/everything-copilot-cli:tdd-workflowfrom everything-copilot-cli
Guides through the Red-Green-Refactor TDD cycle when building new features or fixing bugs. Includes pre-check for existing tests, language-specific test commands, and advice on choosing the smallest behavior slice.
Ships in everything-copilot-cli. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
| Language | Common frameworks | Example commands |
|---|---|---|
| JavaScript / TypeScript | Jest, Vitest | npm test, npx vitest |
| Python | pytest | pytest |
| Go | go test | go test ./... |
| Ruby | RSpec, Minitest | bundle exec rspec, ruby -Itest test/ |
| PHP | PHPUnit | ./vendor/bin/phpunit |
| Rust | cargo test | cargo test |
tdd-guard users: v1.7.0 improves SDK validation error handling, reduces response tokens for allow-operation, and refactors hook-payload parsing. After
bundle add tdd-guard, re-check its framework detection before relying on automatic enforcement.
Before you write or change anything, shrink the task to the smallest meaningful behavior that can go through one Red → Green → Refactor loop.
Good first slices usually have all three properties:
If the first test needs multiple branches, multiple modules, or a large fixture to make sense, shrink it again. After each Green phase, pause long enough to confirm the direction before stacking more behavior on top.
Before writing a new test, verify you are not duplicating existing coverage.
glob pattern="**/*.{test,spec}.{js,jsx,ts,tsx}"
glob pattern="**/{test_*,*_test}.py"
glob pattern="**/*_test.go"
rg pattern="<function-or-behavior-name>" path="."
If an equivalent test already exists, extend or correct it instead of creating a duplicate. If not, proceed to write the failing test.
Identify the behavior to implement, then write a test that asserts it.
# Find existing test files to follow conventions
glob pattern="**/*.test.{ts,js,tsx}" # or **/*_test.go, **/test_*.py
Write a focused test using create or edit:
// example: src/utils/parse.test.ts
describe('parseConfig', () => {
it('should return default values when input is empty', () => {
expect(parseConfig({})).toEqual({ timeout: 30, retries: 3 });
});
});
Run the test and confirm it fails:
npm test -- --testPathPattern="parse.test" 2>&1 | Select-Object -Last 20
Every test must name the break it catches: its name or a focused comment should answer which production regression makes it fail. Every test must also exercise the real behavior; a test that only verifies its mock can stay green while the implementation is broken.
Avoid change-detector tests that can fail only when an intentional constant, exact message, or private structure changes; they fire on redesign and sleep through behavioral bugs. Likewise, asserting that a script, skill, or config contains an exact string proves only that the source contains that string. Exercise the consuming behavior, output, side effect, or exit code instead.
Before finishing, perform a mutation check: deliberately make a safe, temporary break in the implementation and confirm that the relevant test fails, then restore it. If no test detects the mutation, the behavior is unprotected or the test is tautological.
Implement only enough code to make the failing test pass. Resist the urge to add extras.
// src/utils/parse.ts
export function parseConfig(input: Record<string, unknown>) {
return { timeout: input.timeout ?? 30, retries: input.retries ?? 3 };
}
Run the test again and confirm it passes:
npm test -- --testPathPattern="parse.test"
Improve code structure, naming, and duplication while keeping all tests green.
Exception — type-only edits: Adding type annotations, cleaning up imports, or renaming for clarity without changing behavior does not require a prior failing test. Restrict this exception to structural changes only; any logic change must still go through Red → Green first.
# Run full test suite to ensure nothing else broke
npm test 2>&1 | Select-Object -Last 30
Add the next test case for edge cases or the next slice of behavior:
Pick the smallest next slice that adds new information. If the product direction, API shape, or UX is still uncertain, stop after a thin vertical slice and get feedback before widening the change.
npm test -- --coverage --collectCoverageFrom="src/utils/parse.ts"
Aim for ≥80% line coverage on new code, ≥90% branch coverage on critical paths.
# 1. Reproduce the bug as a test
# grep for the failing function, write a test with the exact input that causes the bug
grep -n "calculateTotal" src/billing/*.ts
# 2. Run and see it fail
npm test -- --testPathPattern="billing"
# 3. Fix the code
# 4. Run and see it pass
# 5. Add edge-case tests around the fix
# Use the task agent to run tests continuously while you code
# Start test watcher in async mode
npx jest --watch --testPathPattern="feature" # mode: async
| Rationalization | Reality |
|---|---|
| "This code is too simple to need tests" | Simple code still has edge cases. A 5-line function can have 3. |
| "I'll add tests later" | Later never comes. Untested code becomes legacy code overnight. |
| "It works, I can see it" | Manual verification is not reproducible. CI will catch what you missed. |
| "Copilot wrote it, so it must be right" | AI-generated code requires the same verification standards as human-written code. |
| "Tests still pass after refactoring" | Tests must exist before refactoring — otherwise they provide no safety net. |
Prevent implementation code from being committed without a corresponding failing test. Add this pre-commit check to your workflow:
# Verify that implementation files have corresponding test files staged
$stagedSrc = git diff --cached --name-only | Where-Object { $_ -match "^src/" -and $_ -notmatch "\.test\." }
$stagedTests = git diff --cached --name-only | Where-Object { $_ -match "\.test\." }
if ($stagedSrc -and -not $stagedTests) {
Write-Error "TDD violation: source files staged without corresponding test files."
Write-Error "Write a failing test first, then implement."
exit 1
}
To enforce this automatically, add it as a Git pre-commit hook:
# .git/hooks/pre-commit (chmod +x on Unix)
# See rules/common/testing.md for the full hook content
it('works') with no meaningful assertionsnpm test (or equivalent) exits with code 0it('rejects negative quantities')task agent to run tests so output stays clean in your main contextWhat SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
Jest, Vitest, Pytest, TypeScript, JavaScript, Python, Go, Ruby
npx claudepluginhub drvoss/everything-copilot-cli --plugin everything-copilot-cli115 skills in this plugin
/actions-debuggingUse when a GitHub Actions workflow fails — diagnose the run log, identify the root cause, and apply a targeted fix/add-to-changelogUse when you've shipped a feature, fix, or breaking change and need to update CHANGELOG.md — follows Keep a Changelog format and syncs version numbers across package manifests./agent-governanceUse when designing or reviewing an AI agent system that needs policy-based access controls, intent classification, tool-level rate limiting, trust scoring for multi-agent workflows, or append-only audit trails.
Other plugins' skills for the same job