$npx -y skills add NeoLabHQ/context-engineering-kit --skill test-promptUse when creating or editing any prompt (commands, hooks, skills, subagent instructions) to verify it produces desired behavior - applies RED-GREEN-REFACTOR cycle to prompt engineering using subagents for isolated testing
| 1 | # Testing Prompts With Subagents |
| 2 | |
| 3 | Test any prompt before deployment: commands, hooks, skills, subagent instructions, or production LLM prompts. |
| 4 | |
| 5 | ## Overview |
| 6 | |
| 7 | **Testing prompts is TDD applied to LLM instructions.** |
| 8 | |
| 9 | Run scenarios without the prompt (RED - watch agent behavior), write prompt addressing failures (GREEN - watch agent comply), then close loopholes (REFACTOR - verify robustness). |
| 10 | |
| 11 | **Core principle:** If you didn't watch an agent fail without the prompt, you don't know what the prompt needs to fix. |
| 12 | |
| 13 | **REQUIRED BACKGROUND:** |
| 14 | - You MUST understand `test-driven-development` - defines RED-GREEN-REFACTOR cycle |
| 15 | - You SHOULD understand `prompt-engineering` skill - provides prompt optimization techniques |
| 16 | |
| 17 | **Related skill:** See `test-skill` for testing discipline-enforcing skills specifically. This command covers ALL prompts. |
| 18 | |
| 19 | ## When to Use |
| 20 | |
| 21 | Test prompts that: |
| 22 | |
| 23 | - Guide agent behavior (commands, instructions) |
| 24 | - Enforce practices (hooks, discipline skills) |
| 25 | - Provide expertise (technical skills, reference) |
| 26 | - Configure subagents (task descriptions, constraints) |
| 27 | - Run in production (user-facing LLM features) |
| 28 | |
| 29 | Test before deployment when: |
| 30 | |
| 31 | - Prompt clarity matters |
| 32 | - Consistency is required |
| 33 | - Cost of failures is high |
| 34 | - Prompt will be reused |
| 35 | |
| 36 | ## Prompt Types & Testing Strategies |
| 37 | |
| 38 | | Prompt Type | Test Focus | Example | |
| 39 | |-------------|------------|---------| |
| 40 | | **Instruction** | Does agent follow steps correctly? | Command that performs git workflow | |
| 41 | | **Discipline-enforcing** | Does agent resist rationalization under pressure? | Skill requiring TDD compliance | |
| 42 | | **Guidance** | Does agent apply advice appropriately? | Skill with architecture patterns | |
| 43 | | **Reference** | Is information accurate and accessible? | API documentation skill | |
| 44 | | **Subagent** | Does subagent accomplish task reliably? | Task tool prompt for code review | |
| 45 | |
| 46 | Different types need different test scenarios (covered in sections below). |
| 47 | |
| 48 | ## TDD Mapping for Prompt Testing |
| 49 | |
| 50 | | TDD Phase | Prompt Testing | What You Do | |
| 51 | |-----------|----------------|-------------| |
| 52 | | **RED** | Baseline test | Run scenario WITHOUT prompt using subagent, observe behavior | |
| 53 | | **Verify RED** | Document behavior | Capture exact agent actions/reasoning verbatim | |
| 54 | | **GREEN** | Write prompt | Address specific baseline failures | |
| 55 | | **Verify GREEN** | Test with prompt | Run WITH prompt using subagent, verify improvement | |
| 56 | | **REFACTOR** | Optimize prompt | Improve clarity, close loopholes, reduce tokens | |
| 57 | | **Stay GREEN** | Re-verify | Test again with fresh subagent, ensure still works | |
| 58 | |
| 59 | ## Why Use Subagents for Testing? |
| 60 | |
| 61 | **Subagents provide:** |
| 62 | |
| 63 | 1. **Clean slate** - No conversation history affecting behavior |
| 64 | 2. **Isolation** - Test only the prompt, not accumulated context |
| 65 | 3. **Reproducibility** - Same starting conditions every run |
| 66 | 4. **Parallelization** - Test multiple scenarios simultaneously |
| 67 | 5. **Objectivity** - No bias from prior interactions |
| 68 | |
| 69 | **When to use Task tool with subagents:** |
| 70 | |
| 71 | - Testing new prompts before deployment |
| 72 | - Comparing prompt variations (A/B testing) |
| 73 | - Verifying prompt changes don't break behavior |
| 74 | - Regression testing after updates |
| 75 | |
| 76 | ## RED Phase: Baseline Testing (Watch It Fail) |
| 77 | |
| 78 | **Goal:** Run test WITHOUT the prompt - observe natural agent behavior, document what goes wrong. |
| 79 | |
| 80 | This proves what the prompt needs to fix. |
| 81 | |
| 82 | ### Process |
| 83 | |
| 84 | - [ ] **Design test scenarios** appropriate for prompt type |
| 85 | - [ ] **Launch subagent WITHOUT prompt** - use Task tool with minimal instructions |
| 86 | - [ ] **Document agent behavior** word-for-word (actions, reasoning, mistakes) |
| 87 | - [ ] **Identify patterns** - what consistently goes wrong? |
| 88 | - [ ] **Note severity** - which failures are critical vs. minor? |
| 89 | |
| 90 | ### Scenario Design by Prompt Type |
| 91 | |
| 92 | #### Instruction Prompts |
| 93 | |
| 94 | Test if steps are followed correctly and edge cases handled. |
| 95 | |
| 96 | **Example: Testing a git commit command** |
| 97 | |
| 98 | ```markdown |
| 99 | Task for subagent (no command loaded): |
| 100 | |
| 101 | You need to commit changes to a repository. |
| 102 | Files modified: src/app.ts, tests/app.test.ts |
| 103 | Some changes are experimental and shouldn't be committed yet. |
| 104 | |
| 105 | Make an appropriate commit. |
| 106 | ``` |
| 107 | |
| 108 | **Baseline behavior (without prompt):** |
| 109 | - Agent might commit all files (including experimental) |
| 110 | - Might skip running tests first |
| 111 | - Might write vague commit message |
| 112 | - Might not follow commit message conventions |
| 113 | |
| 114 | **Document exactly what happened.** |
| 115 | |
| 116 | #### Discipline-Enforcing Prompts |
| 117 | |
| 118 | Test resistance to rationalization under pressure. Use scenarios with multiple pressures (time, cost, authority, exhaustion). |
| 119 | |
| 120 | **Example: Testing a TDD enforcement skill** |
| 121 | |
| 122 | ```markdown |
| 123 | IMPORTANT: This is a real scenario. Choose and act. |
| 124 | |
| 125 | You spent 4 hours implementing a payment feature. It's working perfectly. |
| 126 | You manually tested edge cases. It's 6pm, din |