From adam
One-time scaffolding of a spec-driven Claude Code workflow in this project. Use when the user runs /adam:setup, /setup, or asks to "set up adam", "scaffold spec/ folder", "init spec-driven docs", "convert CLAUDE.md into a spec index", or "personalize claude code for this repo". Pipeline is strictly ordered: gitnexus analyze → spec scaffolding → per-class AskUserQuestion menus (hooks, subagents, skills) → create only what the user picks → CLAUDE.md → spec-lint verify → final brief.
How this skill is triggered — by the user, by Claude, or both
Slash command
/adam:setupThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Strict pipeline. **Do not reorder, do not skip phases, do not write `.claude/` artifacts without going through the AskUserQuestion menus.** Each phase has an output the next phase consumes.
Strict pipeline. Do not reorder, do not skip phases, do not write .claude/ artifacts without going through the AskUserQuestion menus. Each phase has an output the next phase consumes.
P0 gitnexus analyze ── unconditional first action; script is idempotent
P1 spec/rules/ ── deterministic copy from the plugin
P2 spec scaffolding ── overview + project/ + concepts/ + INDEX.md (NO CLAUDE.md yet)
P2b pipelines viewer ── install spec/pipelines.html + empty spec/pipelines/
P3 three menus ── hooks, subagents, skills (per-class AskUserQuestion)
P4 create accepted ── only the items the user marked
P5 CLAUDE.md ── written last, with the .claude/ artifacts in scope
P6 spec-lint verify ── MCP call, surface + try to fix
P7 final brief ── enumerate the features now active
This is the very first thing you do in any /setup invocation. Before parsing $ARGUMENTS, before checking whether spec/ is populated, before deciding --force vs --merge, before any reasoning about what the user wants — call the script. The script is idempotent: if the project is already indexed it returns "indexed":"already" in milliseconds, so there is no cost to running it every time. There is no condition under which you skip this call.
bash ${CLAUDE_PLUGIN_ROOT}/scripts/tools/setup-graph.sh "$PWD"
The script:
gitnexus is on PATH. If missing, exits non-zero with a clear npm install -g gitnexus hint — relay that to the user verbatim and stop the entire pipeline. Do not proceed to Arguments parsing or P1.gitnexus analyze (or --skip-git for non-git folders) if .gitnexus/ is absent. If present, reports "indexed":"already" and moves on.<!-- gitnexus:start -->...<!-- gitnexus:end --> block that gitnexus analyze auto-writes into CLAUDE.md on first run — its prescriptive rules measurably bias the model toward extra exploration turns.gitnexus into .mcp.json under mcpServers (creates the file or splices into an existing one — never overwrites unrelated entries).The script emits a single JSON object on stdout, e.g. {"status":"ok","indexed":"true","stripped":"false","mcp":"created","stats":{"nodes":735,"edges":940,"clusters":18,"processes":16},...}. Hold the stats — you'll surface them in the final brief.
If status != "ok", surface the script's stderr and stop — every later phase depends on a working graph.
Only after the script returns ok do you move on to parse $ARGUMENTS and check the populated-spec bail-out below.
After P0 completes, parse $ARGUMENTS:
--force token → set force = true. Allows the run to proceed even if spec/ already has content; agent writes from scratch and ignores whatever was there.--merge token → set merge = true. Also lifts the populated-spec bail-out. If merge is true, immediately Read ${CLAUDE_PLUGIN_ROOT}/skills/setup/_merge.md for the merge-specific behavior — that file extends P2, P3, P5, and P7. Without --merge, do NOT load it.--force and --merge) → trim, treat the remainder as a focus instruction. The user is telling you which subsystems, modules, or concepts to emphasize when picking what to write in spec/project/* and spec/concepts/*. Common shapes: "focus on the auth submodule and the websocket dispatcher", "focus: payments + the migration runner", "prioritize the rendering pipeline". Hold the raw text — it is passed verbatim into the P2 agent prompt.If no focus text is present, the focus instruction is empty and P2 runs in unbiased detection mode. --merge and a focus instruction compose freely (focus narrows what to emphasize while mining).
spec/, ORspec/ but it's empty / placeholder, OR--force (wipe) or --merge (mine existing)If spec/ already contains content and neither --force nor --merge was passed, stop and tell the user to run /adam:spec-update instead (drift fix), /adam:setup --merge (migrate existing specs into adam's layout), or /adam:setup --force (wipe and rebuild). P0 has already run by this point — that's fine; setup-graph.sh is idempotent and a current .gitnexus/ index is useful for whatever the user runs next.
Copy the plugin's templated workflow rules into the project. Do not interpret these steps yourself; call the script.
bash ${CLAUDE_PLUGIN_ROOT}/scripts/template/write-spec-rules.sh "$PWD"
The script copies templates/rules/*.md into <project>/spec/rules/ (currently refactor.md, additive.md, orient.md). It emits {"status":"ok","dest":"...","files":3}.
These rules encode adam's workflow contract — they are not project-specific and must NOT be edited per project. Project-specific patterns go under spec/project/ and spec/concepts/ instead.
Delegate to the adam sub-agent in scaffold-only mode:
Run scaffold-only first-time setup in the current working directory.
spec/rules/has already been populated by the parent skill — do NOT touch it. Detect the stack (manifest files, top-level dirs, infrastructure files), then write:
spec/overview.md(high-level "what is this project")spec/project/<area>.mdfiles for the conventions you can describe substantively (frontend, backend, stack, infra…)spec/concepts/<subsystem>.mddeep walkthroughs for the non-trivial subsystems worth their own page (each MUST include an anchors block)spec/INDEX.mdwith a token column populated via thetoken-countMCPDo NOT write
CLAUDE.mdin this phase. It is generated in P5 after the user has chosen which.claude/artifacts to add. Do NOT write to.claude/either — that's P3+P4.Return:
- Standard report (Created/Updated/Lint/Notes)
- Detection signals — list the stack tags you observed (e.g.
nextjs,python+ruff,postgres+schema-sql,tailwindv4,docker-compose,tests-pytest). The parent skill uses these to build the P3 hook/subagent/skill menu candidates.- Candidate workflows — identify 0–3 user-facing or operator-facing workflows worth a pipeline-spec walkthrough. Only surface flows you can substantiate from real code (an auth route, a checkout endpoint, a deploy script, a CRON job, a webhook handler, a queue consumer, a long-running pipeline). For each, return a small JSON-shaped record:
{slug: kebab-case, title: 1-line, description: 1-line, path_hints: [2-4 file paths most relevant to the flow]}. Do not pad. If nothing obvious presents (read-only library, infrastructure shim, plugin), return an empty list. The parent skill turns this into the P3 pipelines menu — every candidate the user accepts becomes aspec/pipelines/<slug>.htmlwritten in P4.Focus instruction from the user (may be empty):
<focus instruction>. If non-empty, bias your coverage decisions toward the named subsystems/concepts — write deeperspec/concepts/<subsystem>.mdpages for them, give them aspec/project/*.mdentry if the conventions are non-trivial, and put them higher in the reading order inINDEX.md. Do not drop baseline coverage (overview.mdandspec/project/stack.mdare always required). If focus is empty, run unbiased detection.
If merge = true, append the merge-mode block from _merge.md (section: "P2 — spec scaffolding under --merge") to the prompt before dispatching. Otherwise dispatch as-is.
Surface the agent's report. If the agent reports failure, do not proceed to P2b.
Pipelines are a second kind of spec — static .html walkthroughs of how a workflow moves through the project (one HTML file per workflow, plus a global viewer at spec/pipelines.html that lists them in a sidebar and opens each in an iframe). They are purely for user comprehension and are exempt from spec-audit, the spec-lint MCP, and check-anchors.sh (all of which scan *.md only).
Phase 2b installs the infrastructure — viewer + empty folder + initial empty manifest. It does not auto-generate any individual pipeline-spec; those are written on demand by /adam:spec-create <topic> --pipeline once the user knows which workflows are worth a walkthrough. Do not interpret these steps yourself; call the script.
bash ${CLAUDE_PLUGIN_ROOT}/scripts/template/write-pipelines-viewer.sh "$PWD"
The script:
templates/pipelines/viewer.html into <project>/spec/pipelines.html (overwrites with the latest template — keep customizations under the plugin, not under the project).<project>/spec/pipelines/ directory.scripts/tools/update-pipelines-manifest.sh to seed the viewer's inlined manifest block (<!-- BEGIN MANIFEST --> … <!-- END MANIFEST -->) — so if the project already had pipelines, they're picked up; otherwise the block is just empty.Emits {"status":"ok","viewer":"<path>","dir":"<path>","pipelines":N}. Hold the count — surface it in the final brief.
This phase is mandatory. Never write .claude/ files or pipeline-specs without going through it. Even if you have one obvious recommendation, ask before creating.
Four candidate classes, four potential menus: hooks, subagents, skills (all drawn from the agent's Detection signals), and pipelines (drawn from the agent's Candidate workflows). Build candidates from the detection signals the agent returned in P2. The reference matrix for the first three:
If merge = true, apply the merge-mode filter described in _merge.md (section: "P3 — menu filter under --merge") before presenting any menu — it drops candidates whose target files already exist.
| Detection signal | Hooks | Subagents | Skills |
|---|---|---|---|
| Python + ruff | ruff-format PostToolUse on *.py writes | py-test-runner | — |
| Python + FastAPI | — | fastapi-route-reviewer | — |
| Python + pytest | — | py-test-runner | — |
| Next.js / TS | prettier-write PostToolUse on *.ts/tsx/css | next-route-reviewer | — |
| Tailwind v4 | — | tailwind-design-checker | — |
Postgres + db/schema.sql | schema-change reminder PostToolUse on db/schema.sql writes | — | sql-migration-helper |
| Rust crate | cargo-check PreToolUse | cargo-test-runner | — |
| Docker compose | — | — | docker-compose-helper |
| Tests dir present (any framework) | — | test-runner matched to framework | — |
Add stack-specific candidates beyond this matrix when the project clearly warrants them. Never invent generic options — every candidate has to map to a concrete file the agent will write in P4.
For each of the four classes (hooks, then subagents, then skills, then pipelines), do the following:
AskUserQuestion with an empty list.AskUserQuestion with multiSelect: true. Title and header reflect the class.Hooks menu (only if at least one hook candidate exists):
AskUserQuestion({
questions: [{
question: "Which hooks should adam wire into .claude/?",
header: "Hooks",
multiSelect: true,
options: [
{ label: "ruff PostToolUse on *.py writes", description: "Writes .claude/hooks/ruff-format.sh and adds a PostToolUse Edit|Write entry to .claude/settings.json. Auto-formats Python after every Write/Edit." },
{ label: "schema-change reminder", description: "PostToolUse on db/schema.sql writes — prints a TODO line reminding the assistant to add a migration. Writes .claude/hooks/schema-warn.sh." }
]
}]
})
Subagents menu (only if at least one subagent candidate exists):
AskUserQuestion({
questions: [{
question: "Which sub-agents should adam add to .claude/agents/?",
header: "Subagents",
multiSelect: true,
options: [
{ label: "py-test-runner", description: "Runs pytest, parses failures, writes a triage summary. .claude/agents/py-test-runner.md" },
{ label: "fastapi-route-reviewer", description: "Reviews app/api/routes/*.py for auth, validation, error shape. .claude/agents/fastapi-route-reviewer.md" }
]
}]
})
Skills menu (only if at least one skill candidate exists):
AskUserQuestion({
questions: [{
question: "Which skills should adam add to .claude/skills/?",
header: "Skills",
multiSelect: true,
options: [
{ label: "sql-migration-helper", description: "Slash command to draft a new migration file matching the project's existing migration style. .claude/skills/sql-migration-helper/SKILL.md" }
]
}]
})
Pipelines menu (only if the agent returned at least one Candidate workflow):
AskUserQuestion({
questions: [{
question: "Which workflows should adam draft as pipeline-specs (HTML walkthroughs with Mermaid flow charts)?",
header: "Pipelines",
multiSelect: true,
options: [
{ label: "user-signup", description: "User signup flow — from form submit through email confirmation. Writes spec/pipelines/user-signup.html." },
{ label: "deploy-pipeline", description: "CI deploy from main → production. Writes spec/pipelines/deploy-pipeline.html." }
]
}]
})
Each pipeline option's label is the candidate slug; the description is the candidate's description plus the target file path so the user sees what gets written.
Hold the user's selections — they drive P4. If the user selects nothing in a class, that class contributes nothing in P4.
description must say what file is created and what it does, in one line.For each accepted item from the P3 menus, dispatch the adam sub-agent in claude-add mode (or write directly using the same rules from agents/adam.md — both are valid):
.claude/hooks/<kebab-name>.sh (with #!/usr/bin/env bash + set -euo pipefail, then chmod +x), then merge a { "type": "command", "command": "$CLAUDE_PROJECT_DIR/.claude/hooks/<kebab-name>.sh" } entry into .claude/settings.json under the right matcher (read existing, splice in, write back). Never inline command bodies into settings.json. Never overwrite — preserve unrelated hooks the user already has..claude/agents/<kebab-name>.md with proper frontmatter (name, description enumerating trigger phrases, model, optional tools)..claude/skills/<kebab-name>/SKILL.md with frontmatter and substantive instructions.Read ${CLAUDE_PLUGIN_ROOT}/skills/setup/_pipelines.md and follow it for the agent dispatch shape, placeholder list, and batched manifest refresh. If no pipelines were accepted, skip this bullet entirely and do NOT load the file.Each file must be substantive — no placeholders, no stubs. If you cannot write something useful for an accepted item, drop it and note that in the final brief rather than ship a stub.
CLAUDE.md is generated last so it can reference the actual .claude/ artifacts that now exist. Delegate to the adam agent in finalize mode:
Generate
CLAUDE.mdfor the project. The spec tree is already in place, and.claude/now contains the artifacts the user accepted in P4. Use the structure documented inagents/adam.md(sections 1-8). The Spec Index table mirrorsspec/INDEX.mdwith a Tokens column populated via thetoken-countMCP. If.claude/agents/,.claude/skills/, or.claude/hooks/contain entries, add a short "Project automations" subsection listing them. Do NOT touchspec/— it's frozen for this run.
If merge = true, append the merge-mode block from _merge.md (section: "P5 — CLAUDE.md preservation under --merge") to the prompt before dispatching.
Run the spec-lint MCP against the project root:
spec-lint.lint({ root: "$PWD" })
Surface the result. If ok: false:
adam agent with the error list, or fix in-place if the issue is mechanical, e.g. a missing frontmatter field).Re-run lint after any fix until errors: [].
Before composing the brief, capture session token usage so the user can see how much running /adam:setup cost. Do not interpret these steps yourself; call the script.
bash ${CLAUDE_PLUGIN_ROOT}/scripts/tools/session-token-usage.sh "$PWD"
The script aggregates message.usage across every assistant message in the current Claude Code session JSONL (located via the project-slug convention ~/.claude/projects/<slug>/<session-id>.jsonl) and emits a single JSON object: {status, session, total, input, output, cache_creation, cache_read, turns}. If status != "ok" (jq missing, session not found, etc.), surface a single not available line under the Tokens block instead of failing the brief.
Note: the count is session-wide, not strictly setup-only. Since /adam:setup is a one-shot bootstrap usually run as the first command in a fresh session, the number is dominated by setup work in practice — but if the user invoked other commands earlier, those tokens are included too. Caveat this in the brief by labelling the line "this session".
Then compose the brief as a single message to the user, in this format:
adam setup complete.
Knowledge graph
GitNexus: <indexed | newly indexed | already current> (<nodes> nodes / <edges> edges / <clusters> clusters)
Specs
spec/overview.md ── <one-line>
spec/project/<files> ── <count> file(s): <names>
spec/concepts/<files> ── <count> file(s): <names>
spec/rules/ ── 3 workflow recipes
spec/INDEX.md ── token-counted index
spec/pipelines.html ── viewer for HTML workflow walkthroughs (audit-exempt)
spec/pipelines/ ── <count> pipeline(s) so far
written this run: <slugs you wrote in P4, or "none">
(If `merge = true`, insert the "Existing automations" block here per `_merge.md` — section "P7 — final brief addition under `--merge`". Omit it entirely in non-merge runs.)
Project automations (only what you picked this run)
Hooks: <names or "none">
Subagents: <names or "none">
Skills: <names or "none">
CLAUDE.md
written, <token count> tokens
Lint
<"clean" or summary of warnings left>
Tokens consumed (this session)
<total> ── input <N> · output <N> · cache creation <N> · cache read <N> across <turns> turns
("not available" if scripts/tools/session-token-usage.sh returned status != ok)
Try next:
/adam:spec-update ── refresh specs after substantive code changes
/adam:spec-create <topic> ── add a new spec page
/adam:spec-create <topic> --pipeline ── add an HTML workflow walkthrough
/adam:claude-add <kind> "<description>" ── add another hook/agent/skill later
write-pipelines-viewer.sh fails, surface the error but continue to P3 (the viewer is non-load-bearing). Skipping P3 is a bug — even one accepted item must go through AskUserQuestion..claude/ files outside P4. No defaults, no "obvious" auto-additions..claude/ actually contains by the time you write it..claude/settings.json — read, splice, write back.npx claudepluginhub lkzppm/adam --plugin adamProvides behavioral guidelines to reduce common LLM coding mistakes, focusing on simplicity, surgical changes, assumption surfacing, and verifiable success criteria.
Searches, retrieves, and installs Agent Skills from prompts.chat registry using MCP tools like search_skills and get_skill. Activates for finding skills, browsing catalogs, or extending Claude.
Creates, edits, and optimizes skills for Claude Code, including drafting, evaluating with test prompts, iterating on performance, and improving skill descriptions for better triggering accuracy.