From jaan-to
Orchestrates RED/GREEN/REFACTOR TDD cycles using context-isolated Task sub-agents. Use for test-first feature implementation with structured BDD outer loop support.
How this skill is triggered — by the user, by Claude, or both
Slash command
/jaan-to:qa-tdd-orchestrate [feature-description | acceptance-criteria | qa-test-cases-output][feature-description | acceptance-criteria | qa-test-cases-output]This skill is limited to the following tools:
The summary Claude sees in its skill listing — used to decide when to auto-load this skill
> Context isolation between AI agents is the single most important architectural decision for TDD.
Context isolation between AI agents is the single most important architectural decision for TDD.
$JAAN_CONTEXT_DIR/tech.md - Tech stack context (CRITICAL -- determines test framework and runner)
#current-stack, #frameworks, #constraints$JAAN_LEARN_DIR/jaan-to-qa-tdd-orchestrate.learn.md - Past lessons (loaded in Pre-Execution)$JAAN_TEMPLATES_DIR/jaan-to-qa-tdd-orchestrate.template.md - Output template${CLAUDE_PLUGIN_ROOT}/docs/extending/language-protocol.md - Language resolution protocol${CLAUDE_PLUGIN_ROOT}/docs/research/76-tdd-bdd-ai-orchestration.md (Sections 1, 3)Feature Source: $ARGUMENTS
Input modes:
/jaan-to:qa-test-cases) for outer loopIMPORTANT: The input above is your starting point. Determine mode and proceed accordingly.
This skill requires the Task tool for spawning context-isolated sub-agents. Context isolation (the core research premise) requires Task-based sub-agents; single-context sequential mode fundamentally breaks this guarantee. This skill is NOT available in Codex runtime.
MANDATORY -- Read and execute ALL steps in: ${CLAUDE_PLUGIN_ROOT}/docs/extending/pre-execution-protocol.md
Skill name: qa-tdd-orchestrate
Execute: Step 0 (Init Guard) -> A (Load Lessons) -> B (Resolve Template) -> C (Offer Template Seeding)
Also read context files if available:
$JAAN_CONTEXT_DIR/tech.md -- Know the tech stack for test framework detectionIf files do not exist, continue without them.
Read and apply language protocol: ${CLAUDE_PLUGIN_ROOT}/docs/extending/language-protocol.md
Override field for this skill: language_qa-tdd-orchestrate
Language exception: Generated code output is NOT affected by this setting.
ultrathink
Use extended reasoning for:
Based on input mode:
Feature description: Decompose into testable components (functions, modules, endpoints). Acceptance criteria / qa-test-cases output: Use as outer BDD acceptance test. Each AC becomes an outer loop iteration target.
Present decomposition:
TDD DECOMPOSITION
-------------------------------------------------------------
Feature: {feature name}
Outer Loop: {count} acceptance criteria
Inner Components: {count} TDD-able units
Components:
1. {component_name} -- {brief description}
2. {component_name} -- {brief description}
...
Test Framework: {detected from tech.md}
Test Command: {detected test command}
Read $JAAN_CONTEXT_DIR/tech.md for test framework detection:
If tech.md unavailable, use AskUserQuestion:
For each component, plan the RED/GREEN/REFACTOR sequence:
TDD CYCLE PLAN
-------------------------------------------------------------
Outer Loop: BDD Acceptance Test
"{acceptance criterion text}"
Inner Cycles:
Cycle 1: {component_1}
RED: Write failing test for {specific behavior}
GREEN: Minimal implementation to pass
REFACTOR: Clean up, extract patterns
Cycle 2: {component_2}
RED: Write failing test for {specific behavior}
GREEN: Minimal implementation to pass
REFACTOR: Clean up, apply DRY
...
Iteration Limits:
Max RED-GREEN cycles per component: {5-10}
Same-test failure escalation: 3 attempts
Max total cycles: {configurable, default 10}
Show complete plan before executing:
TDD ORCHESTRATION PLAN
-------------------------------------------------------------
Feature: {feature name}
Components: {count}
Outer Loop: {count} acceptance criteria
Inner Cycles: {estimated count} RED-GREEN-REFACTOR cycles
Test Framework: {framework}
Test Command: {command}
Context Isolation:
Level 1: Artifact-only handoffs (no reasoning text)
Level 2: Prompt exclusion lists (per agent)
Level 3: Handoff manifest verification
Output Folder: $JAAN_OUTPUTS_DIR/qa/tdd-orchestrate/{id}-{slug}/
Use AskUserQuestion:
Do NOT proceed to Phase 2 without explicit approval.
Reference: See
${CLAUDE_PLUGIN_ROOT}/docs/extending/qa-tdd-orchestrate-reference.mdsection "Agent Prompt Templates" for RED/GREEN/REFACTOR agent prompts with explicit exclusion rules.
Isolation is enforced at three levels:
Level 1 -- Artifact-only handoffs: No reasoning text transfer between agents. Only file paths and test runner stdout/stderr cross boundaries.
Level 2 -- Prompt exclusion lists: Each agent's Task prompt explicitly excludes information from other phases.
Level 3 -- Handoff manifest verification: Each phase gate writes handoff-{phase}.json listing only artifact paths being passed. Next agent's prompt is built ONLY from allowlisted paths.
Parallel Component Execution: When multiple components have no data dependencies, run their TDD cycles concurrently via separate Task agents. Each agent handles a full RED/GREEN/REFACTOR cycle independently. Merge results after all complete.
Outer Loop Batching: Run all AC acceptance tests once upfront before starting inner cycles. Only TDD components whose acceptance tests fail. This avoids unnecessary cycles for already-passing ACs.
Handoff Optimization: Compress test runner output in handoff manifests -- include only failure messages and assertion diffs, exclude verbose logs and stack traces. This significantly reduces Task prompt token overhead.
For each acceptance criterion:
For each component within current AC:
Spawn isolated sub-agent via Task tool:
Task prompt for RED agent:
- ONLY includes: requirements text, test framework docs, existing test patterns
- EXCLUDED: implementation plans, existing source code (src/**), scaffold output
- Goal: Write a failing test for {component} that tests {specific behavior}
- Output: test file path
Phase gate: Run test command. Verify test FAILS (non-zero exit code).
handoff-red.json:
{
"phase": "red",
"test_file": "{path to test file}",
"runner_output": "{stdout/stderr from failed test run}",
"exit_code": 1
}
Spawn isolated sub-agent via Task tool:
Task prompt for GREEN agent:
- ONLY includes: failing test file content, test runner output (from handoff-red.json)
- EXCLUDED: RED agent's reasoning, requirements text, implementation plans
- Goal: Write MINIMAL code to make the failing test pass
- Output: implementation file path(s)
Allowlist verification: Assert GREEN agent's prompt contains ONLY content from files listed in handoff-red.json. Any non-manifest content = isolation violation, abort cycle.
Phase gate: Run test command. Verify test PASSES (zero exit code).
handoff-green.json:
{
"phase": "green",
"implementation_files": ["{path1}", "{path2}"],
"test_file": "{path to test file}",
"runner_output": "{stdout/stderr from passing test run}",
"exit_code": 0
}
Spawn isolated sub-agent via Task tool:
Task prompt for REFACTOR agent:
- INCLUDES: all code files + passing test suite output
- EXCLUDED: RED and GREEN agent prompts/reasoning
- Goal: Improve code quality without changing behavior. All tests must still pass.
- Output: modified file path(s)
Phase gate: Run ALL tests. Verify ALL still PASS (zero exit code).
Track progress per component:
Component: {name}
Cycle 1: RED(pass) -> GREEN(pass) -> REFACTOR(pass)
Cycle 2: RED(pass) -> GREEN(fail x2, pass) -> REFACTOR(pass)
...
Same-test failures: {count}/3
Total cycles: {count}/{max}
If same test fails 3 times with same error pattern: escalate via AskUserQuestion with error details.
Before preview, validate:
source "${CLAUDE_PLUGIN_ROOT}/scripts/lib/id-generator.sh"
SUBDOMAIN_DIR="$JAAN_OUTPUTS_DIR/qa/tdd-orchestrate"
mkdir -p "$SUBDOMAIN_DIR"
NEXT_ID=$(generate_next_id "$SUBDOMAIN_DIR")
Generate slug from feature name, lowercase-kebab-case, max 50 chars.
Template:
TDD orchestration for {feature_name} completed with {component_count} components
across {cycle_count} RED-GREEN-REFACTOR cycles. {ac_count} acceptance criteria
satisfied. Context isolation enforced via artifact-only handoffs with manifest
verification. Final test suite: {test_count} tests, all passing.
TDD ORCHESTRATION RESULTS
-------------------------------------------------------------
ID: {NEXT_ID}
Folder: $JAAN_OUTPUTS_DIR/qa/tdd-orchestrate/{NEXT_ID}-{slug}/
Feature: {feature name}
Components: {count}
Total Cycles: {count}
Tests Written: {count}
Tests Passing: {count}/{count}
Acceptance Criteria:
AC1: {text} -- PASS
AC2: {text} -- PASS
...
Files:
{id}-{slug}.md (Orchestration report)
handoff-red.json (RED phase manifest)
handoff-green.json (GREEN phase manifest)
orchestration-log.json (Full cycle history)
Use AskUserQuestion:
If approved:
OUTPUT_FOLDER="$JAAN_OUTPUTS_DIR/qa/tdd-orchestrate/${NEXT_ID}-${slug}"
mkdir -p "$OUTPUT_FOLDER"
Path: $OUTPUT_FOLDER/${NEXT_ID}-${slug}.md
Sections:
Path: $OUTPUT_FOLDER/orchestration-log.json
Contains full cycle-by-cycle history with timestamps, agent outputs, and phase gate results.
source "${CLAUDE_PLUGIN_ROOT}/scripts/lib/index-updater.sh"
add_to_index \
"$SUBDOMAIN_DIR/README.md" \
"$NEXT_ID" \
"${NEXT_ID}-${slug}" \
"{Feature Name} TDD Report" \
"{Executive Summary}"
TDD ORCHESTRATION COMPLETE
-------------------------------------------------------------
ID: {NEXT_ID}
Folder: $JAAN_OUTPUTS_DIR/qa/tdd-orchestrate/{NEXT_ID}-{slug}/
Index: Updated $JAAN_OUTPUTS_DIR/qa/tdd-orchestrate/README.md
Components: {count}
Cycles: {count}
Tests: {count} (all passing)
Next Steps:
- Review generated tests and implementation
- Run /jaan-to:qa-test-mutate to validate test effectiveness
- Run /jaan-to:dev-verify to verify build pipeline
Use AskUserQuestion:
If "Learn from this": Run /jaan-to:learn-add qa-tdd-orchestrate "{feedback}"
tech.md detection$JAAN_OUTPUTS_DIR path{id}-{slug}/{id}-{slug}.mdnpx claudepluginhub parhumm/jaan-to --plugin jaan-toOrchestrates red-green-refactor TDD cycles, coordinates multi-agent testing workflows, and enforces test-first discipline with modern TDD methodologies.
Guides Red-Green-Refactor cycles for test-first feature implementation and bug fixes. Requires /optimus:init and working test infrastructure.
Enforces strict test-driven development: write a failing test first, then minimal code to pass, then refactor. Activates when TDD is explicitly requested or chosen for an atomic task.