A tiny, local-first CLI that finds the files your AI coding agent actually needs — and packs them into a focused context.
Give your AI agent a map before it touches your code.
A tiny, local-first CLI that finds the files your AI coding agent actually needs — and packs them into a focused context.
No API key.
No cloud.
No embeddings.
No database.
Just your repository.
AI coding agents work better with the right files — not every file in the repo.
A typical project mixes source, tests, docs, build output, lockfiles, assets, and caches. Dumping all of that into an agent wastes tokens and buries the signal.
agent-context scans your repository locally, ranks files for a task, and packs a compact context package you can hand to any coding agent.
Before
Repository
│
└── 428 files
│
▼
AI Agent
│
▼
Too much irrelevant context
After
Repository
│
▼
agent-context
│
├── scan
├── rank
├── filter
└── pack
│
▼
Relevant context
│
▼
AI Agent
.gitignore + builtins — skip node_modules, dist, caches, etc.pip install -e .
# or with test extras
pip install -e ".[dev]"
Requires Python 3.11+.
cd your-project
agent-context analyze
agent-context pack "implement JWT refresh token"
agent-context explain
| Command | Purpose |
|---|---|
agent-context analyze [path] | Repository inventory + token estimates |
agent-context pack "task" | Rank files and write a context package |
agent-context explain [path] | Heuristic repository map |
agent-context tokens <file> | Estimate tokens for one file |
agent-context mcp | Optional read-only MCP server (stdio) |
Common flags:
agent-context pack "fix auth" --tokens 12000
agent-context pack "fix auth" -o ./context.md
agent-context pack "fix auth" --stdout
agent-context pack "fix auth" --json
agent-context pack "fix auth" --verbose
agent-context analyze --json
agent-context --help
agent-context --version
Illustrative example (numbers vary by repository):
$ agent-context pack "fix authentication middleware" --tokens 12000
agent-context
Task
fix authentication middleware
Repository
428 files
184,320 estimated tokens
Selected
7 files
11,842 estimated tokens
Top matches
94 src/auth/middleware.ts
88 src/auth/session.ts
81 src/api/auth.ts
79 tests/auth.test.ts
Context reduction
~93.6%
Written to
.agent-context/context.md
Default output path: .agent-context/context.md
No embeddings. No cloud model. Each file gets an explainable score from signals such as:
| Signal | Typical contribution |
|---|---|
| Filename match | +30 |
| Path / directory match | +25–33 |
| Content match | up to +20 |
| Symbol match | +15 |
| Related test | +10 |
| Source file | +5 |
| Documentation | +3 |
| Large file | −10 |
| Generated-looking path | −30 |
With --verbose, every selected candidate shows its signal breakdown.
Ties break by path for deterministic output.
agent-context is local-first.
.env, *.pem, credentials.json, …) are excluded from packed context.[REDACTED].Limitations: redaction is heuristic. It can miss unusual secret formats and may over-redact. Review generated context before sharing it outside your machine. The optional MCP server is also local stdio — treat whichever agent consumes the context according to that agent's own privacy model.
Optional read-only MCP tools:
analyze_repositoryfind_relevant_filesbuild_contextrepository_map# Claude Code (stdio)
claude mcp add agent-context -- agent-context mcp
Optional .agent-context.toml in the repo root:
[context]
max_tokens = 12000
[security]
redact_secrets = true
[files]
include = ["src/**", "tests/**"]
exclude = ["generated/**"]
Configuration is optional. The CLI works with zero config.
Language-agnostic by design. Heuristics understand common layouts and extensions for:
TypeScript / JavaScript, Python, Go, Rust, Java/Kotlin, C/C#, Ruby, PHP, and typical web app trees (src/, app/, tests/, …).
Stack detection for explain is filename/manifest-based (e.g. package.json, pyproject.toml, go.mod) and intentionally cautious.
src/agent_context/
cli.py argparse entrypoint
scanner.py discovery + classification
ignore.py builtins + .gitignore
scoring.py deterministic relevance
tokens.py approximate token estimates
security.py secret detection / redaction
packer.py budget selection + markdown
explain.py heuristic repo map
config.py optional TOML
mcp.py optional stdio MCP server
Small modules. Standard library first. No AI framework.
Optimize only when something is measurably slow.
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -e ".[dev]"
pytest
pytest
pytest --cov=agent_context --cov-report=term-missing
Tests cover scanning, ignore rules, scoring, packing, security redaction, CLI commands, and MCP tool wiring.
.gitignore supportKeep the project small.