Skip to main content

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: L0 annotated directory layout · L1 key files ranked by import graph · L2 public signatures.
  • Freshness contract — deterministic output, check with 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

MIT

Metadata

Release files for codemap-agents 0.5.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for codemap-agents 0.5.1
File Size Uploaded
codemap_agents-0.5.1.tar.gz 25.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for codemap-agents 0.5.1
File Interpreter ABI Platform
codemap_agents-0.5.1-py3-none-any.whl Python 3 none any Details

Total release size: 50.1 kB

Release files / codemap_agents-0.5.1.tar.gz

Download URL codemap_agents-0.5.1.tar.gz
Size 25.1 kB
Tags Source
SHA-256 checksum
How to use checksums
a0852bce83ccdd9780602dffccb5eb96c28c1d00b05f3f8cdb182d698e41553f
BLAKE2b-256 checksum
How to use checksums
9dd65e61c24a76c3f7fb15f16b91d5eaa9eaef6e27056336f4e6cef45c129c83
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 11, 2026.

Transparency log

Release files / codemap_agents-0.5.1-py3-none-any.whl

Download URL codemap_agents-0.5.1-py3-none-any.whl
Size 25.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c17752d2ce336d4e17196b786ad5d23305efcde88a8423f547f7f94e99c792ff
BLAKE2b-256 checksum
How to use checksums
51c09fbbbe979112918d8932d8897092dbf6c9999e995384cf02493bbb88ea8b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 11, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.5.1 This release

2 release 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