/kmgraph:kmg-create-adrfrom kmgraph
Creates a new Architecture Decision Record (ADR) using the knowledge graph from the current directory. Auto-fills git metadata, increments ADR number, and updates the decisions index.
Claude never picks this command on its own
Its frontmatter has no description. Without a description, Claude Code leaves it out of the list Claude chooses from. Typing /kmgraph:kmg-create-adr still runs it.
Purpose: Create a new Architecture Decision Record (ADR) using the knowledge graph resolved from the current directory. Auto-fills git metadata, auto-increments the ADR number, prompts for decision content, and updates the decisions index.
Version: 1.0 (Created: 2026-02-20)
Note: This command creates Architecture Decision Records. For Lessons Learned, use /kmgraph:kmg-capture-lesson. For general documentation, use /kmgraph:kmg-create-doc.
/kmgraph:kmg-create-adr
/kmgraph:kmg-create-adr <title>
Examples:
/kmgraph:kmg-create-adr → Interactive wizard (all prompts)/kmgraph:kmg-create-adr Use PostgreSQL for primary database → Pre-fills title from argumentBefore any other steps, detect the user's intent for WHERE this ADR should be captured,
directly from their message or an explicit flag — no separate routing skill needed
(gov-capture-routing, formerly invoked here, has been retired — see issue-18 — this
detection is now native to how kg_capture/create-adr-agent already resolve scope):
--user
flag → --user (create-adr-agent passes scope: "user" to kg_capture)--project flag → --project--named=<kg> → --named=<kg> (resolves to
targetKg at the kg_capture call)--active → --active (default, cwd-derived resolution)$restore_kg to resolve — knowledge graphs resolve from context per call, not a
mutable "active" pointer, so there is nothing to restore after (ADR-067 Phase 6).Set $requested_tier = standard-tier. Invoke kmg-ai-model-tier-resolver module (commands/kmg-init-shared/kmg-ai-model-tier-resolver.md) with $requested_tier and {KG_PATH}. On success: pass --model [$resolved_model] to the subagent.
Resolve {active_kg_path} according to the flag Level Routing above resolved (issue-41:
this step previously read .active directly and ignored routing entirely — a
pre-ADR-067 pattern that also predates Level Routing's own resolution; both are fixed
together here since Step 0's resolution feeds every direct file operation later in this
command, not just the create-adr-agent dispatch):
--active (default): call kg_resolve (no scope — cwd-derived). Take the returned
path as {active_kg_path}.--project: same as --active — call kg_resolve (cwd-derived). --project and
--active resolve to the same project graph from this command's cwd-derived context;
the distinction matters at the create-adr-agent dispatch (Phase -1), which targets
kg_capture differently per flag even when the resolved path is identical.--user: call kg_resolve with scope: "user". Take the returned path as
{active_kg_path}.--named=<kg>: look up graphs["<kg>"].path directly from
~/.kmgraph/kg-config.json (a keyed lookup by the name the user gave — not the
retired mutable-pointer pattern). Take that as {active_kg_path}.If resolution errors (no graph registered for this directory, or the named graph doesn't exist), stop and report the error rather than falling through to an undefined path.
Decisions directory: {active_kg_path}/decisions/
If the decisions directory does not exist, create it:
mkdir -p {active_kg_path}/decisions/
There is no separate guard needed here (issue-41: this section previously compared a
stale .active-derived pointer against the project's own KG and prompted on mismatch —
a pre-ADR-067 pattern). In the default (--active) case, Step 0 above already resolves
{active_kg_path} via cwd-derived resolution, which by construction finds this
project's own KG — there is nothing left to disagree with. When --user/--named=<kg>
is explicitly passed, the user has already stated their intended target; no guard
applies.
Runs before Step 1 — context preservation before the ADR dialog.
Ask:
"Before creating the ADR — want to run a session summary first? This saves the current session state as a persistent summary and makes the 'why' behind this decision available for the ADR's Context section.
[y] Run session summary [u] Update existing [n] Skip [?] What does this do?"
If ?: explain that this runs /kmgraph:kmg-session-summary in snapshot mode — a lightweight variant that records what was worked on, open plan items, and file changes without requiring a full wrap-up. The result is written to disk and used to enrich the ADR's Context section.
If y:
"Include git history in the session summary? (adds ~5-15 sec)
[y] Yes — include commits [n] No — conversation + files only"
Invoke session-summary-agent --snapshot (with --git if yes). When the agent returns, say:
"Session summary saved — I'll use that to fill in the ADR's context and background."
Then continue to Step 1.
If u:
"Include git history in the updated session summary? (adds ~5-15 sec)
[y] Yes — include commits [n] No — conversation + files only"
Invoke session-summary-agent --snapshot --update (with --git if yes). This refreshes the most recent session summary for the current session rather than creating a new one. When the agent returns, say:
"Session summary updated — I'll use that to fill in the ADR's context and background."
Then continue to Step 1.
If n: proceed to Step 1.
Scan for existing ADRs:
ls {active_kg_path}/decisions/ | grep -E '^ADR-[0-9]+'
Parse existing numbers:
ADR-NNN-*.md filenameFormat: Zero-padded to 3 digits: 001, 002, 042, 100
Edge cases:
Do not announce this number to the user — create-adr-agent (Phase 1)
independently re-derives it with a cross-branch collision check that can
bump it, and is the number that actually gets used. Announcing here risks
showing the user two different ADR numbers in one run.
Collect the following automatically:
git config user.name # author
git config user.email # email
git rev-parse --abbrev-ref HEAD # branch
git rev-parse HEAD # commit (full SHA)
Parse PR and issue numbers from branch name:
feature/123-add-caching → pr candidate: 123issue/456-fix-auth → issue: 456nullgh pr list --head $(git rev-parse --abbrev-ref HEAD) --json number --jq '.[0].number' (if gh CLI available)If git is not available: skip the git metadata fields here and continue to
Step 3. Do not assemble frontmatter or a fallback field set in this command —
create-adr-agent (Phase 2) re-derives git metadata itself and handles the
git-unavailable case on its own, and it owns the only frontmatter schema.
Dispatch create-adr-agent, passing:
--user, --project, --named=<kg>, or --active)--model [$resolved_model] (from Tier resolution above)agents/create-adr-agent.md:150)Do not pass a context payload (no context_provided). The agent runs its own
full interactive wizard (Phase 3, 9 questions including "Implementation
Commit") directly with the user, resolves its own ADR numbering (Phase 1,
with cross-branch collision check) and git metadata (Phase 2), writes the
file via kg_capture (Phase 5), updates the decisions index (Phase 6), and
commits (Phase 7). All user interaction — wizard questions and the
pre-write confirmation summary (Phase 4) — happens directly through the
agent.
This command's role ends at dispatch. Do not re-implement the wizard, filename generation, file write, index update, or commit here.
User types: /kmgraph:kmg-create-adr
Assistant responds:
Creating new Architecture Decision Record...
Collecting git metadata...
Author: Jane Smith <[email protected]>
Branch: feature/add-caching
Commit: a1b2c3d
Dispatching to create-adr-agent...
Then create-adr-agent takes over: it runs its own wizard directly with the
user ("What is the title of this decision?" and on, starting with its own
ADR-number announcement per its cross-branch collision check), shows a
summary for confirmation, writes the file, updates the index, and commits.
kg_resolve or named lookup, per Step 0)create-adr-agent independently re-verifies this with its own
cross-branch collision check before writing)create-adr-agent dispatched with the resolved level-routing flag and
$resolved_model — no context payload/kmgraph:kmg-capture-lesson — Document lessons learned (ADR link offered after capture)/kmgraph:kmg-create-doc — Scaffold general documentation files/kmgraph:kmg-recall — Search existing ADRs and lessons/kmgraph:kmg-link-issue — Link an existing ADR to a GitHub issueCreated: 2026-02-20
Version: 1.0
Usage: Type /kmgraph:kmg-create-adr to create a new Architecture Decision Record
Files this command reads when invoked
What the command file sets; muted values are Claude Code's defaults
7-day visitors to each command page
npx claudepluginhub technomensch/knowledge-graph --plugin kmgraph31 commands in this plugin
/kmg-add-category/kmgraph:kmg-add-category — Add Category to Knowledge GraphAdd a new category to the active knowledge graph with optional custom prefix and git strategy./kmg-backfillBackfill Knowledge Graph from Existing Content<!-- Created: 2026-09-04 (ADR-071) -->/kmg-capture-lessonDocument Lessons Learned**Version:** 2.0 (Updated: 2026-03-27)