From claude-tdd-pro
Use when the user asks to EXTRACT or RELOCATE existing code into its own file, module, or component ("extract X", "split out Y", "pull Z into its own file", "decompose god-file"). NOT for net-new features (use tdd-feature-build) or behavior changes (use fix-bug). Enforces the 9-step extraction with isolated unit tests + integration regression tests as a two-tier safety net.
How this skill is triggered — by the user, by Claude, or both
Slash command
/claude-tdd-pro:test-first-extractThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
You are extracting code from one location into a new, focused file.
You are extracting code from one location into a new, focused file. The risk is silent regression — props dropped, callbacks rewired wrong, state coupling broken. The discipline below makes that risk catchable.
QUALITY-BAR.md for the strictness rules and refactor
discipline.Foo.jsx ↔ Foo.test.jsx). If the project uses a
different convention (e.g. __tests__/ mirror), match it.Read the inline code being extracted. Build a complete inventory:
If anything in the inventory is itself inline in the parent (e.g., a 1,600-line component the wrapper depends on) — STOP. Either extract that dependency first, or pivot to a different extraction. Never use render-props or import-circularity hacks to work around blocking inline dependencies.
Create <Target>.test.{jsx,ts,py} at the target path's sibling.
Import from the target file path (which doesn't exist yet — that's
intentional).
Cover EVERY meaningful prop / arg / branch / edge case from your survey:
Apply the strictness rules from QUALITY-BAR.md:
getByRole over queryAllByText.toBeInTheDocument, toBeDisabled,
toHaveAttribute).userEvent over fireEvent for interactions.Run just the new test file. They MUST fail with file-not-found (or import error). That's the correct "red" state.
If they pass somehow → you imported from the wrong path; fix. If they fail for any other reason → fix the test, don't proceed.
Open the parent's integration test file (e.g.,
ScriptureEngineV2.regression.test.jsx). Add tests that exercise the
about-to-be-extracted UI/behavior THROUGH the live parent.
These tests:
Run the integration tests. They MUST pass against the current (still- inline) code. This establishes the baseline.
If they fail → your test is wrong; fix until green. The baseline must be solid before you touch the code.
Now (and only now) create <Target>.{jsx,ts,py} and copy the inline
code into it, transformed into a function/class accepting the props
you defined in step 1.
Keep behavior IDENTICAL. This is a relocation, not an improvement opportunity. Resist the urge to "clean up while you're here" — that expands scope and undermines the test net.
Run just the new test file. All tests should pass. If any fail, the extraction has a real bug — fix the implementation (not the test).
Open the parent. Remove the inline code. Add:
import { Target } from './path/to/Target.jsx';
Replace the inline JSX with <Target {...props} />.
For React: pass props the parent owns; wire callbacks to parent's state setters.
Run every test in the project — unit + integration + regression. All must pass.
If anything is red → revert the parent edit (step 8), debug, retry.
If green → commit using QUALITY-BAR.md commit format:
refactor(scope): extract <Target> from <Parent>
Process: tests-first (10 strict unit tests for the target + 2
regression tests in the parent suite); confirmed file-not-found
failure; created target; verified isolated 10/10; replaced inline
~N lines with <Target …>; full suite NN/NN green.
Behavior: no behavior change — pure relocation.
Numbers: parent file XXX → YYY lines (-N). Tests: AA → BB (+N).
Assisted-by: Claude (claude-tdd-pro 0.3.0)
If the "target" is a 1,000+ line block:
This is the "wave" pattern — each wave is its own commit, each commit runs through the full 9 steps.
npx claudepluginhub drumfiend21/claude-tdd-proOffers UI/UX design guidance for web and mobile with 50+ styles, 161 color palettes, 57 font pairings, and 99 UX guidelines across 10 stacks. Use for designing pages, components, color systems, or reviewing UI code.
Fetches up-to-date documentation from Context7 for libraries and frameworks like React, Next.js, Prisma. Use for setup questions, API references, and code examples.