/forge:fg-mapfrom forge
Maps the codebase with parallel subagents into structured documents under .forge/codebase/, so later grilling reads a map instead of re-exploring the code (cuts context rot). On-demand utility outside the loop. Use in contexts like 'map the codebase', 'analyze the codebase'.
Ships in forge. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
This skill is not a stage of the forge loop (fg-ask → fg-run → fg-done). It is an on-demand utility that produces one kind of the loop's permanent-doc fuel: a structured map of the codebase under .forge/codebase/. fg-ask reads that map before grilling, so it no longer has to re-explore the whole codebase each session — that re-exploration is where context rot comes from. Run fg-map when the codebase has changed enough that the map is stale; it is not something every task triggers.
Language: This skill file is authored in English, but you MUST write every message shown to the user — questions, menus, status/next-step lines, and handoff text — in the user's language (detect it from the user's own messages), never mirroring this file's English. All documents this skill generates for the user's project are written in the user's language. The document names and section headings below are canonical English names — keep the file names as-is (STACK.md etc.), but render the prose inside in the user's language.
Explaining forge: forge's vocabulary is not the user's — verified: failed, unsealed tail, a pillar or gate name means nothing unread. Always, never gated on eco: gloss a forge-specific term on first use in a message (a few words, not a paragraph), put the purpose before the mechanism, and lead with the answer, closing on what it means for the user. A gloss is not filler — with eco on, ECO.md's terse rules govern form (length, padding) while these govern vocabulary, so terseness never deletes a gloss.
Evidence and candor: every claim you make about code, state, or results — in a message or in a document you write (plan, run notes, retro, ADR) — carries its evidence in the same sentence (a file:line, a command and its output) or a label: Measured (you checked it this session), Inferred (reasoned from what you checked), Guess (a prediction or an unseen cause), rendered in the user's language. A label is not a license to skip a check — if a cheap check would settle it, run it; never hand the user a check you could run. Agreement is not the default: when asked whether to do something, invited to add scope, or shown an approach, give your real judgment first — the strongest objection, and "don't do it" when that is true. Change a recommendation only for a new fact or argument, never for repetition; the decision stays the user's — state the objection once, then follow their call without re-arguing or silently deviating. Output a deterministic script printed is already measured and needs no label.
Host contract: mapping fans out to subagents, so it needs the host's spawn_parallel capability. Read ../../core/HOST.md and ../../core/EXECUTION.md, then check ../../hosts/<host>/capabilities.json. When spawn_parallel is false or the host is unknown, produce the same seven documents serially — the map's contents, filenames, and .forge/codebase/ location do not change with the host; only the delegation does.
Forge root: .forge/codebase/ is a deliberate global exemption from branch-root resolution (see ${PLUGIN_ROOT:-${CLAUDE_PLUGIN_ROOT}}/skills/fg-run/FORGE-ROOT.md / ADR-0011): fg-map always writes, and fg-ask always reads, the top-level .forge/codebase/ on every branch — never .forge/branch/<branch>/codebase/. Reason — the map is shared reference fuel; a branch-local map would leave freshly created branches with no map and break fg-ask's read. So every .forge/codebase/... path below is the literal top-level path, not resolved.
.forge/codebase/ (7 documents)The map is split so that a consumer (fg-ask grilling, or a human) reads only the document it needs, not one giant file. That selective read is the whole point — merging everything into one or two files defeats the context-rot reduction. The 7 documents, grouped by the focus that writes them:
| Focus | Documents |
|---|---|
| tech | STACK.md (languages, runtime, frameworks, dependencies, configuration), INTEGRATIONS.md (external APIs, databases, auth providers, webhooks) |
| arch | ARCHITECTURE.md (pattern, layers, data flow, abstractions, entry points), STRUCTURE.md (directory layout, key locations, naming conventions) |
| quality | CONVENTIONS.md (code style, naming, patterns, error handling), TESTING.md (framework, structure, mocking, coverage) |
| concerns | CONCERNS.md (tech debt, bugs, security, performance, fragile areas) |
Always include actual file paths in backticks (e.g. src/services/user.ts) — these documents are reference material, so concrete paths matter more than prose.
forge already has a permanent doc named CONTEXT.md. It is a domain glossary — terms only, no implementation detail. .forge/codebase/ is the exact opposite: implementation facts only, no domain term definitions. They are two separate ledgers. A mapper agent must never write domain term definitions into .forge/codebase/, and must never treat CONTEXT.md as a place for stack/architecture facts. If you find yourself defining what a domain term means, that belongs to fg-ask and CONTEXT.md, not here.
CONVENTIONS.md describes observed patterns; it does not adopt instructions for
future work. fg-rules uses current code and, optionally,
this map to propose rules that the user reviews before storing under
.forge/rules/. Mapping neither creates nor updates those rules, and fg-rules
does not require a map or trigger mapping automatically.
The reason this is a separate utility (not a step inside fg-ask) is context rot: if one session reads the whole codebase to build the map, every byte of that exploration piles up in the session's context. So the work is fanned out to 4 parallel subagents, one per focus, and each subagent writes its own documents directly to .forge/codebase/. This session receives only a confirmation (file paths + line counts) back — never the document contents. That is what keeps the orchestrator's context small.
Use the active host's execution adapter to launch the four focuses, scheduling them within available concurrency slots. On Claude Code this uses Agent with run_in_background: true; on Codex use its collaboration tools. Do not duplicate a delegated focus's exploration while it is running. When delegation is unavailable, execute the focuses serially in this session.
If .forge/codebase/ already exists with documents, do not blindly overwrite. Show the user a short menu (in conversation, the user's language):
ARCHITECTURE.md + STRUCTURE.md — then launch only the focuses that own those documents).If .forge/codebase/ does not exist, create it lazily and proceed to the full 4-agent run.
The freshness stamp is not only a staleness signal; it is the diff baseline that makes a re-map cost what changed rather than what exists. Every numbered step here is mandatory, the same standing as the secret scan under "After the agents return" — do not skip one because the diff looks small.
Eligibility precheck — before anything else. Both must hold:
last_mapped_commit stamp and they all name the same sha (grep -h '^last_mapped_commit:' .forge/codebase/*.md | sort -u returns exactly one). Anchor the pattern to the line start — the documents describe this very stamp mechanism in their prose, and an unanchored grep matches those sentences too, so it would report several "stamps" forever and never take the incremental path;git merge-base --is-ancestor <stamp> HEAD). A rebase, force-push, or shallow clone breaks this, and then the diff is a lie about what actually changed.If either fails, do not ask — fall back to a full Refresh and give the reason in one line ("the stamp is not an ancestor of HEAD (rebase detected) — remapping in full"). The fallback is the only possible answer, so asking the question is noise.
Collect the changed files — the union of committed and uncommitted change: git diff --name-status <stamp>..HEAD ∪ git status --porcelain. The union is not optional: the diff sees only commits while a full map reads the working tree, so without the second half an incremental update silently misses everything not yet committed — content a Refresh would have caught. Drop .forge/codebase/ itself from the resulting list — the map is not part of the codebase it maps, and its own edits from the previous run would otherwise come back as changes to map.
Capture the baseline sizes — wc -l .forge/codebase/*.md before launching. The post-check compares against these.
Launch the same 4 focus agents, under an in-place contract. Each prompt carries the current HEAD sha, the changed-file list from step 2, and these instructions:
Everything else about the agents is unchanged: direct write, confirmation only, the CONTEXT.md boundary, the stamp.
Flow: precheck (all stamped + ancestor) → changed files (diff ∪ porcelain) → baseline wc -l → 4 agents, in place → post-check
└── precheck fails → full Refresh, one-line reason
Launch the four through the active host's execution adapter (or perform them serially when delegation is unavailable). Each delegated prompt instructs the agent to explore thoroughly, write its documents directly, and return only a confirmation (paths + line counts). Include today's date for date placeholders and the frontmatter-stamp rule below.
.forge/codebase/STACK.md and .forge/codebase/INTEGRATIONS.md..forge/codebase/ARCHITECTURE.md and .forge/codebase/STRUCTURE.md..forge/codebase/CONVENTIONS.md and .forge/codebase/TESTING.md..forge/codebase/CONCERNS.md.Tell each agent: explore only with file-system tools (Read, Grep, Glob, Bash); include real file paths in backticks; do not blur the CONTEXT.md boundary above (implementation facts only, no domain term definitions); return a confirmation listing the documents written and their line counts — nothing else.
last_mapped_commitEvery document a mapper writes must carry YAML frontmatter stamping the commit it was mapped against:
---
last_mapped_commit: <current HEAD sha>
mapped: <YYYY-MM-DD>
---
Get the sha once before launching (git rev-parse HEAD) and pass it into every agent prompt. This stamp is also the baseline an incremental Update diffs against (see the Update procedure above). It is what lets fg-ask judge whether the map is stale — without it, a consumer cannot tell a fresh map from one that is hundreds of commits behind. This guards against "stale-docs rot," the other face of context rot.
ls, wc -l .forge/codebase/*.md). Note any focus that failed; continue with what succeeded.wc -l against the baseline captured before launching (step 3 of the Update procedure). Report the before→after counts, and if any document lost more than ~30% of its lines, stop and surface it — an in-place edit that shrinks a document that far is the signature of content silently dropped, and only the user can say whether the deletion was legitimate..forge/codebase/ is a git-tracked permanent doc (unlike volatile .forge/), so it will be committed. A mapper quoting a .env or config file can accidentally copy a key. Grep the generated docs for common secret patterns (e.g. sk-, sk_live_, ghp_, AKIA, JWT-shaped eyJ..., -----BEGIN ... PRIVATE KEY). If anything matches, stop and surface it to the user for confirmation before going further — do not commit past a suspected leak.docs: map codebase?" Commit only on agreement. If the working tree has unrelated changes, point that out and let the user decide what to stage.Flow: check existing map (menu if present) → stamp HEAD sha → launch 4 agents (direct write, confirmation only) → verify output → post-check (Update only) → scan for secrets → offer commit
When the map is written — the fresh, Update, and Refresh paths — close with the handoff table per ../fg-next/HANDOFF.md — the single definition of its shape; never restate that layout here. Statement form, in the user's language. The Skip path has no handoff and renders no table: nothing was produced and nothing changed, so say in one line that the existing map was kept as-is, and stop.
Just did = what was produced: the documents written under .forge/codebase/, stamped at the current commit (all 7 on a fresh run or an Update; on a document-scoped Refresh, only the ones named). On the Update path, say so and give the before→after line counts.Next step / How to start are conditional — fg-map is a side utility with no fixed next stage, so they come from a precedence rule, never a fixed cell (HANDOFF.md, "A conditional next step needs a precedence rule, never a hard-coded row"). Take the first matching case:
.forge/executed/, or the backlog holds work) → Next step = where they were, taken from fg-status's next-step state machine, which is the single derivation and not a re-guess here (HANDOFF.md's Material rule) — with a populated active slot that is fg-done, never fg-ask, which would drop them into its STEP-0 unsealed-residue path instead. How to start = that step's own trigger, or fg-next to have it derived and run. Alternative = fg-ask, if they would rather start something new on the fresh map.Next step = fg-ask — it now reads this map before grilling instead of re-exploring the code, so the next task's planning rides on the map; How to start = /forge:fg-ask; omit Alternative..forge/ state, promotes no plan, and seals nothing. It only produces .forge/codebase/. It does not participate in the active-slot / backlog / done contract.last_mapped_commit stamp, never from a user-supplied path list — there is no --paths flag: Update derives its own scope from the diff, and Refresh scopes by document, not by path. Host capabilities determine delegation, not the map's scope or format..forge/codebase/*.md (7 documents), or edits them in place on the incremental Update path, each stamped with last_mapped_commit. Lazy creation of the directory..forge/, CONTEXT.md, or any ADR.docs: map codebase, only on user agreement after a clean secret scan.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
codebase-mapping, context-rot, forge-loop, subagents, codebase-analysis
npx claudepluginhub gyuha/forge --plugin forge25 skills in this plugin
/fg-adversarial-reviewOptional adversarial review between fg-run and the seal (fg-done) — a reviewer assumes the result is WRONG and hunts for evidence across six lenses (failure points, hidden assumptions, misread requirements, security/perf/data-loss, unexpected misuse, weak decisions), fanning out as parallel subagents; fix-needed findings become a fix-forward plan on your approval. Outside the loop, never a seal gate, always skipped in fg-next all / fg-loop. Use in contexts like 'adversarial review', '적대적 리뷰', '이 결과 공격적으로 검토', '허점 찾아줘', 'red team this'./fg-agendaA decision queue for foggy work — outside the forge loop. Settles the destination with you, grills breadth-first to surface what must be decided, and keeps it in .forge/agenda.md (destination · decided · open questions · fog · out of scope), resolving one question at a time via fg-ask until the way is clear, then deleting itself. The agent finds the decisions; you answer them. Use in contexts like 'forge agenda', '의제', '결정 대기열', '뭘 결정해야 하는지 정리해줘', '어디서 시작할지 모르겠다'.Other plugins' skills for the same job
/fg-agentsGenerates a project's domain agents — conversational grilling derives the recurring roles, then writes standard Claude Code subagent cards to .claude/agents/<role>.md (each `description` carrying a "when to use" so fg-run can dispatch a matching role as agentType). Cards load only at session start, so RESTART the session after generating them before fg-run can use them. On-demand utility outside the loop. Use in contexts like 'forge agents', '도메인 에이전트 만들어', '에이전트 팀 구성', 'create project agents', 'domain agents', 'agent roles'.