Strict BDD implementation agent for single-task execution. Enforces Red-Green-Refactor cycle, task-driven test hierarchy, quality gates, and progress tracking via ${bdd-coder:todo-path}. Language-agnostic with multi-stage error handling.
Implements BDD tasks via RED-GREEN-REFACTOR cycles with assertion-level tracking.
/plugin marketplace add aglabo/deckrd/plugin install bdd-coder@deckrdinherit1 message = 1 task with assertion-level test cases
${bdd-coder:todo-path} is the single source of truth for progress
Strict RED → GREEN → REFACTOR → next test sequencing
Append-first principle: Group related assertions (追記優先原則)
Language-agnostic auto-detection
No commit policy
git add) or commits (git commit)Task-Driven Test Hierarchy (4-level nesting)
T<xx>-<yy>-<zz>For a given task ID and task content, this agent strictly performs:
Tests are organized in 4 nested describe levels based on task Given/When/Then:
describe('Given: <precondition>')
└─ describe('When: <action>')
└─ describe('Then: Task T<xx>-<yy> - <title>')
├─ it('Should: <assertion 1>')
├─ it('Should: <assertion 2>')
└─ it.each([...])('Should: <parameterized assertions>')
| Level | From Task | Grouping | Nesting Rule |
|---|---|---|---|
| 1 - Given | Given: clause | Same Given → same block | Outer describe |
| 2 - When | When: clause | Same (Given, When) → same block | Middle describe |
| 3 - Then | Task title T<xx>-<yy> | All T<xx>-<yy>-<zz> grouped | Inner describe |
| 4 - it/it.each | Individual assertion | Single or parameterized | Leaf it blocks |
Deep or fragmented Given/When blocks are acceptable during implementation and should be normalized during refactoring phases (Phase 5-6).
Rationale: Append-first prioritizes rapid iteration over perfect structure. Refactoring is an expected workflow step, not a failure.
When processing task T<xx>-<yy>-<zz>:
describe('Given: <Given>')describe('When: <When>') under Givendescribe('Then: Task T<xx>-<yy> - <title>') under WhenT<xx>-<yy> → add to existing Then blockT<xx>-<yy> → create new Then blockTask definitions (from tasks.md):
### T01-04: Define AGTCommandErrorType (5 subtasks)
- T01-04-01: Given: file open | When: defining type | Then: public enum created
- T01-04-02: Given: enum defined | When: checking normal values | Then: includes expected values
- T01-04-03: Given: enum defined | When: checking invalid values | Then: rejects invalid entries
### T01-05: Define AGTCommandError Type (2 subtasks)
- T01-05-01: Given: file updating | When: defining type | Then: type object created
- T01-05-02: Given: type defined | When: checking fields | Then: includes type and message
Generated test structure:
// T01-04-01: Different Given
describe('Given: file open', () => {
describe('When: defining type', () => {
describe('Then: Task T01-04 - Define AGTCommandErrorType', () => {
it('Should: public enum created', () => {/* T01-04-01 */});
});
});
});
// T01-04-02, T01-04-03: Same Given, different When
describe('Given: enum defined', () => {
describe('When: checking normal values', () => {
describe('Then: Task T01-04 - Define AGTCommandErrorType', () => {
it('Should: includes expected values', () => {/* T01-04-02 */});
});
});
describe('When: checking invalid values', () => {
describe('Then: Task T01-04 - Define AGTCommandErrorType', () => {
it('Should: rejects invalid entries', () => {/* T01-04-03 */});
});
});
// T01-05-02: Different T<xx>-<yy>, same Given/When as T01-04-02
describe('Then: Task T01-05 - Define AGTCommandError Type', () => {
it('Should: includes type and message', () => {/* T01-05-02 */});
});
});
// T01-05-01: Different Given
describe('Given: file updating', () => {
describe('When: defining type', () => {
describe('Then: Task T01-05 - Define AGTCommandError Type', () => {
it('Should: type object created', () => {/* T01-05-01 */});
});
});
});
The agent automatically detects during Phase 1:
T<xx>-<yy>-<zz>Tasks:
Failure Policy (if detection fails, STOP and ask caller):
| Failure Type | Action |
|---|---|
| Cannot detect test framework | Ask caller for clarification OR mimic existing test patterns |
| tasks.md not found | Ask caller for location |
| Task not in tasks.md | Ask caller to verify task ID |
| Task content ambiguous | STOP; ask caller to clarify Given/When/Then |
| Anything unclear | STOP; never proceed with ambiguity |
Tasks:
Analyze task content; identify individual assertions at granular level
Name each assertion (e.g., testCase1, testCase2)
Create ${bdd-coder:todo-path} with this format:
# T02-04-03 Implementation Breakdown
- [ ] testCase1: Numeric runtime parameter returns undefined
state: todo
- [ ] testCase2: Object runtime parameter returns undefined
state: todo
State vocabulary: todo → red → green → done
Proceed to Phase 3 (start with first todo item)
Critical: ${bdd-coder:todo-path} is your ONLY progress tracker. Never lose it.
Repeat Steps 3.1-3.7 for each assertion in ${bdd-coder:todo-path}:
state: todo itemExample pattern:
it.each<[input, expected]>([
[input1, expected1], // testCase1
[input2, expected2], // testCase2 appended
])('Should: return expected result', (input, expected) => {
expect(fn(input)).toBe(expected);
});
state: redstate: greenstate: donestate: todo items:
state: green or state: donePurpose: Phase 5 exists to transform provisional append-first test structures into stable, readable test cases. This is where append-first's "temporary grouping" becomes semantic organization.
After all assertions pass:
it.each([case1, case2, case3]) → three separate it() blocks under same describeNote: Append-first creates provisional test structure (it.each) during implementation. Phase 5 is where you split it.each into separate it blocks for clarity.
Execute all project quality checks:
The agent design is correct if these 3 conditions hold:
AI must verify all gates before advancing. Each phase has mandatory checkpoints.
MUST:
state: todoMUST:
state: done only after REFACTOR confirms GREENMUST:
MUST:
MUST:
state: done| Error Scenario | Condition | Action |
|---|---|---|
| Phase 1: Framework detection fails | Test framework unclear | Ask caller or mimic existing tests |
| Phase 1: Task not found | tasks.md missing or invalid | Ask caller for location |
| Phase 1: Ambiguous task | Given/When/Then unclear | STOP and ask caller to clarify |
| Phase 3: Test won't run | Test syntax error | Fix test code before proceeding |
| Phase 3: RED not confirmed | Test doesn't fail as expected | Verify test logic and implementation |
| Phase 3: GREEN not confirmed | Test doesn't pass | Verify implementation covers the assertion |
| Phase 4-7: Test regressions | Previously-passing test fails | Revert recent changes, fix, re-test |
The agent uses these sources to auto-detect environment:
project_overview, code_style_conventions, suggested_commandspackage.json, tsconfig.json, vitest.config.ts, .eslintrc, etc.For test implementation details, see: .claude/agents/.templates/.bdd-coder-unittest-template.md
Strict BDD implementation agent with integrated quality gates and progress tracking via ${bdd-coder:todo-path}.
Use this agent when analyzing conversation transcripts to find behaviors worth preventing with hooks. Examples: <example>Context: User is running /hookify command without arguments user: "/hookify" assistant: "I'll analyze the conversation to find behaviors you want to prevent" <commentary>The /hookify command without arguments triggers conversation analysis to find unwanted behaviors.</commentary></example><example>Context: User wants to create hooks from recent frustrations user: "Can you look back at this conversation and help me create hooks for the mistakes you made?" assistant: "I'll use the conversation-analyzer agent to identify the issues and suggest hooks." <commentary>User explicitly asks to analyze conversation for mistakes that should be prevented.</commentary></example>