skills/code/SKILL.md
Implement code following TDD/RGRC cycle with real-time test feedback. Vertical slices only (one test then one impl, never bulk tests then bulk impl). Do NOT use for small bug fixes or error resolution (use /fix instead).
npx skillsauth add thkt/dotclaude codeInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
NO PRODUCTION CODE WITHOUT A FAILING TEST FIRST.
Violation → delete the code, write the test, then rewrite.
Before writing any code, output the declaration below verbatim.
Starting TDD RGRC cycle. Every code change begins with a failing test.
| Excuse | Counter | | ------------------------------------ | ------------------------------------------------------------------------ | | "This is too simple for TDD" | Simple changes hide regressions. One test line prevents hours of debug | | "I'll add tests later" | "Later" never comes. Test debt compounds with interest | | "This is just a refactor" | Refactors without tests are the #1 cause of silent regressions | | "Existing tests already cover" | If they do, Red phase will confirm it. Run it | | "Testing this would be too slow" | A slow test is faster than a production bug | | "Red test doesn't need verification" | Untested Red = writing blind. Run it; confirm failure matches the intent |
$ARGUMENTS holds the implementation description (required, prompt if empty)| Flag | Effect |
| ---------------- | ------------------------------------------------------- |
| --no-storybook | Disable Storybook auto-detection (default: auto-detect) |
Auto-detects when project has Storybook + component file. See Storybook Phase.
See ${CLAUDE_SKILL_DIR}/../_lib/sow-resolution.md
After reading OUTCOME.md and SOW, check (a) Phase file counts and (b) outcome alignment. If any Phase has Files ≥ 5, stop and ask user to split via /think before proceeding. If the implementation steps into Non-goals or conflicts with Constraints from OUTCOME.md, stop and confirm with user. If no SOW exists and $ARGUMENTS implies ≥ 5 files, suggest running /think first.
JS/TS is first-class. Rust / Go / Python work via generator-test framework detection. When detection fails, specify the test runner explicitly in the task prompt. Storybook/E2E phases auto-skip for non-JS/TS via their existing conditions. Quality Gates are language-agnostic (T-NNN coverage, gates hook per language pre/post-edit).
| Reference | When read | If not found / unclear |
| ----------------------------------------------- | ----------------------------------- | ----------------------------------------------- |
| .claude/OUTCOME.md | Step 0 Outcome Anchor | Generate stub via rules/core/OUTCOME.md flow |
| ${CLAUDE_SKILL_DIR}/../_lib/sow-resolution.md | Step 1 SOW detect | No SOW state, apply Scope Guard inline only |
| ${CLAUDE_SKILL_DIR}/references/csf3-patterns.md | Storybook Phase all conditions pass | Use minimal CSF3 stories format |
| /goal (optional) | Step 4 autonomous loop | gates auto-retry; manual otherwise |
| generator-test agent | Step 2 spawn | Error Handling: Leader generates tests directly |
| evaluator-test agent | Step 8 Quality Gates, Spec exists | Skip Test Quality gate |
| reviewer-readability agent | Step 5 Review Gate | Skip for /fix; continue with manual review |
| Symbol | Meaning | Usage |
| ------------ | ----------------------------------------------------------------- | ------------------------------------------------------------------ |
| T-NNN | T-\d{3} three-digit zero-padded spec scenario ID (e.g. T-001) | Embed in test function name, describe/it string, or inline comment |
| TaskOutput | Synchronous receive from run_in_background: true spawn | Wait for completion before proceeding |
| Step | Action | Detail |
| ---- | ---------------------- | --------------------------------------------------------------------------------- |
| 0 | Outcome Anchor | Read .claude/OUTCOME.md; if absent, stub generation (see rules/core/OUTCOME.md) |
| 1 | SOW Context | Detect and read SOW/spec → Scope Guard |
| 2 | Spawn generator-test | subagent_type: generator-test, run_in_background: true |
| 3 | Receive test results | TaskOutput (wait for completion before implementation) |
| 4 | RGRC cycle | gates auto-retry per Green; optional /goal wrapper |
| 5 | Review Gate | Spawn reviewer-readability (skip for /fix) |
| 6 | Storybook Phase | Conditional |
| 7 | E2E Phase | Conditional |
| 8 | Quality Gates | See use-workflow-code |
During implementation, new requirements may be discovered (edge cases, error handling, integration concerns).
evaluator-test uses T-NNN mappings to compute coverage and other quality metrics.
All must pass, evaluated in order, skip on first fail.
| # | Check | How | On fail |
| --- | ----------------------------------------- | ----------------------------------------------------------- | ------------- |
| 1 | --no-storybook flag not set | Parse $ARGUMENTS | skip (silent) |
| 2 | Project has Storybook | .storybook/ exists OR @storybook/* in package.json deps | skip (silent) |
| 3 | Implementation includes component file(s) | .tsx/.jsx with PascalCase export in changed files | skip (silent) |
When conditions match, announce before generating.
[auto-detect] Storybook detected + {File}.tsx appears to be a component.
Will generate {File}.stories.tsx. Opt out with --no-storybook.
For each detected component, generate {Component}.stories.tsx per ${CLAUDE_SKILL_DIR}/references/csf3-patterns.md. Source props from Spec's Component API section when present, otherwise infer from the component.
| Option | Action | | ------ | ------------------------- | | [O] | Overwrite existing file | | [S] | Skip - keep existing | | [M] | Merge - show diff, manual | | [D] | Diff only - append new |
All must pass, evaluated in order, skip on first fail.
| # | Check | How | On fail |
| --- | ----------------------------------- | ----------------------------------------- | --------------- |
| 1 | Spec has Type: e2e scenarios | ugrep Spec Test Scenarios table | skip (silent) |
| 2 | agent-browser installed | which agent-browser | skip + advisory |
| 3 | Dev server detected in package.json | Match dev, start:dev, start scripts | skip + advisory |
| 4 | Dev server running (user confirms) | AskUserQuestion: "Dev server at {url}?" | skip + advisory |
Detected from package.json scripts.
| Priority | Script name pattern | Default URL | | -------- | ------------------------ | --------------------- | | 1 | dev, start:dev | http://localhost:5173 | | 2 | start | http://localhost:3000 | | 3 | storybook, storybook:dev | http://localhost:6006 |
Extract port from script value if specified (--port, -p, PORT=).
Agent(subagent_type: "generator-e2e",
prompt: "spec_path: <path>\ndev_server_url: <url>",
run_in_background: true)
| Check | Condition | How |
| ------------------------- | -------------------------- | -------------------------- |
| AC met | After RGRC | Manual (skip if no SOW) |
| Test Quality (per-metric) | Spec exists | evaluator-test agent |
| Iteration enforcement | Every Write/Edit/MultiEdit | gates hook (PostToolUse) |
See use-workflow-code for invocation details.
| Error | Action |
| -------------------------------- | -------------------------------------------------------------------------------- |
| generator-test timeout | Leader generates tests directly |
| generator-test produces 0 tests | Verify spec exists, ask user |
| /goal loop stalls | /goal clear, then fix manually |
| Quality gates fail | Fix issues before commit |
| Evaluator metric below threshold | Fix uncovered/excess/duplicate/granularity/intent issues |
| Evaluator timeout | Skip gate, log warning |
| Spec not found | Proceed without T-NNN trace, skip Test Quality gate (or ask user to create spec) |
| agent-browser crash | Skip E2E, advisory, continue |
| Dev server unreachable | Skip E2E, advisory, continue |
| E2E tests fail | Advisory (do not block) |
| Storybook phase error | Skip phase, advisory, continue |
tools
Internal helper for /think Step 11. Renders SOW.md + Spec.md as an integrated Astro view and returns a dev server URL.
development
Extract repository spec while detecting bugs, spec gaps, and consistency drift via dual-purpose documentation. OUTCOME.md-axis question-driven exploration with ephemeral output. Do NOT use for code review (use /audit or /polish), feature implementation (use /code), planning only (use /think), or single-bug fix (use /fix).
development
Discover undocumented design decisions and challenge each candidate via critic-design before promotion. Rank by impact and reversibility, produce ADR promotion candidates. Treat each candidate as a position arguing for ADR status, not a fact to be filed. Pairs with audit-adr-drift, which scans existing ADRs for drift against code.
development
Scan ADR Decision sections against current code and report drift with modification direction and priority. Do NOT use for repos without ADRs (use audit-adr-gaps instead).