ahgraber/skills/sdd-derive

Claude Code and agent skill by ahgraber/skills

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Use when deriving SDD specs from existing code or retroactively documenting implemented behavior. Triggers: "derive specs", "generate specs from code", "document this code in SDD", "retrofit specs", "spec out what's already built".

Install

npx vskill@latest install ahgraber/skills/sdd-derive

SKILL.md

The same SKILL.md was published earlier as ahgraber/skills/sdd-derive.

SDD Derive

Orchestrate spec generation from existing code: a change directory (new or modified behavior) or baseline specs (retroactive documentation).

The orchestrator holds context across phases; subagents are dispatched for scoped work that benefits from context isolation.

SPECS_ROOT is resolved by the sdd router before this skill runs.
Replace .specs/ with the project's actual specs root.

Writing Style

Write the derived specs in the voice of a professional technical writer. Prefer ASD-STE100 Simplified Technical English: short sentences, one instruction per sentence, active voice, and one term per concept. Keep identifiers, commands, paths, and RFC 2119 keywords exact.

When to Use

  • Deriving specs from existing code ("derive SDD specs for the auth flow")
  • Documenting implemented behavior retroactively into baseline specs
  • Producing a change directory for behavior already implemented
  • User phrases: "derive specs", "generate specs from code", "retrofit specs", "document this code in SDD"

When Not to Use

  • Translating specs from another tool or format — use sdd-translate
  • No codebase and no existing behavior to anchor against — use sdd-propose
  • Exploring a problem before deciding what to spec — use sdd-explore

Invocation Notice

  • Tell the user when this skill is running: sdd-derive.

Skip the notice when the user asked for the skill by name or slash command; spelling and spacing need not match. A phrase from this skill's own trigger list is not a name — naming the work is not naming the skill.

Determine Output Type

Baseline specs (.specs/specs/) document implemented behavior. Write baseline specs only when existing code anchors them; otherwise generate a change directory.

dot
digraph output_type {
".specs/specs/ exists?" [shape=diamond];
"Codebase has relevant\nimplementation?\n(answered by Phase 2 discovery)" [shape=diamond];
"New or existing behavior?" [shape=diamond];
"Generate change directory\n(.specs/changes/<name>/)\nADDED-only delta specs" [shape=box];
"Generate change directory\n(.specs/changes/<name>/)" [shape=box];
"Generate baseline specs\n(.specs/specs/)" [shape=box];
".specs/specs/ exists?" -> "Codebase has relevant\nimplementation?\n(answered by Phase 2 discovery)" [label="no"];
"Codebase has relevant\nimplementation?\n(answered by Phase 2 discovery)" -> "Generate baseline specs\n(.specs/specs/)" [label="yes — retroactive doc"];
"Codebase has relevant\nimplementation?\n(answered by Phase 2 discovery)" -> "Generate change directory\n(.specs/changes/<name>/)\nADDED-only delta specs" [label="no — greenfield"];
".specs/specs/ exists?" -> "New or existing behavior?" [label="yes"];
"New or existing behavior?" -> "Generate change directory\n(.specs/changes/<name>/)" [label="new or modified"];
"New or existing behavior?" -> "Generate baseline specs\n(.specs/specs/)" [label="retroactive doc"];
}

Greenfield check: when .specs/specs/ does not exist, run discovery (Phase 2) before deciding. If discovery finds no relevant implementation, generate a change directory with ADDED-only delta specs — never assert behavior in .specs/specs/ that has not been built.

One run has one output type. A change directory holds delta specs, so its output type is delta; baseline specs have output type baseline. Pass that word to every lifter and to every validate.py and check_spec_format.py run as --type.

Workflow

Checklist
  • [ ] Phase 1: Understand User Intent
  • [ ] Phase 2: Discovery (explore + synthesize)
  • [ ] Phase 3: Pre-flight Consent
  • [ ] Phase 4: Per-Capability Derive (Observe + Lift)
  • [ ] Phase 5: Validate
  • [ ] Phase 6: Generate Output
Subagent Protocol

This protocol is purpose-built for spec derivation and takes precedence over any general subagent skill (e.g. subagent-patterns) during a derive run.

Persist before returning. Every subagent MUST write its output to disk unconditionally.

Resolve paths before dispatch. The orchestrator MUST expand $TMPDIR and other shell variables in the prompt; subagents do not consistently expand them, and literal $TMPDIR produces silent write failures.

Verify writes inline. Every subagent prompt MUST require ls -la <path> after writing and report byte count. The orchestrator confirms the file exists before treating dispatch as successful.

Dispatch by reference, not inline duplication. Role discipline lives in references/<role>.md. Resolve the skill's install path (e.g., ~/.claude/skills/sdd-derive/, .claude/skills/sdd-derive/, or a plugin directory) and substitute it into the template. Subagents inherit Read permissions from the parent.

markdown
Read `<resolved_skill_root>/references/<role>.md` and follow it as your job description.
Below is your specific scope.
Capability: `<name>` \
Files in scope: `<list>` \
External-surface candidates: `<list>` \
Output path: `<literal absolute path>` \
After writing, run `ls -la <path>` and report byte count.

A lifter prompt also carries the other inputs references/lifter.md § Inputs lists, including the output type.

Return decision-relevant data, not artifact content. Full artifacts live on disk; the orchestrator reads the file when it needs detail. The synthesizer is the exception — its capability menu is structured, bounded, and required for Phase 3.

