ワンクリックで
ralph-loop
Use after first code change. Autonomous iteration until all quality gates pass (max 7 iterations).
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Use after first code change. Autonomous iteration until all quality gates pass (max 7 iterations).
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
Coordinate specialized teammates in Agent Teams for execution, review, and planning. Delegate mode mandatory with TaskCompleted/TeammateIdle hooks.
Plan completion workflow - archive plan, verify todos, create git commit, push with retry. Use for finalizing completed plans.
Plan confirmation workflow - extract plan from conversation, create file, auto-review with Interactive Recovery. Use for confirming plans after /00_plan.
Plan execution workflow - parallel SC implementation, worktree mode, verification patterns, GPT delegation. Use for executing plans with TDD + Ralph Loop.
Use when blocked, stuck, or needing fresh perspective. Consults GPT experts via Codex CLI with graceful fallback.
Coordinate independent teammates concurrently in Agent Teams for 50-70% speedup. Launch multiple teammates simultaneously.
| name | ralph-loop |
| description | Use after first code change. Autonomous iteration until all quality gates pass (max 7 iterations). |
Purpose: Autonomous completion loop - iterate until all tests pass, coverage met, type-check clean Target: Coder, Tester, Validator teammates ⚠️ Teammates Only: This skill is for coder/tester teammates in Agent Teams. Team Lead spawns teammates who execute this loop autonomously.
# Ralph Loop: Autonomous iteration
iteration=0
max_iterations=7
early_escalation=false
# Check for --early flag or architecture-related failure
if [[ "$*" == *"--early"* ]] || is_architecture_failure; then
max_iterations=2
early_escalation=true
fi
while [ $iteration -lt $max_iterations ]; do
echo "Iteration $((iteration + 1))/$max_iterations"
# Run verification
if run_all_checks; then
echo "✓ All quality gates passed"
break
fi
# Fix failures
fix_failures
# Update state
update_state "$SC" "in_progress" $((iteration + 1))
((iteration++))
done
# Complete or escalate
if [ $iteration -eq $max_iterations ]; then
# Message Team Lead for GPT Architect escalation
echo "Max iterations reached. Messaging Team Lead for GPT Architect escalation..."
else
echo "<CODER_COMPLETE>" # All checks pass
fi
Trigger: Immediately after first code change
Detection:
All must pass before completion:
npm test - All tests passnpm run type-check or tsc --noEmitnpm run lint - Zero violations[x] before <CODER_COMPLETE>
.pilot/plan/in_progress/grep -q "^- \[ \]" "$PLAN_PATH" must return false (no unchecked items)| Mode | Max Iter | Trigger | Escalation |
|---|---|---|---|
| Standard | 7 | Default (after failed attempts) | GPT Architect at iteration 7 |
| Early | 2 | --early flag OR architecture failure | GPT Architect at iteration 2 |
Triggers for Early Escalation: --early flag OR architecture keywords (architecture, tradeoff, design, scalability, pattern, choice) OR confidence < 0.5 (see @.claude/skills/gpt-delegation/SKILL.md)
Flow: Code change → Run checks → All pass? → Complete : Check trigger → Fix → Repeat (max iterations) → Escalate to GPT Architect if blocked
run_all_checks() {
# Tests
npm test || return 1
# Coverage (≥80%)
coverage=$(npm test -- --coverage 2>&1 | grep -oP 'Lines\s+:\s+\K[\d.]+')
(( $(echo "$coverage < 80" | bc -l) )) && return 1
# Type-check
npm run type-check || return 1
# Lint
npm run lint || return 1
# TODOs (PLAN_PATH from execute-plan OR auto-detect)
PLAN_PATH="${PLAN_PATH:-$(find .pilot/plan/in_progress -name "*.md" -type f | head -1)}"
if [ -f "$PLAN_PATH" ]; then
grep -q "^- \[ \]" "$PLAN_PATH" && return 1
fi
return 0
}
fix_failures() {
# Priority: tests → type-check → lint → coverage
npm test || { echo "Fixing test failures..."; }
npm run type-check || { echo "Fixing type errors..."; }
npm run lint || { echo "Fixing lint violations..."; }
}
is_architecture_failure() {
# Check for architecture keywords in error output
local error_log=$(last_error 2>/dev/null || echo "")
local arch_keywords="architecture|tradeoff|design|scalability|pattern|choice"
if echo "$error_log" | grep -qiE "$arch_keywords"; then
return 0 # True
fi
# Check confidence score (see @.claude/skills/gpt-delegation/SKILL.md)
# confidence = 1.0 - (architecture_keywords * 0.3) - (multiple_approaches * 0.2) - (uncertainty_markers * 0.2)
# If confidence < 0.5, trigger early escalation
return 1 # False
}
Condition: Max iterations reached (7 standard, 2 early escalation), still failing
Action: Teammate messages the team lead for GPT Architect escalation
# Teammate uses Message tool to communicate with Team Lead
echo "Messaging Team Lead for escalation..."
echo "Iterations: $iteration"
echo "Early Escalation: $early_escalation"
echo "Last error: $(last_error)"
# Message: "BLOCKED after $iteration iterations. Need GPT Architect for: $(last_error)"
Team Lead handles escalation: Reads .claude/rules/delegator/prompts/architect.md, builds delegation prompt with history, calls codex-sync.sh (workspace-write mode), applies GPT recommendations, re-spawns teammate
Purpose: Rapid escalation for architecture-related failures (max 2 iterations instead of 7)
Triggers: 1) --early flag (explicit request), 2) Architecture keywords in errors (architecture, tradeoff, design, scalability, pattern, choice), 3) Low confidence < 0.5 (see @.claude/skills/gpt-delegation/SKILL.md rubric)
Behavior: Faster delegation to GPT Architect, ideal for complex design decisions requiring expert input
PROHIBITED Phrases: "I cannot", "Too complex", "Out of scope", "Unable to"
Required Pattern: on_blocker_detected → GPT delegation → User collaboration (never "give up")
Details: @.claude/skills/ralph-loop/REFERENCE.md - Full enforcement algorithm
Internal: @.claude/skills/ralph-loop/REFERENCE.md - Advanced patterns, state machine details | @.claude/skills/tdd/SKILL.md - Red-Green-Refactor cycle | @.claude/skills/gpt-delegation/SKILL.md - GPT escalation patterns
External: The Pragmatic Programmer | Working Effectively with Legacy Code
Version: claude-pilot 4.4.50