/arrow-maintenance:map-codebasefrom arrow-maintenance
Bootstraps LID (Linked Intent Documentation) in an existing codebase by deep-reading every file, offering lens-based clustering, generating skeleton LLDs/HLD/EARS bottom-up, and creating arrow docs. Use when asked to map a codebase, reverse-engineer design, or start LID on a brownfield project.
Ships in arrow-maintenance. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description, though model invocation is off: only you can start it.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
This skill maps an existing codebase into the arrow of intent. It works bottom-up: read all the code in scope first, then propose lens-based clusterings for the user to choose among, then generate skeleton docs that describe what actually exists.
See brownfield-bootstrap.md for detailed guidance per phase.
These govern every phase. Apply consistently.
[inferred] markers; known technical debt and behavioral quirks go in Open Questions.Newcomer tour offer. Unless the state dispatch below sends the person to /arrow-maintenance, check whether the memory your harness already placed in your context shows that this person has met LID before: a record of the LID tour, or other memories of them working with LID. If it doesn't, load the linked-intent-dev skill, read its references/tour-offer.md, and follow it as a setup route. That puts a card at the top of your first message, above the token-intensity warning and your first question. If the linked-intent-dev skill isn't installed, make no offer.
Ask one question first:
This question determines scope and mode simultaneously — the user is not asked a separate "Full or Scoped?" later at terminal verification. Default to Full (whole project) if the user is undecided.
Then ask:
Token-intensity warning. Tell the user upfront this is token-intensive by design — reading every file, proposing multiple lenses, drafting skeletons for every segment, multi-step reconciliation. Not a lightweight operation. Users expecting a quick one-shot map should reconsider.
Undo. The workflow's STOPs between phases are the undo mechanism — aborting at any STOP leaves nothing written to disk. Agent harnesses also provide their own session-level rewind. LID does not ship a dedicated /unmap-codebase command; users roll back via the agent framework's rewind or by reverting a git commit.
Inspect the project before starting:
docs/arrows/. Redirect the user to /arrow-maintenance — that command bootstraps the overlay from existing docs without the brownfield sweep. Do not proceed here.Read every file in the declared scope. Not a sample. Sampling risks missing behaviors that only surface in edge-case files and locks in segmentation based on incomplete view.
For each file, record a structured summary:
Output: a flat list of observed behaviors with file/line references. No segmentation attempted here.
Capacity constraint handling. If the declared scope exceeds the invocation's capacity (single-agent context window, or the chosen subagent budget), surface the constraint with concrete sizing evidence, warn the user that a sampled sweep produces lower-quality mapping, and recommend narrowing scope or enabling subagent parallelism. The user may override and proceed with sampling anyway. Under override, preserve state across truncation points via per-subagent files (docs/arrows/_map-codebase/sweep-{N}.md) or by incrementally writing arrow-doc partial drafts during reconnaissance — never silently discard information the orchestrator cannot hold.
When subagents ran in parallel, each subagent writes its sweep to its own file; the orchestrator processes them in chunks during Phase 2. The docs/arrows/_map-codebase/ working area is transient handoff state, not overlay content — remove it at terminal verification.
See subagent-sweep-prompt.md for the prompt template given to sweep workers.
Propose 3–5 fundamentally different clusterings, each using a distinct lens. Not variations on one theme — entirely different mental models.
Good lenses to propose:
Anti-pattern lenses to explicitly avoid:
For each proposed clustering, present: name, lens, the clusters it produces, pros, cons, and best-for (what kind of reasoning it supports well).
STOP. User picks a lens. Multiple lenses are the primary edge-detection mechanism — the user's choice of lens reveals latent intent in a way no single clustering can.
See reconciliation-template.md for the presentation format.
Within the chosen lens, propose 2–3 slicing variations:
Coarse absorbs more code per LLD; fine gives precise segment-scoped tracking. Pick based on project maturity and the user's appetite for maintenance.
When a fine slicing produces more segments than sit comfortably at one level, propose grouping related leaves under sub-HLD (grouping) nodes — a shallow tree rather than a long flat list. Most projects map flat (depth-2: leaves directly under the root); nesting is offered only when the leaf count makes a grouping level genuinely clarifying. The tree placement chosen here drives the parent/children links and the mirrored artifact paths in Phase 5.
STOP. User picks a slicing.
Present the final candidate clustering (chosen lens + chosen granularity). User:
Where parallel subagents disagreed on segment assignments earlier, flag those conflicts prominently here.
Component quality check. When reviewing, apply the working definition: a segment should be an independent system achieving an independent purpose. Flag proposed segments that match anti-patterns (team boundaries, deployment units, file locations, generic "utils") rather than accepting them silently.
Derive segment and component names from the codebase's existing vocabulary — its module and directory names, its domain terms — rather than imposing LID labels on the project (HLD tenet: Speak the project's language).
STOP. User approves the final clustering before artifact generation begins.
The design layer is a recursive tree. A leaf node owns EARS and an arrow doc; an intermediate (sub-HLD) node groups its children and owns neither. Where the chosen granularity produces nested structure — leaf segments gathered under a grouping node — that nesting is the design tree, and every artifact path mirrors it. A flat depth-2 mapping (the common case) has every segment at the root level, so the mirrored path collapses to a single folder name. {segment-path} below means the root-to-leaf path; at depth-2 it is just the segment name.
For each approved leaf segment, generate these artifacts in order with a STOP after each:
docs/arrows/{segment-path}.md (e.g. docs/arrows/billing/invoicing.md for an invoicing leaf under a billing group; docs/arrows/auth.md for a root-level auth leaf) — References pointing to actual files, initial status: MAPPED. Grouping (sub-HLD) nodes are directories, not arrow docs. See arrow-doc template. STOP.docs/intent/{segment-path}/{segment-name}-design.md (node-as-folder; e.g. docs/intent/billing/invoicing/invoicing-design.md, or docs/intent/auth/auth-design.md at depth-2) — standard LLD template (lld-templates), no separate brownfield template. Content carries brownfield state: [inferred] markers in Decisions & Alternatives table, Open Questions for observed-but-unexplained behaviors. STOP.docs/intent/<segment-path>/{segment-name}-specs.md — reserved spec-ID prefix that is the segment's root-to-leaf path (path-concatenated: the leaf prefix is the full path from the root, e.g. a runner leaf under prompt-eval reserves PEVAL-RUN). Ask the user for a namespacing parent if the prefix collides with an existing one. Initial status semantics:
[x] — behavior is observed as working in current code.[ ] — behavior is specified but broken or partial in current code.[D] — explicit non-wants (intentional non-features); rare in brownfield.
STOP.index.yaml entry under arrows: with the taxonomy placement and the parent/children tree links chosen during reconciliation. A leaf segment carries parent (its grouping node, or null at the root level) and no children; each grouping (sub-HLD) node gets its own entry carrying its children list and no detail. The detail of a leaf points at its tree-mirrored arrow-doc path. At depth-2 every segment sits at the root level with parent: null and no children. Follow the schema in index-schema.md.After all segments are generated, if no HLD exists:
docs/high-level-design.md — standard template (hld-template), bodies marked *(not yet specified)* rather than filled with placeholder content. If an HLD already exists, skip this step — never modify an existing HLD. STOP.Before completing:
Ensure CLAUDE.md is configured. Invoke the /update-lid behavior (equivalent to running the update-lid skill), passing the mode that was determined from the invocation-time scope question. update-lid honors caller-provided mode and does not re-prompt. Result: LID directives block present, the ## LID block's - Mode: bullet set to the determined mode, arrow-navigation rows included (since the overlay is now installed), and a ## LID Tooling section scaffolded if a coherence script is to be declared. update-lid runs exactly once per /map-codebase invocation — at terminal verification, not during artifact generation.
Issue the flesh-out prompt. Direct the user to move into the linked-intent-dev workflow segment-by-segment to populate the skeleton LLDs and EARS specs. Without this prompt the user may leave reconstruction incomplete — and partial arrows propagate incoherence into future sessions. The flesh-out prompt is the terminal step; do not exit without issuing it.
What SKILL.md sets; muted values are Claude Code's defaults
2 skills in this plugin
npx claudepluginhub jszmajda/lid --plugin arrow-maintenanceOther plugins' skills for the same job