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.0.tar.gz (14.5 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.0-py3-none-any.whl (14.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: context_gen_cli-1.2.0.tar.gz
  • Upload date:
  • Size: 14.5 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.0.tar.gz
Algorithm Hash digest
SHA256 7ab6bd5f5255242244b8d47a50da08fb0e0eb8b276642453e281d82318da3f5d
MD5 caabcfd8e268b2d6e30ff0773df9bc87
BLAKE2b-256 c5f623a985c21fde92d1653a2ccb3fd7d05fe376f33ee775d093c7217fb7f016

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for context_gen_cli-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d5f7050a89bf937caafb1862d1a379baa3bf275c168ebde69c74a739c6fce382
MD5 a049acd4f1c1571dee20d9e2c7fd225a
BLAKE2b-256 448d93093f87fe27b43ed003fa4cdeb048ee2736b8a5c41dcb8c129f9b788616

See more details on using hashes here.

Release history Release notifications | RSS feed

1.2.5

2 files

1.2.4

2 files

This release

1.2.0 This release

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