SubagentReturn inline
Explorerpath written, byte count, technique, finding count, anomalies
Synthesizerfull capability menu (Phase 3 needs it), path written, byte count
Observerpath written, byte count, observation count, surface item count, anomalies
Lifterpath written, byte count, requirement count, scenario count, uncertainty count, anomalies

Track a manifest, not content. Decide what runs, track completed paths + counts + status, detect failures, trigger the next phase. Never re-ingest all artifacts at once.

dot
digraph subagent_dispatch {
need [label="Phase needs subagent", shape=ellipse];
resolve [label="Resolve absolute paths\n($TMPDIR, skill_root)", shape=box];
compose [label="Compose prompt:\nread references/<role>.md\n+ scope + literal output path", shape=box];
dispatch [label="Dispatch subagent", shape=box];
work [label="Subagent reads role doc,\ndoes scoped work,\nwrites artifact to disk", shape=box];
verify_cmd [label="ls -la <output_path>", shape=plaintext];
report [label="Subagent reports path + bytes\n+ counts inline", shape=box];
check [label="File exists and non-empty?", shape=diamond];
manifest [label="Update manifest:\npath + counts + status=ok", shape=box];
fail [label="Mark dispatch failed;\nre-dispatch or escalate", shape=octagon, style=filled, fillcolor=pink];
next [label="Trigger next phase", shape=doublecircle];
need -> resolve;
resolve -> compose;
compose -> dispatch;
dispatch -> work;
work -> verify_cmd;
verify_cmd -> report;
report -> check;
check -> manifest [label="yes"];
check -> fail [label="no"];
manifest -> next;
}
Phase 1: Understand User Intent

Extract from the request:

  • Which capability(s) does this touch?

(auth, payments, UI, etc.)

  • What behavior is being specified?

(new, modified, retroactive)

  • In scope vs. out of scope?

Ask one targeted question if truly ambiguous.

Don't speculate on large surface areas — confirm scope before generating anything.

Phase 2: Discovery

Two sequential calls:

  1. `discovery-explore` — fan out parallel explorers, one per technique (call graph, naive AST, data-flow / channel, port/interface, schema artifacts, test-suite).

Each emits structured findings.

  1. `discovery-synthesize` — single synthesizer consumes all explorer outputs and produces a capability menu (candidates with file scope and cost, overlaps, external-surface candidates, axis disagreements, gotchas).

See references/discovery.md for the explorer schema, synthesizer expectations, and loop semantics.

One-time tooling suggestions. Check .specs/.sdd/suggested-tools and present each suggestion below at most once (append the marker after presenting; create the file/dir if needed). If declined or already listed, skip and proceed with reduced fidelity.

`code-review-graph` (first run only):
CLI that builds a structural AST graph of the codebase, improving call-graph discovery with communities, bridge nodes, and impact-radius signals. Install: uv tool install code-review-graph. Without it, the call-graph explorer falls back to naive AST traversal. Say "skip" to dismiss.
`schema-config` (first run only when schemas detected):
Detected schema artifacts: <files>. Create .specs/.sdd/schema-config.yaml to configure schema extraction commands — enables snapshot generation, drift detection, and authored-vs-generated diffs. See references/sdd-schema.md § 3 for the format. Without it, the schema-artifact explorer runs detection-only. Say "skip" to dismiss.
Phase 3: Pre-flight Consent

Users typically lack architectural ground-truth for overlap-ownership and external-surface classification. The orchestrator commits sensible defaults silently and only escalates on flagged conditions.

Defaults (applied silently unless escalation fires):

  • Pre-select all candidates with confidence >= medium.
  • Overlap primary-owner: capability with most edges to the bridge wins; ties broken alphabetically.
  • External-surface owned vs 3rd-party: take each candidate's classification when explorer confidence ≥ medium.

Escalation conditions (orchestrator MUST prompt):

  • Single-cluster degeneracy flagged by the synthesizer.
  • Axis disagreements between explorers on capability boundaries.
  • Universally low confidence (< medium across the menu).
  • Cost threshold exceeded — capability count > 6 OR file count > 100.
  • External-surface classification has medium-vs-high split.

When no escalation fires, present a brief summary (capabilities + counts + cost) and proceed. When any fires, present only the flagged item and ask one targeted question.

Loop semantics: if the user requests refinement, clarify the request unless unambiguous. Refinement options:

  • Re-run synthesizer alone — cheap; preferred for "treat A and B as one"
  • Re-run a specific explorer with adjusted scope — medium; for "ignore vendor/"
  • Re-run all explorers — expensive; only for substantive scope changes

Change-directory output — value layer. If the output type is a change directory, draft candidate user stories from the change intent (Phase 1) and the capability menu — cross-cutting product value — and seed .specs/NORTH-STAR.md if absent. Present both for user ratification here, before dispatching lifters: Phase 4 lifters add each requirement's Serves: backlink from this ratified story set. Deriving cross-cutting stories from code is approximate — present them for ratification rather than asserting them. Baseline output skips this entirely (baseline is value-free).

Phase 4: Per-Capability Derive

For each selected capability, dispatch sequentially:

This is the start of the file. Read the full SKILL.md on GitHub.

Security

  • Security scanPassed, 95 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

Repository stars
4
7-day trend score
8

Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/ahgraber/skills/sdd-derive/badge)](https://verified-skill.com/skills/ahgraber/skills/sdd-derive)

Something wrong with this skill or its page? Tell us.