test-loop

A test-first workflow for fixing bugs and reorganizing code. TDD means writing a test before the code change; a refactor changes structure without intending to change behavior.

In plain words
What is it for?
Use bugfix mode for broken behavior and refactor mode for structure-only changes, then run the full checks: TypeScript compilation, tests, and linting.
Why use it?
It catches regressions by recording the expected behavior first and requiring tests, type checks, and linting to stay passing throughout the work.

Skill for Claude CodeCodex

Part of the playbook plugin — 49 skills, 4 hooks shipped together

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/ao92265/claude-code-playbook/test-loop
Any agent
npx skills add ao92265/claude-code-playbook --skill test-loop
Clone the repo
git clone --depth 1 https://github.com/ao92265/claude-code-playbook

Made for: Claude Code, Codex.

Or install playbook, the plugin that ships this one along with the rest of its 49 skills, 4 hooks.

Per session 152 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,261 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00152 $0.01261
Opus 5 $0.00076 $0.00630
Sonnet 5 $0.00030 $0.00252
Haiku 4.5 $0.00015 $0.00126

Measured 3d ago against content hash 37b7ddb0156b, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

test-loop scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/test-loop/SKILL.md · 118 lines

How it starts

The opening of the file, as written. The whole thing — 118 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Test Loop

One shared skeleton, two modes. Eliminates wrong-approach / buggy-first-pass friction and regression-on-refactor risk by forcing tests-before-code and CI parity before shipping.

Shared skeleton

  1. Write tests (mode-specific — see below)
  2. Commit the tests as a baseline, separate from any behavior change
  3. Change code in small increments
  4. Keep tests green after every increment
  5. Full CI parity gate before PR: tsc -b && npm test && npm run lint

Mode selection

  • Bug report, issue number, "fix X is broken" → bugfix mode
  • Rename/restructure/extract/split/upgrade with no intended behavior change → refactor mode
  • Ambiguous → ask the user which one before writing anything

Mode: bugfix (failing-test-first)

Phase 1 — RED

  1. Read issue, reproduce bug locally.
  2. Write a test that captures expected behavior. Test MUST fail.
  3. Run tsc -b && npm test — confirm the test fails for the RIGHT reason (not a compile error, not a wrong assertion).
  4. Commit failing test alone: test: failing case for #N.

Phase 2 — GREEN

  1. Implement MINIMAL fix. No refactor, no adjacent cleanup.
  2. After every edit run full CI parity: tsc -b && npm test && npm run lint
  3. Loop until all three pass. NEVER skip a step.
  4. 3 failed attempts → STOP, explain blocker, ask user.

Phase 3 — SHIP

  1. Commit fix separate from test: fix: <one line> (#N).
  2. git branch --show-current before push.
  3. gh pr create referencing issue.

Mode: refactor (characterization-first)

For refactors with no intended behavior change: renaming/restructuring, splitting a god component, extracting a hook/util, deduping logic, migrating styles/theme without altering rendered output, or a contained library/version upgrade.

Not for: bug fixes (use bugfix mode above), feature adds, or a mechanical rename across files already covered by existing tests.

Step 1 — Identify target + capture surface

Ask the user (if not stated) for:

  • Target file/dir
  • Public surface to preserve: rendered output, network calls, exposed API, side effects

Read the full file on GitHub · 118 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3d ago First seen · 118 lines · 152 tokens per session scan A 37b7ddb0156b

Subscribe to this mod's changes

test-loop is a skill published in the GitHub repository ao92265/claude-code-playbook (10 stars, last pushed 16d ago), licensed MIT. It adds 152 tokens to every session and 1,261 once invoked, about $0.0008 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

agent-integration

Run all three agent integration phases sequentially: research, write-tests, and implement using E2E-first TDD (unit tests written last). For individual phases, use /agent-integration:research, /agent-integration:write-tests, or /agent-integration:implement. Use when the user says "integrate agent", "add agent…

entireio/cli · 89 tokens

engram-testing-coverage

TDD and coverage standards for Engram. Trigger: When implementing behavior changes in any package.

Gentleman-Programming/engram · 25 tokens

code-assist

Guides implementation of code tasks using test-driven development in an Explore, Plan, Code, Commit workflow. Acts as a Technical Implementation Partner and TDD Coach — following existing patterns, avoiding over-engineering, and producing idiomatic, modern code.

mikeyobrien/ralph-orchestrator · 53 tokens

tdd

Test-driven development. Use when the user wants to build features or fix bugs test-first, mentions "red-green-refactor", or wants integration tests.

GreyDGL/PentestGPT · 33 tokens

css-design-tdd

Test-driven CSS design system modifications. Run checks before/after CSS changes to verify token usage, variable definitions, fallbacks, and consistency. Use when modifying CSS tokens, fixing design inconsistencies, or auditing CSS architecture.

xiaolai/vmark · 49 tokens

mobiai-mobile-tdd

You MUST use this before writing any implementation code for a mobile feature, bug fix, refactor, or behavior change. Tests come before implementation — no exceptions.

ArisGuimera/MobiAI-Core · 38 tokens