Communityコーディング&開発github.com

cartographer

Token-saving code navigation for coding agents. Use BEFORE exploring any codebase (new workspace, "how does X work", "where is Y", any fix/refactor/feature in unfamiliar code), BEFORE opening a source file over 120 lines, BEFORE editing code others import, at the START of any long task (more than 5 steps or 3+ files), AFTER context compaction or when resuming, and BEFORE saying a coding task is done. Gives a ranked skeleton map with exact line ranges, line-exact reads, telegraphic task memory, and syntax verification.

cartographer とは?

cartographer is a Claude Code agent skill that token-saving code navigation for coding agents. Use BEFORE exploring any codebase (new workspace, "how does X work", "where is Y", any fix/refactor/feature in unfamiliar code), BEFORE opening a source file over 120 lines, BEFORE editing code others import, at the START of any long task (more than 5 steps or 3+ files), AFTER context compaction or when resuming, and BEFORE saying a coding task is done. Gives a ranked skeleton map with exact line ranges, line-exact reads, telegraphic task memory, and syntax verification.

対応~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/Byronz123/cartographer/tree/HEAD

Installed? Explore more コーディング&開発 skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

お気に入りのAIに質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

cartographer は何をしますか?

Spend context only on code that matters: irrelevant code costs tokens and accuracy. S=<skill_dir> = folder of this file. Run python3 "$S/scripts/<tool>.py" from the project root (Windows: python or py -3; Python 3.9+, nothing to install). The 4 Laws are mandatory; each is scaled to the task, so none is optional "ceremony".

Law 1 — Skeleton Survey First

  • Never start with ls -R, find, tree, dir /s, Get-ChildItem -Recurse, **/* globs, or whole-file reads. Allowed: one non-recursive ls, or a file the user named.
  • Task known → map_workspace.py --query "<3-6 identifiers / domain words>" → top 10 files (--top N), each with imports/imported-by and only the matching symbols: .def save(db: "Session", retries: int = 3) -> None [L13-18].
  • Know the name → map_workspace.py --find <Name|Class.method> → file + [La-b] of each definition. Prefer it over grep for definitions.
  • Grep is fine after the map, for exact strings that are not definitions (error messages, config keys, CSS classes, call sites).
  • Big picture → map_workspace.py (entry points, suggested checks, deps, hotspots, tree, skeleton).
  • Resuming or reviewing work in progress → map_workspace.py --changed (--changed main for a branch).
  • ⚠ syntax error in a skeleton = already broken before you; report it.

Impact check — run map_workspace.py --impact <file> before you change anything other code relies on: a function/method signature, an exported name, a rename/move/delete, a return type or shape. Then fix every direct importer it lists. Not needed for changes inside a function body that keep its contract (e.g. a constant, a condition, a message).

Law 2 — Surgical Reading Only

  • File over 120 lines → never read it whole (no normal read tool, cat, type, Get-Content).
  • Read only the block you need, by the map's range or by name: surgical_read.py --file <path> --start <A> --end <B> · surgical_read.py --file <path> --symbol Class.method
  • Output: Showing Lines 115-173 of 1,450 total lines; target lines 120 | …, ±5 context 115 : …. Line numbers are exact; edit by them. Need a caller? --find it and read that range.
  • Several reads may go in one shell call.

Law 3 — Telegraphic Breadcrumbs (long or resumable work)

  • Required when the task has more than 5 steps, touches 3 or more files, the user says "continue/resume", or the context was compacted. Small edits (1-2 files, few steps) skip it.
    1. checkpoint_manager.py --status first. Resume if it matches; unrelated → ask before --init --force.
    2. None → --init "<objective; done-criteria>" then --update --next "A;B;C".
    3. After each step: --update --done "<what>" --next "<next>" --files "a.py,b.ts" [--note "<decision>"].
  • Telegraph style: one line ≤160 chars, no filler, keep identifiers/paths/numbers/decisions. invoice calc → Invoice.total() · VAT: Decimal not float (rounding)
  • After compaction or interruption: --status before anything else; trust it over memory.

Law 4 — Zero-Error Verification (every task that edited files)

  1. Run checkpoint_manager.py --verify after every editing task, even if tests already passed. No state file needed: it checks git-modified files (plus --files / recorded files) with the language's own parser: Python, JSON/ipynb, TOML, JS (node --check), PHP (php -l), Ruby (ruby -c), shell (bash -n), Go (gofmt -e); a missing tool is reported, never faked.
  2. It must end ✔ Verification passed. On ✘, fix the first error (a caret marks the line), then re-run. ✘ on a git file you never touched → pre-existing; tell the user, don't silently fix. It also prints Laws this task: ✔ 1 survey · ✔ 2 surgical · – impact · – 3 memory · ✔ 4 verify from a local log of this task's Cartographer calls. Every ✘/⚠ line names what was missed; fix it now when you can (e.g. re-read a changed file surgically), and mention the rest.
  3. Then run the commands it prints after Next: (the project's tests/lint/build) and any related tests from --impact. If one cannot run, say so in your answer.
  4. Terminal errors: use only the ≤5 root-cause lines (first error, its file:line, the failing code). Never paste or re-read full logs; surgical_read.py the frame in your code, fix, re-run.
  5. If .cartographer_state.md exists, ask once: "Keep it or delete it?" → --clean only on a clear yes.

Quick Reference

NeedCommand
Relevant files + line rangesmap_workspace.py --query "jwt refresh expiry"
Where is X definedmap_workspace.py --find Invoice.total
Whole-repo overviewmap_workspace.py (--path sub/, --depth 2, --max-chars 25000)
Read lines / a symbolsurgical_read.py --file F --start A --end B / --symbol Name
Who depends on a filemap_workspace.py --impact F
Work in progressmap_workspace.py --changed [REF]
Memory (long tasks)checkpoint_manager.py --status / --init / --update / --clean
Done?checkpoint_manager.py --verify → then its Next: commands

Error messages, worked examples, map tuning and the optional Rust engine (ask the user before installing it) are in references/REFERENCE.md. Read it only when you need it.

Final check before you say "done" — answer each in your head:

  1. Did I start with --query/--find (not ls -R/full reads)?
  2. Did I read files over 120 lines only surgically?
  3. Did I run --impact if I changed a signature, export or name?
  4. Long task (>5 steps or 3+ files)? Then is the state file up to date?
  5. Did --verify pass, and did I run its Next: checks (or say why not)?
  6. If a state file exists, did I ask whether to keep it?

関連スキル