codemaps
Skill1 starsChanged 7 months agoMITView on GitHub
Set up "codemaps" — a deterministic, auto-updating map of a whole repo (routes, API, data model with FK edges, components, env, specs) that agents read first as grounded ground truth so they never get confused or hallucinate structure. Use when the user asks to create/install codemaps, a "repo map", "codebase map", "project map", "the brain of the repo", "architecture docs that auto-update", "grounded project context for agents", or wants a hook that regenerates structure docs when code changes. Builds a project-tailored generator + Stop hook; works on any project (Next.js/Drizzle reference impl included, recipes for Prisma/SQL/Express/etc.).
- Reads credentials
In this repository50 other files it gives its agents.
- ab-test-setupSkill
- Agent DevelopmentSkill
- analytics-trackingSkill
- autonomous-spec-runsSkill
- backend-patternsSkill
- claude-opus-4-5-migrationSkill
- Command DevelopmentSkill
- competitor-alternativesSkill
- conciseSkill
- continuous-learning-v2Skill
- coolify-vpsSkill
- copy-editingSkill
- copywritingSkill
- create-agentic-specSkill
- create-specSkill
- crmSkill
- decision-toolkitSkill
- email-replySkill
- email-sequenceSkill
- form-croSkill
- free-tool-strategySkill
- frontend-patternsSkill
- indexnowSkill
- launch-strategySkill
- marketing-ideasSkill
- marketing-psychologySkill
- MCP IntegrationSkill
- og-imageSkill
- onboarding-croSkill
- page-agentSkill
- page-croSkill
- paid-adsSkill
- paywall-upgrade-croSkill
- popup-croSkill
- postgres-patternsSkill
- pricing-strategySkill
- profile-learnerSkill
- programmatic-seoSkill
- qa-deliverablesSkill
- referral-programSkill
- schema-markupSkill
- security-reviewSkill
- seo-auditSkill
- signup-flow-croSkill
- social-contentSkill
- strategic-compactSkill
- stripe-best-practicesSkill
- tdd-workflowSkill
- unified-dev-envSkill
- upwork-listingsSkill
The file
We split this skill into the rules it gives an agent
5 rules. About 0 are common, 2 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 43
Follow these steps in order.
- Very specific: line 63
Add the package.json scripts, then pnpm codemaps (or the repo's runner).
- Very specific: line 66
Idempotency: run it twice → git status docs/codemaps shows no modifications on the 2nd.
- Distinctive: line 69
Run the repo's typecheck/lint on the new generator file.
- Very specific: line 91
Every file is machine-derived — if one looks wrong, fix the generator (or, for flows.md, the source file's JSDoc header), never the output …
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 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
Codemaps
A codemaps system gives AI agents a grounded, always-current map of the repo so they stop re-deriving structure (burning context) or guessing at routes/tables/services that don't exist.
Core idea: the whole map is derived mechanically from the real files by a fast deterministic generator (no LLM, no network) — it cannot hallucinate. A Stop hook keeps it fresh on every change.
Output lives in docs/codemaps/ — all auto-generated:
architecture.md— entry point: stack, counts, links, spec statusfrontend.md— pages/routes + component groupsbackend.md— server actions, API handlers + auth, lib modules, integrationsdata.md— DB tables with FK edges + types, migrations, envflows.md— the "why": built by quoting each flow module's top-of-file JSDoc header verbatim
flows.md is the key idea for the "why". A scan can't infer intent — but the codebase already
records it in file-header comments, which the coding agent writes and updates next to the code
(this survives vibe-coding: the human never writes comments, the agent does). The generator
quotes those headers verbatim — grounded, never fabricated; a stale header yields a stale quote,
not an invented one. A small AGENTS.md "header-freshness" rule keeps them current. Nothing is
hand-written, so idempotency stays a trivial string compare and truth stays grounded.
Bundled resources
assets/generate.ts— a complete, working reference generator (Next.js App Router + Drizzle). Copy it to the target repo and adapt the scanners + CONFIG block. Sections to change are marked// ADAPT:. Keep the core machinery and the invariants intact.references/generator-patterns.md— scanner recipes per stack (Next.js/Remix/SvelteKit/ Express routes; DrizzlegetTableConfig/ Prisma / raw SQL schema; env; specs; the plain-node regex fallback) and the non-negotiable invariants. Read before adapting scanners.references/hook-and-wiring.md— the exact Stop-hooksettings.json+codemaps.sh, the/update-codemapscommand, the AGENTS.md pointer,.gitignore, and the doc-blocker note. Read at the wiring step.
Workflow
Follow these steps in order. Act as the builder: scan the repo, adapt the template, verify against reality, then wire the hook. Do NOT hand-write the structural files — the generator produces them.
1. Inventory the repo
Determine what to map and how. Identify: framework + router (App/Pages Router, Remix, Express…),
ORM + schema location (Drizzle schema.ts, schema.prisma, SQL migrations), source roots
(src/? app/?), env mechanism (Zod schema vs .env.example), whether a specs/*/STATUS.md
convention exists, and the script runner (tsx/ts-node/bun/plain node). Read
references/generator-patterns.md for how each maps to a scanner.
2. Build the generator
Copy assets/generate.ts to scripts/codemaps/generate.ts (or .mjs for a plain-node repo —
see the fallback in the patterns ref). Adapt each // ADAPT: site: schema import path + ORM
introspection, source roots, auth probe, env path, the INTEGRATIONS list, migrations dir, the
specs scanner (delete it if there's no specs convention), and the flows scanner's dirs +
FLOW_EXCLUDE (scope out scratch/discovery dirs whose headers aren't live flows). Preserve the
invariants (deterministic, idempotent write, fail-safe schema try/catch).
3. Run and verify against reality
Add the package.json scripts, then pnpm codemaps (or the repo's runner). Verify the output
is TRUE:
- Spot-check counts/rows against
find/grep(pages, API handlers, tables, FK edges). - Idempotency: run it twice →
git status docs/codemapsshows no modifications on the 2nd. - Source propagation: make a throwaway schema/route change → confirm it appears in the map → revert.
- Run the repo's typecheck/lint on the new generator file; fix any errors. Iterate on the scanners until the map matches the codebase exactly.
4. Check flows.md and the header convention
flows.md generates automatically from existing file-header JSDoc. Review it: if key flow
modules have thin or missing headers, the "why" will be thin — improve those source headers
(not flows.md) so the next run picks them up. Tune FLOW_EXCLUDE / dirs if it's too noisy or
missing an area. Do NOT hand-write flows.md — the generator owns it.
5. Wire the auto-refresh and consumption
From references/hook-and-wiring.md: create .claude/settings.json (Stop hook + allow rules)
and .claude/hooks/codemaps.sh (chmod +x, and ADAPT its git-status gate paths to the repo's
source roots), the /update-codemaps command, the .gitignore entry, and the AGENTS.md/CLAUDE.md
pointer including the header-freshness rule (when you change a module's behavior, update its
JSDoc header in the same edit — that's what keeps flows.md true).
6. Final verification
pnpm codemaps:check exits 0 (up to date). Simulate the hook: bash .claude/hooks/codemaps.sh
with a dirty source file regenerates; with only a docs/codemaps change it exits 0 (no regen).
Confirm the lock dir is cleaned up. Run the repo's full check (lint + typecheck) once more.
Key invariants (never violate)
- Every file is machine-derived — if one looks wrong, fix the generator (or, for
flows.md, the source file's JSDoc header), never the output file. - Idempotent writes — no source change means no write means no git churn.
- The schema scan is fail-safe (try/catch leaves
data.mduntouched on parse failure). - The hook is async, change-gated, and never blocks a turn; every failure path exits 0.
flows.mdquotes source JSDoc headers verbatim — grounded, never fabricated. Nothing is hand-written; the AGENTS.md header-freshness rule keeps the quoted headers current.
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.

