Execute current ready phase with Ralph TDD loop
Executes ready phases using automated TDD workflow with quality gates and plan updates.
/plugin marketplace add Henry229/alsso-plugin/plugin install henry229-auto-tdd-executor-auto-tdd-executor@Henry229/alsso-pluginReady 상태인 phase를 TDD 루프로 실행합니다.
ISSUE_ID=$(bd ready --json 2>/dev/null | jq -r '.[0].id // empty')
ISSUE_TITLE=$(bd ready --json 2>/dev/null | jq -r '.[0].title // empty')
if [ -z "$ISSUE_ID" ]; then
echo "❌ No ready phases. Run 'bd list' to see all issues."
exit 0
fi
echo "📋 Phase: $ISSUE_TITLE ($ISSUE_ID)"
bd update "$ISSUE_ID" --status in_progress
if [ -f "package.json" ]; then
TEST_CMD="npm test"
LINT_CMD="npm run lint"
TYPE_CMD="npm run type-check"
BUILD_CMD="npm run build"
E2E_CMD="npm run test:e2e 2>/dev/null || npx playwright test"
fi
Get the issue info and build TDD prompt:
# Re-fetch issue info (variables don't persist between bash calls)
ISSUE_ID=$(bd ready --json 2>/dev/null | jq -r '.[0].id // empty')
ISSUE_TITLE=$(bd ready --json 2>/dev/null | jq -r '.[0].title // empty')
# Detect project commands
if [ -f "package.json" ]; then
TEST_CMD="npm test"
LINT_CMD="npm run lint"
TYPE_CMD="npm run type-check"
BUILD_CMD="npm run build"
fi
# Build the TDD prompt
RALPH_PROMPT="═══ PHASE: $ISSUE_TITLE ═══
Issue: $ISSUE_ID
CONTEXT RECOVERY:
bd show $ISSUE_ID
Read plan file: docs/plans/PLAN_*.md (find matching plan file)
TDD WORKFLOW:
🔴 RED: Write failing tests → Run: $TEST_CMD → Expect FAIL
➡ Update plan: Check off RED tasks in plan file
🟢 GREEN: Implement code → Run: $TEST_CMD → Expect PASS
➡ Update plan: Check off GREEN tasks in plan file
🔵 REFACTOR:
Use Task tool with subagent_type='auto-tdd-executor:tdd-refactor' to refactor.
Then run: $TEST_CMD → Confirm PASS
➡ Update plan: Check off REFACTOR tasks in plan file
QUALITY GATE (MANDATORY - DO NOT SKIP):
⚠️ MUST run this script (NOT manual commands):
Find and run: \$HOME/.claude/plugins/*/auto-tdd-marketplace/auto-tdd-executor/*/scripts/quality-gate.sh --phase '$ISSUE_TITLE'
Or run: find \$HOME/.claude/plugins -name 'quality-gate.sh' -path '*auto-tdd*' -exec {} --phase '$ISSUE_TITLE' \\;
This script:
- Runs all tests, lint, type-check, build
- Auto-updates plan document (QUALITY_GATE + COMPLETE sections)
- Marks Phase as ✅ in Summary table
❌ DO NOT run npm test/lint manually - plan won't update!
VERIFY PLAN UPDATED:
After quality-gate.sh, check plan file:
- Phase Summary table shows ✅ (not ⏳)
- All checkboxes in Phase section are [x]
If NOT updated → run quality-gate.sh again with --phase flag!
ON QUALITY GATE PASS:
Run E2E tests:
Use Task tool with subagent_type='playwright-test-healer'
to run and fix any E2E failures.
If E2E pass:
git add . && git commit -m 'Complete: $ISSUE_TITLE'
git push origin HEAD
bd close $ISSUE_ID --reason 'All gates passed'
<promise>PHASE_COMPLETE</promise>
IF STUCK (30+ iterations):
bd update $ISSUE_ID --notes 'Blocked: [reason]'
<promise>PHASE_COMPLETE</promise>
⚠️ CRITICAL:
- NEVER skip quality-gate.sh script
- NEVER use manual npm commands for quality gate
- ALWAYS verify plan document updated before commit"
# Call ralph-loop setup script directly
RALPH_SCRIPT="$HOME/.claude/plugins/cache/claude-plugins-official/ralph-loop/latest/scripts/setup-ralph-loop.sh"
if [ ! -f "$RALPH_SCRIPT" ]; then
RALPH_SCRIPT="$HOME/.claude/plugins/marketplaces/claude-plugins-official/plugins/ralph-loop/scripts/setup-ralph-loop.sh"
fi
if [ -f "$RALPH_SCRIPT" ]; then
"$RALPH_SCRIPT" "$RALPH_PROMPT" --max-iterations 50 --completion-promise "PHASE_COMPLETE"
else
echo "❌ Error: ralph-loop script not found. Please install ralph-loop plugin."
exit 1
fi
echo ""
echo "═══════════════════════════════════════════════════════════════"
echo "Phase execution completed!"
echo "═══════════════════════════════════════════════════════════════"
bd list
echo ""
echo "Next ready phases:"
bd ready
echo ""
echo "Run '/auto-tdd-run' for next phase"