map-modules
Skill1 starsChanged 4 months agoMITView on GitHub
Use when bootstrapping a contract tree — either extracting module contracts from an existing codebase or designing a module tree greenfield before writing code. Produces per-module `CONTRACT.md` files and the `.contract-tree/tree.md` index.
In this repository3 other files it gives its agents.
- change-with-contractsSkill
- check-driftSkill
- contract-treeSkill
The file
We split this skill into the rules it gives an agent
2 rules. About 0 are common, 0 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 57
Every module directory in scope has a CONTRACT.md valid per references/contract-format.md.
- Very specific: line 62
Only upstream was authored.
≈ “Common” is an estimate: at least 1 in 5 of the 372,429 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Map Modules
Bootstrap a contract tree. Two entry modes, one output: a CONTRACT.md in each
module directory plus a .contract-tree/tree.md index at the repo root.
Read references/contract-format.md first — it is the canonical on-disk
format. Do not invent field names.
Which mode
- Legacy — the code already exists; extract contracts from it.
- Greenfield — no code yet; design the tree and contracts first, then let code fill the declared entrypoints.
You can also run legacy mode on just one area of a large repo — you do not have to map everything at once.
Legacy mode (extract from code)
Read references/extraction-heuristics.md for how to find boundaries and infer
fields. Then:
- Walk the directory tree of the target area. Identify module candidates — directories with a cohesive purpose behind a small public surface.
- Go bottom-up: characterize leaf modules (no upstream) first, then parents.
- For each module, draft a
CONTRACT.md: inferentrypointsfrom public exports,io.input/io.outputfrom their signatures,upstreamfrom cross-module imports, and invariants from what the code guarantees. - Apply the granularity stop rule — don't make a contract per tiny file; stop when a module is one boundary / one purpose.
- Present the drafts for review. Extraction is a proposal; the user corrects intent the code doesn't state. Do not commit contracts silently.
- Generate
.contract-tree/tree.mdfrom the approved contracts: one indented line per module,→edges pointing at each module's downstream (derived by invertingupstream),(leaf)where none.
Greenfield mode (design first)
- Interview the user about the top-level split: what are the root modules, and how does each divide (the "2 modules → 5 each" shape)? Keep dividing only while each piece stays one boundary / one purpose.
- For each planned module, write a
CONTRACT.mdwith purpose, intendedio.input/io.output,upstream, invariants, and theentrypointsthe code will expose (files/symbols that don't exist yet — that's fine; they are the contract the code must fulfill). - Generate
.contract-tree/tree.mdfrom those contracts. - Code is then written to fill the declared entrypoints, and
change-with-contractsgoverns later edits.
Output checklist
- Every module directory in scope has a
CONTRACT.mdvalid perreferences/contract-format.md. .contract-tree/tree.mdexists at the repo root, its edges match the contracts'upstreamrelations (inverted), and its header note names the contracts as the I/O source of truth.- Only
upstreamwas authored;downstreamwas derived, never hand-written.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

