Auto-generated, budget-bounded codebase maps inside AGENTS.md — spec + stdlib-only reference generator with git-hook, CI, watch, and MCP integrations
Project description
codemap
Auto-generated, budget-bounded codebase maps inside AGENTS.md — so coding agents stop re-exploring your repo at the start of every session.
Coding agents don't fail at finding code; they fail at knowing the shape
of a system in the first minutes of a session. Codemap keeps a small
(≤ 2,000-token) machine-generated map inside AGENTS.md
— the context file agents already read — and keeps it provably fresh.
- Compass, not encyclopedia — three layers under a hard token budget:
L0annotated directory layout ·L1key files ranked by import graph ·L2public signatures. - Freshness contract — deterministic output,
checkwith CI-friendly exit codes, a pre-commit hook so the map travels in the same commit as the change, and an MCP server that refreshes the map at session start. - Zero dependencies — single stdlib-only Python package (≥ 3.9), 40+ languages, local-only, no network, never fails on unknown file types.
- A format, not just a tool — the block layout and freshness rules are a spec (codemap-spec.md); any generator can implement it.
Install
pipx install codemap-agents # PyPI (or: uv tool install codemap-agents)
pipx install git+https://github.com/xenitV1/codemap # bleeding edge
# or, from a clone: python3 bin/codemap ... / pipx install .
The installed command is codemap in all cases.
Always-latest, npx-style (no install)
For MCP configs that should track the newest release automatically — the
Python equivalent of npx some-server@latest:
uvx codemap-agents@latest mcp --no-cache # PyPI
uvx --refresh --from git+https://github.com/xenitV1/codemap codemap mcp --no-cache # git HEAD
Trade-off: the launcher checks for updates at every server start (a few
seconds cold). Pin a version or use pipx install if session startup
latency matters more than freshness.
Quickstart
cd your-project
codemap update # writes the map block into ./AGENTS.md (creates skeleton if missing)
codemap check # exit 0 fresh / 1 drift / 2 no map — wire this into CI
codemap install --ci # pre-commit hook + GitHub Actions freshness gate
Everything between <!-- codemap:begin --> and <!-- codemap:end --> is
machine-owned; everything outside is yours (architecture notes, conventions,
warnings — the parts only humans can write).
Exclude vendored or irrelevant directories with gitignore-like globs in a
repo-local .codemapignore (travels with the repo, CI sees it) or a
user-global ~/.codemapignore (every repo on your machine).
Automatic mode (MCP)
codemap mcp is a stdio MCP server. Registered once at user scope, it starts
automatically with every agent session, refreshes AGENTS.md for the project it
opens in (git repos only), and exposes on-demand tools: codemap (return a
fresh map without writing files), codemap_update, codemap_check.
# Claude Code
claude mcp add --scope user codemap -- codemap mcp --no-cache
# Codex CLI — ~/.codex/config.toml
[mcp_servers.codemap]
command = "codemap"
args = ["mcp", "--no-cache"]
# opencode — ~/.config/opencode/opencode.json
"mcp": { "codemap": { "enabled": true, "type": "local",
"command": ["codemap", "mcp", "--no-cache"] } }
Any other MCP client: stdio transport, command codemap mcp --no-cache.
Agent skill
codemap skill # installs SKILL.md into ~/.agents/skills/codemap and ~/.claude/skills/codemap
Skill-aware agents (Claude Code, Codex, …) then know when and how to use the tool without extra prompting.
All commands
| Command | What it does |
|---|---|
codemap update |
(Re)generate the map block in ./AGENTS.md |
codemap check |
Freshness: exit 0 fresh / 1 drift / 2 missing |
codemap print |
Write the block to stdout, touch nothing |
codemap install [--ci] |
Pre-commit hook (+ CI workflow) for this repo |
codemap watch |
Regenerate on every source change while you work |
codemap mcp |
MCP stdio server with session-start auto-refresh |
codemap skill |
Install the agent SKILL.md |
Options: --root PATH · --file AGENTS.md · --budget 2000 · --no-cache ·
--quiet · --interval N · --include-ext .foo,.bar
How it works
A full tree walk every run (adds/deletes reflected by construction), regex
import/symbol extraction per language, import-graph PageRank for L1 ranking,
and budget-driven degradation (drop L2 first, then L1, then collapse L0).
Output is deterministic — same tree, same bytes — which is what makes check
and reviewable map diffs possible. An incremental content-hash cache makes
warm runs fast and is semantically invisible.
Measured: ~130-file repo ≈ 0.2 s · ~900-file repo ≈ 0.4 s cold.
Tests
python3 -m unittest discover -s tests -v
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file codemap_agents-0.5.1.tar.gz.
File metadata
- Download URL: codemap_agents-0.5.1.tar.gz
- Upload date:
- Size: 25.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a0852bce83ccdd9780602dffccb5eb96c28c1d00b05f3f8cdb182d698e41553f
|
|
| MD5 |
08429efec42fe363e9a47d62b0b1c003
|
|
| BLAKE2b-256 |
9dd65e61c24a76c3f7fb15f16b91d5eaa9eaef6e27056336f4e6cef45c129c83
|
Provenance
The following attestation bundles were made for codemap_agents-0.5.1.tar.gz:
Publisher:
publish.yml on xenitV1/codemap
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
codemap_agents-0.5.1.tar.gz -
Subject digest:
a0852bce83ccdd9780602dffccb5eb96c28c1d00b05f3f8cdb182d698e41553f - Sigstore transparency entry: 2145585638
- Sigstore integration time:
-
Permalink:
xenitV1/codemap@879f203a3b039e83d79124bb156873f63de49412 -
Branch / Tag:
refs/tags/v0.5.1 - Owner: https://github.com/xenitV1
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@879f203a3b039e83d79124bb156873f63de49412 -
Trigger Event:
release
-
Statement type:
File details
Details for the file codemap_agents-0.5.1-py3-none-any.whl.
File metadata
- Download URL: codemap_agents-0.5.1-py3-none-any.whl
- Upload date:
- Size: 25.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c17752d2ce336d4e17196b786ad5d23305efcde88a8423f547f7f94e99c792ff
|
|
| MD5 |
da4d1985131104a97e727823903df928
|
|
| BLAKE2b-256 |
51c09fbbbe979112918d8932d8897092dbf6c9999e995384cf02493bbb88ea8b
|
Provenance
The following attestation bundles were made for codemap_agents-0.5.1-py3-none-any.whl:
Publisher:
publish.yml on xenitV1/codemap
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
codemap_agents-0.5.1-py3-none-any.whl -
Subject digest:
c17752d2ce336d4e17196b786ad5d23305efcde88a8423f547f7f94e99c792ff - Sigstore transparency entry: 2145585726
- Sigstore integration time:
-
Permalink:
xenitV1/codemap@879f203a3b039e83d79124bb156873f63de49412 -
Branch / Tag:
refs/tags/v0.5.1 - Owner: https://github.com/xenitV1
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@879f203a3b039e83d79124bb156873f63de49412 -
Trigger Event:
release
-
Statement type: