test-subagent-driven-development.sh 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. #!/usr/bin/env bash
  2. # Test: subagent-driven-development skill
  3. # Verifies that the skill is loaded and follows correct workflow
  4. #
  5. # No drill coverage: this test asks the agent to *describe* SDD (string-
  6. # matches its verbal explanation against expected keywords like
  7. # "self-review", "skeptical", "worktree", "Step 1", "loop"). Drill scenarios
  8. # test behavior (real subagent dispatch, plan-following, review loops),
  9. # not description-recall. Kept by design.
  10. set -euo pipefail
  11. SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
  12. source "$SCRIPT_DIR/test-helpers.sh"
  13. CLAUDE_PROMPT_TIMEOUT="${CLAUDE_PROMPT_TIMEOUT:-90}"
  14. echo "=== Test: subagent-driven-development skill ==="
  15. echo ""
  16. # Test 1: Verify skill can be loaded
  17. echo "Test 1: Skill loading..."
  18. output=$(run_claude "What is the subagent-driven-development skill? Describe its key steps briefly." "$CLAUDE_PROMPT_TIMEOUT")
  19. if assert_contains "$output" "subagent-driven-development\|Subagent-Driven Development\|Subagent Driven" "Skill is recognized"; then
  20. : # pass
  21. else
  22. exit 1
  23. fi
  24. if assert_contains "$output" "Load Plan\|read.*plan\|extract.*tasks" "Mentions loading plan"; then
  25. : # pass
  26. else
  27. exit 1
  28. fi
  29. echo ""
  30. # Test 2: Verify skill describes correct workflow order
  31. echo "Test 2: Workflow ordering..."
  32. output=$(run_claude "In the subagent-driven-development skill, what comes first: spec compliance review or code quality review? Answer using exactly this structure:
  33. First: <review type>
  34. Second: <review type>" "$CLAUDE_PROMPT_TIMEOUT")
  35. if assert_order "$output" "First:.*spec.*compliance" "Second:.*code.*quality" "Spec compliance before code quality"; then
  36. : # pass
  37. else
  38. exit 1
  39. fi
  40. echo ""
  41. # Test 3: Verify self-review is mentioned
  42. echo "Test 3: Self-review requirement..."
  43. output=$(run_claude "Does the subagent-driven-development skill require implementers to self-review before handoff, and can self-review replace the external reviews? Answer using exactly this structure:
  44. Self-review required: <yes or no>
  45. Self-review replaces external review: <yes or no>" "$CLAUDE_PROMPT_TIMEOUT")
  46. if assert_contains "$output" "Self-review required:.*yes" "Mentions self-review"; then
  47. : # pass
  48. else
  49. exit 1
  50. fi
  51. if assert_contains "$output" "Self-review replaces external review:.*no" "Self-review does not replace external review"; then
  52. : # pass
  53. else
  54. exit 1
  55. fi
  56. echo ""
  57. # Test 4: Verify plan is read once
  58. echo "Test 4: Plan reading efficiency..."
  59. output=$(run_claude "In subagent-driven-development, how many times should the controller read the plan file? When does this happen?" "$CLAUDE_PROMPT_TIMEOUT")
  60. if assert_contains "$output" "once\|one time\|single" "Read plan once"; then
  61. : # pass
  62. else
  63. exit 1
  64. fi
  65. if assert_contains "$output" "Step 1\|beginning\|start\|Load Plan" "Read at beginning"; then
  66. : # pass
  67. else
  68. exit 1
  69. fi
  70. echo ""
  71. # Test 5: Verify spec compliance reviewer is skeptical
  72. echo "Test 5: Spec compliance reviewer mindset..."
  73. output=$(run_claude "What is the spec compliance reviewer's attitude toward the implementer's report in subagent-driven-development?" "$CLAUDE_PROMPT_TIMEOUT")
  74. if assert_contains "$output" "not trust\|don't trust\|skeptical\|verify.*independently\|suspiciously" "Reviewer is skeptical"; then
  75. : # pass
  76. else
  77. exit 1
  78. fi
  79. if assert_contains "$output" "read.*code\|inspect.*code\|verify.*code" "Reviewer reads code"; then
  80. : # pass
  81. else
  82. exit 1
  83. fi
  84. echo ""
  85. # Test 6: Verify review loops
  86. echo "Test 6: Review loop requirements..."
  87. output=$(run_claude "In subagent-driven-development, what happens if a reviewer finds issues? Is it a one-time review or a loop?" "$CLAUDE_PROMPT_TIMEOUT")
  88. if assert_contains "$output" "loop\|again\|repeat\|until.*approved\|until.*compliant" "Review loops mentioned"; then
  89. : # pass
  90. else
  91. exit 1
  92. fi
  93. if assert_contains "$output" "implementer.*fix\|fix.*issues" "Implementer fixes issues"; then
  94. : # pass
  95. else
  96. exit 1
  97. fi
  98. echo ""
  99. # Test 7: Verify full task text is provided
  100. echo "Test 7: Task context provision..."
  101. output=$(run_claude "In subagent-driven-development, how does the controller provide task information to the implementer subagent? Answer using exactly this structure:
  102. Controller provides: <directly or by file>
  103. Implementer must read plan file: <yes or no>" "$CLAUDE_PROMPT_TIMEOUT")
  104. if assert_contains "$output" "provide.*directly\|full.*text\|paste\|include.*prompt" "Provides text directly"; then
  105. : # pass
  106. else
  107. exit 1
  108. fi
  109. if assert_contains "$output" "Implementer must read plan file:.*no" "Doesn't make subagent read file"; then
  110. : # pass
  111. else
  112. exit 1
  113. fi
  114. echo ""
  115. # Test 8: Verify worktree requirement
  116. echo "Test 8: Worktree requirement..."
  117. output=$(run_claude "What workflow skills are required before using subagent-driven-development? List any prerequisites or required skills." "$CLAUDE_PROMPT_TIMEOUT")
  118. if assert_contains "$output" "using-git-worktrees\|worktree" "Mentions worktree requirement"; then
  119. : # pass
  120. else
  121. exit 1
  122. fi
  123. echo ""
  124. # Test 9: Verify main branch warning
  125. echo "Test 9: Main branch red flag..."
  126. output=$(run_claude "In subagent-driven-development, is it okay to start implementation directly on the main branch?" "$CLAUDE_PROMPT_TIMEOUT")
  127. if assert_contains "$output" "worktree\|feature.*branch\|not.*main\|never.*main\|avoid.*main\|don't.*main\|consent\|permission" "Warns against main branch"; then
  128. : # pass
  129. else
  130. exit 1
  131. fi
  132. echo ""
  133. echo "=== All subagent-driven-development skill tests passed ==="