A tiny, local-first CLI that finds the files your AI coding agent actually needs — and packs them into a focused context.
Guidance for Claude Code (and similar agents) working on this repository.
agent-context is a small, local-first Python CLI that:
It does not call external LLMs, embeddings APIs, or databases.
| Module | Role |
|---|---|
cli.py | argparse CLI (analyze, pack, explain, tokens, mcp) |
scanner.py | Walk tree, classify files, estimate tokens |
ignore.py | Built-in ignores + .gitignore |
scoring.py | Explainable relevance scores |
tokens.py | Approximate tokens ≈ characters / 4 |
security.py | Sensitive path detection + redaction |
packer.py | Budget selection, truncation, markdown |
explain.py | Heuristic repository map |
config.py | Optional .agent-context.toml |
mcp.py | Optional JSON-RPC MCP over stdio |
Package root: src/agent_context/.
agent-context analyze
agent-context pack "task" --tokens 12000
agent-context explain
agent-context tokens README.md
agent-context mcp
Flags of note: --json, --verbose, --stdout, -o, --version, --help.
pip install -e ".[dev]"
pytest
pytest --cov=agent_context
Security tests must keep failing if secrets leak into packed markdown.
Avoid new dependencies unless they are mature, tiny, and clearly better than stdlib.
Do not add: LangChain, LlamaIndex, OpenAI/Anthropic SDKs, embedding clients, vector DBs, ORMs.
Prefer extending heuristics in scoring.py / security.py over new frameworks.
explain wording must stay hedged (“Detected”, “Likely”, “Potential”).mcp.py; CLI users should not need MCP concepts.