Skip to main content

⚡ context-gen-cli (Python Edition)

PyPI version Python Versions License: MIT

Fast, AST-powered Python CLI tool that scans any project, extracts architecture models, and generates structured LLM context (agent.md, agent.json, agent.yaml).


🌟 Highlights

  • 100% Accurate Python Dependency Graphs: Built using Python's native ast (Abstract Syntax Tree) module to resolve imports, relative packages, entry points, and utilities without regex guesswork.
  • ⚡ All-In-One Default Mode (-d): Auto-generates triple context formats in context/ and runs a live auto-sync watcher in the background.
  • .gitignore & Multi-Ignore Respect: Automatically parses rules from .gitignore, .npmignore, .dockerignore, .contextignore, .ignore, and filters .env* secrets.
  • Triple Format Output: Generates Markdown (agent.md), MCP-compatible structured JSON (agent.json), and clean YAML (agent.yaml).
  • 🔄 Auto-Sync Watch Mode (-w): Monitors workspace changes and updates context files automatically on save.
  • Configuration Parity: Seamlessly reads .context-gen.json if present to maintain unified project settings with the Node.js edition.
  • Modern CLI: Styled with typer and rich for rich terminal output and progress reporting.

📦 Installation

Install from PyPI using pip (or pipx / uv):

pip install context-gen-cli

🚀 Quick Start

1. ⚡ All-In-One Default Mode (Recommended)

Generates all formats in context/ and starts the live auto-sync watcher in background:

context-gen -d

2. Generate All Formats (Markdown, JSON, YAML)

Scans the current directory and outputs agent.md, agent.json, and agent.yaml in context/:

context-gen .

3. Generate Specific Format (JSON / MD / YAML)

Generate only the format you need:

# Generate MCP-ready JSON
context-gen . --format json

# Generate Markdown
context-gen . --format md

# Generate YAML
context-gen . --format yaml

4. Watch Mode

Keep context files fresh automatically on every file edit:

context-gen . --watch

5. Custom Output Destination & Directory Depth

context-gen ./my-project -o custom/docs/context.md --max-depth 4

📖 CLI Reference

Usage: context-gen [OPTIONS] [PATH]

Arguments:
  [PATH]    Target project directory to analyze  [default: .]

Options:
  -d, --default             ⚡ Zero-config default mode: generate all formats in context/ and run live auto-sync watcher
  -f, --format [all|md|json|yaml]  Output format [default: all]
  -o, --output PATH         Custom output file path (e.g. context/agent.md or custom.json)
  -w, --watch               Watch directory and auto-regenerate context on file changes
  --max-depth INTEGER       Maximum directory depth to scan (1-10) [default: 3]
  --help                    Show this message and exit

🌐 Node.js & Live MCP Server

Looking for the live MCP server with interactive SSE streaming and public tunnels? Check out the Node.js edition:

npx context-gen-cli -d
# or
npx context-gen-cli --mcp

📄 License

MIT © yakkshit

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

context_gen_cli-1.2.4.tar.gz (19.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

context_gen_cli-1.2.4-py3-none-any.whl (20.4 kB view details)

Uploaded Python 3

File details

Details for the file context_gen_cli-1.2.4.tar.gz.

File metadata

  • Download URL: context_gen_cli-1.2.4.tar.gz
  • Upload date:
  • Size: 19.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.11.5

File hashes

Hashes for context_gen_cli-1.2.4.tar.gz
Algorithm Hash digest
SHA256 7e6598432e0334b86aa6f1e8c0abc8876a82a84893d1103414de7ae894890de2
MD5 c059b5dc24f3de3a3af5f8f706889597
BLAKE2b-256 05bfc4493714a9a33ed0d72d09400f142730026b0533dedc9b53122d4256ea8e

See more details on using hashes here.

File details

Details for the file context_gen_cli-1.2.4-py3-none-any.whl.

File metadata

File hashes

Hashes for context_gen_cli-1.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 303468071bd985bdb840b396809ddf4a806154215ffde6d7b926dc759853b4df
MD5 9affba1da52fa50556cbf888688fb701
BLAKE2b-256 60fc669df611a2ee0551d75cf4f78dd139e52db220e7b367cad09820105ad6fa

See more details on using hashes here.

Release history Release notifications | RSS feed

1.2.5

2 files

This release

1.2.4 This release

2 files

1.2.0

2 files

1.0.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page