repomap 开源:扫描代码库生成 CONTEXT.md 供 AI 编码智能体读取
connectjackofficial-source/repomap
repomap 是一个开源工具,扫描代码库后生成紧凑的 CONTEXT.md,让 Claude Code、Cursor、Codex 等 AI 编码智能体快速了解项目结构,避免反复读取文件消耗大量 token。
Scan a codebase and generate a compact
CONTEXT.mdso any AI coding agent understands your project in 30 seconds, not 30 minutes.
Every time you point Claude Code / Cursor / Codex at an unfamiliar repo, it burns hundreds of thousands of tokens re-reading files to figure out where the entry points are, what the classes do, and how things connect.
repomap pre-computes that once: it walks the tree, parses Python with ast
and JS/TS with heuristics, and writes a tight map of files, classes, functions,
and exports. Drop CONTEXT.md at the root and your agent starts oriented.
Install
git clone https://github.com/connectjackofficial-source/repomap.git
cd repomap
python -m repomap.cli /path/to/your/repoUsage
# generate CONTEXT.md for the current project python -m repomap.cli . # write somewhere else python -m repomap.cli ~/src/awesome-app -o docs/MAP.md # skip extra directories python -m repomap.cli . --ignore generated temp # only scan the top two levels python -m repomap.cli . --max-depth 2 # machine-readable output for tooling python -m repomap.cli . --format json -o context.json # skip files with very few symbols (focus on real modules) python -m repomap.cli . --min-symbols 3 # per-language file/symbol counts python -m repomap.cli . --stats # {"\".py\"": {"files": 12, "symbols": 87}, "\".ts\"": {"files": 4, "symbols": 19}}
Example output
# my-app - codebase map **`src/server.py`** - class Server (methods: listen, route, use) - def create_app(config) **`src/db.py`** - class Pool (methods: query, close) - const DEFAULT_LIMIT
How it works
| Language | Extraction |
|---|---|
| Python | ast — classes, methods, functions, constants |
| JS / TS / JSX / TSX | regex — exports, classes, top-level functions |
Skips .git, node_modules, __pycache__, virtualenvs. No network, no
third-party deps.
Use cases
- Speed up onboarding of new AI coding agents
- Generate a reference doc for contributors
- Spot entry points and public exports before a refactor
License
来源:GitHub · github.com