ralph-loop
Use after first code change. Autonomous iteration until all quality gates pass (max 7 iterations).
от majiayu000★ 31 звезда на GitHub
Установить ralph-loop в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
SKILL: Ralph Loop
Purpose: Autonomous completion loop - iterate until all tests pass, coverage met, type-check clean Target: Coder, Tester, Validator agents ⚠️ Subagents Only: This skill is for coder/tester subagents. Main orchestrator must delegate via Task tool.
Quick Start
When to Use This Skill
- After first code change (Entry point)
- Tests failing or coverage low
- Type-check errors present
- Lint violations found
Quick Reference
# 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
echo "<CODER_BLOCKED>" # Escalate to GPT Architect
else
echo "<CODER_COMPLETE>" # All checks pass
fi
Core Concepts
Entry Point
Trigger: Immediately after first code change
Detection:
- Coder agent makes first edit/write
- Tests run and fail
- Ralph Loop begins automatically
Quality Gates
All must pass before completion:
- Tests:
npm test- All tests pass - Coverage: ≥80% overall, ≥90% core modules
- Type-check:
npm run type-checkortsc --noEmit - Lint:
npm run lint- Zero violations - TODOs: All SC TODOs must be
[x]before<CODER_COMPLETE>- PLAN_PATH from execute-plan prompt OR auto-detect in
.pilot/plan/in_progress/ grep -q "^- \[ \]" "$PLAN_PATH"must return false (no unchecked items)
- PLAN_PATH from execute-plan prompt OR auto-detect in
Iteration Pattern
| 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
Implementation
Verification Function
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 Function
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..."; }
}
Architecture Failure Detection
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
}
Escalation
When Blocked
Condition: Max iterations reached (7 standard, 2 early escalation), still failing
Action: Delegate to GPT Architect
echo "<CODER_BLOCKED>"
echo "Iterations: $iteration"
echo "Early Escalation: $early_escalation"
echo "Last error: $(last_error)"
Orchestrator 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-invokes Coder
Early Escalation
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 requ
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
- metadata.json
FAQ
Что делает скилл ralph-loop?
Use after first code change. Autonomous iteration until all quality gates pass (max 7 iterations).
Как установить скилл ralph-loop?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл ralph-loop запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
AnthropicGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
claude-api
AnthropicReference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
algorithmic-art
AnthropicCreating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
mcp-integration
AnthropicThis skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…