Coding Agent — TDD Red-Green-Refactor
Prerequisites
Before starting, read:
- •
/app/.claude/skills/project-conventions/SKILL.md— project rules - •
/app/.claude/skills/project-conventions/references/testing-patterns.md— test templates
Workflow
Step 0: Task Confirmation
- •If a spec exists in
docs/specs/, read it first. - •If a task list is active, check current task context.
- •Identify the module and public API to implement.
Step 1: RED — Write Failing Tests
Reference: project-conventions/references/testing-patterns.md
- •Create or open the test module (
#[cfg(test)] mod tests). - •Add
#![allow(clippy::unwrap_used)]and#![allow(clippy::indexing_slicing)]. - •Write tests following Arrange / Act / Assert pattern.
- •Choose test type:
- •Unit:
#[test]withuse super::* - •Async:
#[tokio::test]with mock structs - •Integration:
tests/<name>.rswithassert_cmd
- •Unit:
- •Run
mise run test— confirm tests fail (red).
Step 2: GREEN — Minimal Implementation
Reference: project-conventions/SKILL.md (error context, imports, tracing)
- •Write the minimum code to make all tests pass.
- •Rules to follow:
- •Every
?must have.context()or.with_context() - •Use
tracingmacros, neverprintln! - •Imports grouped:
std→ external →crate/super - •All commands via
mise run, nevercargodirectly
- •Every
- •Run
mise run test— confirm tests pass (green).
Step 3: REFACTOR — Improve Without Breaking
Reference: ~/.claude/skills/rust-implementation/references/naming.md
- •Remove duplication, improve naming, simplify logic.
- •Follow Rust naming conventions (C-GETTER: no
get_prefix, etc.). - •Keep all tests green after each change.
- •Run
mise run testafter refactoring.
Step 4: Repeat or Finish
- •If more functionality is needed, return to Step 1.
- •When complete, proceed to
/qafor quality checks.
Subagent Templates
Use Task tool with subagent_type: "general-purpose" for parallel work:
| Template | Purpose |
|---|---|
prompts/write-tests.md | Generate tests for a target module |
prompts/implement.md | Generate minimal implementation from tests |
Reference Files
| File | Content |
|---|---|
references/common-errors.md | Frequent pre-commit errors and fixes (shared with /qa) |
Workflow Position
Cycle: /coding → /qa → /review code → /docs → /review docs
This agent is the entry point. After implementation is complete, run /qa.