Skip to content
Agent Orchestration
Skill

/test-first

Use when implementing a feature, fixing a bug, refactoring, or changing behaviour in any codebase, before writing the production code that does it.

From plugin
godmode
12333 skills1 agent2 hooks

Claude Code

$ npx -y skills add NoobyGains/godmode --skill test-first --agent claude-code

SKILL.md

test-first.SKILL.md
name: test-first
description: "Use when implementing a feature, fixing a bug, refactoring, or changing behaviour in any codebase, before writing the production code that does it."

Test-First Development

Every change in behaviour starts as a test that fails for the right reason. You write the test, run it, watch it fail, write the least code that makes it pass, and only then clean up. **A test you never saw fail is a test you have no evidence for.**

The Prime Directive

NO PRODUCTION CODE WITHOUT A FAILING TEST THAT YOU WATCHED FAIL

No exceptions. No workarounds. No shortcuts.

Production code written before its test is deleted, not kept "for reference" and not adapted while the test is written. Delete it and build it again from the test.

When to Use

**Required:**

  • A new feature, function, endpoint, command or component.
  • A bug fix: the failing test reproduces the bug before the fix exists.
  • A refactor: the tests that pin current behaviour run green before you touch the code, and after every step.
  • Any change in behaviour, however small it looks.

**Skip (only with the user's agreement, stated in the conversation):**

  • A throwaway spike whose code will be discarded. When the spike ends, delete it and start the real work test-first.
  • Generated code (lockfiles, generated clients, migrations produced by a tool) where the generator is the thing under test.
  • Pure configuration with no logic. Configuration that changes behaviour is verified by `godmode:completion-gate` instead.

The Protocol

digraph test_first {
    rankdir=LR;
    red [label="RED\nwrite one failing test", shape=box];
    red_ok [label="fails for the\nexpected reason?", shape=diamond];
    green [label="GREEN\nleast code to pass", shape=box];
    green_ok [label="this test and\nall others pass?", shape=diamond];
    refactor [label="REFACTOR\nclean, stay green", shape=box];
    next [label="next behaviour", shape=ellipse];

    red -> red_ok;
    red_ok -> green [label="yes"];
    red_ok -> red [label="no: fix the test"];
    green -> green_ok;
    green_ok -> refactor [label="yes"];
    green_ok -> green [label="no: fix the code"];
    refactor -> green_ok [label="after each edit"];
    refactor -> next;
    next -> red;
}

1. **Name the behaviour.** Write one sentence: "When X, the code does Y." If you cannot write it, you do not yet know what to build; go back to the plan or ask the user one question.

2. **Name the break.** Before writing the test body, name the production mistake that would make this test fail (a wrong branch, a missing side effect, an off-by-one, an unhandled error). A test that no realistic bug can fail is not worth writing.

3. **RED: write one test.** One behaviour per test, a name that reads as the behaviour, real code wherever possible. Derive the expected value by hand (a literal or a hand-checked fixture), never by calling the code under test.

4. **Watch it fail.** Run only that test (`npm test -- path/to/file`, `pytest path::test_name`, `go test -run Name ./pkg`). Read the output and confirm three things:

  • it fails, rather than erroring on a typo, a missing import or a broken fixture;
  • the failure message is the one you predicted;
  • it fails because the behaviour is missing, not for an unrelated reason.

If it passes, you are testing behaviour that already exists, or the test cannot fail; rewrite it. If it errors, fix the error and run it again until it fails cleanly. Keep the failing output: it is the evidence for this step.

5. **GREEN: write the least code that passes.** Hard-code if that is the least code; the next test will force the generalisation. No options, parameters or abstractions the tests do not demand. No "while I am here" edits elsewhere.

6. **Watch it pass.** Run the test, then the whole suite. The new test passes, every other test still passes, and the output carries no new warnings. If the new test fails, fix the code, not the test. If another test broke, fix that now, before anything else.

7. **REFACTOR.** Only on green. Remove duplication, improve names, extract helpers. Run the suite after every edit. Refactoring adds no behaviour; a new behaviour needs a new failing test.

8. **Repeat** from step 1 for the next behaviour. Commit at green points so every commit has passing tests. For a bug fix, commit the reproducing test on its own first (`test: reproduce <bug>`), then the fix (`fix: ...`): the red evidence then survives in history, and a reviewer can check out the first commit and watch it fail.

Bug Fixes

A bug report is a test you have not written yet.

1. Write a test that reproduces the reported symptom through the same entry point the user hit. 2. Watch it fail with the symptom the user described. If it passes, your reproduction is wrong; keep working on the test, not the fix. 3. Find the root cause with `godmode:fault-diagnosis` before you change production code. 4. Fix at the root cause, watch the test pass, run the suite. 5. Prove the test guards the fix: revert the fix, watch the test fail again, restore the fix, watch it pass. This red-green-red-green loop is what `godmode:completion-gate` asks for when you claim a regression test works.

Writing Good Tests

| Quality | Good | Bad | |---|---|---| | One behaviour | `rejects an empty email` | `validates email and domain and whitespace` | | Behaviour, not implementation | Asserts the returned value, the stored row, the emitted event | Asserts which private helper was called | | Independent expectation | `expect(slug('A B')).toBe('a-b')` | `expect(slug(x)).toBe(slug(x))` | | Real collaborators | Uses the real parser and an in-memory store | Mocks every collaborator, then asserts on the mocks | | Deterministic | Waits for the condition it needs | Sleeps for a guessed number of milliseconds | | Readable failure | The failure message says what was expected | `expected true, got false` |

Before adding a mock, a test helper or a cleanup method, rea

Read more
@noobygains
Ships withgodmode

Engineering discipline for AI coding agents: question the request, verify against current docs, plan, build test-first on the cheapest capable model, review with a second model family, prove it before saying done. One repo for Claude Code, Codex, Antigravity, Cursor, Gemini CLI and OpenCode.

12333 skills1 agent
Get the whole plugin

Stars on GitHub

Momentum

stars in total
123
Star history of NoobyGains/godmode on GitHub, a chart by star-history.com

Other skills on godmode.

agent-briefing

agent-briefing

Use when writing a prompt for a subagent or teammate, deciding how much context another agent needs, writing or reading a handoff…

@noobygains@noobygainsInstall Skill
code-review

code-review

Use when a task, feature or bug fix is implemented and before it is committed, merged or handed back to the user, and when the…

@noobygains@noobygainsInstall Skill
codebase-conventions

codebase-conventions

Use when about to add or change code in an existing codebase: a new file, module, route, component, service, test, migration,…

@noobygains@noobygainsInstall Skill
completion-gate

completion-gate

Use when about to say that work is done, fixed, passing, working, deployed or ready, before committing, opening or merging a pull…

@noobygains@noobygainsInstall Skill
cross-model-review

cross-model-review

Use when a reviewed change is about to land on a shared branch, be released or be deployed, and when the user asks for a second…

@noobygains@noobygainsInstall Skill
delegated-execution

delegated-execution

Use when a written implementation plan is ready to execute in the current session and its tasks are mostly independent, so each…

@noobygains@noobygainsInstall Skill

More skills from other plugins.

1password

1password

Set up and use 1Password CLI for sign-in, desktop integration, and reading or injecting secrets.

openclaw3d395k
@steipete@steipeteInstall Skill
jira-tickets

jira-tickets

Read and update Jira tickets through Orca's saved Jira connections. Use when a task comes from Jira or the user asks for Jira…

orca1d128k
@stablyai@stablyaiInstall Skill
agentmail

agentmail

Use your assigned AgentMail inbox to read email tasks, explicitly send or reply, and check delivery. Provided automatically by…

paperclip2d114k
@paperclipai@paperclipaiInstall Skill
adr-create

adr-create

Create a new Architecture Decision Record with sequential numbering and AgentDB registration

@ruvnet@ruvnetInstall Skill

Questions about test-first.

Which coding agents can use test-first?
test-first installs in Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode and Windsurf with the skills CLI, using each agent's flag shown on this page. Flowy's auto-invocation, which fires a skill when your prompt matches, runs in Claude Code only.