Comprehensive developer toolkit providing reusable skills for Java/Spring Boot, TypeScript/NestJS/React/Next.js, Python, PHP, AWS CloudFormation, AI/RAG, DevOps, and more.
90
90%
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Risky
Do not use without reviewing
This document describes the Ralph Loop state machine so it can be implemented by any CLI (Claude Code, Copilot CLI, Codex CLI, Gemini CLI, OpenCode CLI).
One /loop invocation = one step. The state machine is implemented as a state file (fix_plan.json). Each invocation reads the current state, executes one step, updates the state, and stops.
fix_plan.json and stop immediately. Do NOT prompt the user with "Do you want to proceed?" or present confirmation options.--no-confirm on sub-commands: When invoking task-review (or any other interactive command) inside the loop, always pass --no-confirm so it does not block waiting for user input.fix_plan.json and continue automatically.All state lives in docs/specs/[id]/_ralph_loop/fix_plan.json.
{
"spec_id": "001-feature",
"spec_folder": "docs/specs/001-feature/",
"task_range": {
"from": "TASK-036",
"to": "TASK-041",
"from_num": 36,
"to_num": 41,
"total_in_range": 6
},
"state": {
"step": "implementation",
"current_task": "TASK-036",
"current_task_file": "docs/specs/001-feature/tasks/TASK-036.md",
"current_task_lang": "spring",
"iteration": 1,
"retry_count": 0,
"last_updated": "2026-03-25T10:30:00",
"error": null,
"range_progress": {
"done_in_range": 0,
"total_in_range": 6
}
},
"tasks": [...],
"done": [],
"pending": [],
"optional": [],
"superseded": [],
"learnings": []
}init ──────────────────────────► choose_task ────────────────────► complete
│ ▲
▼ │
implementation │
│ │
▼ │
review ─────── issues ───► fix ◄────────────┤
│ │ │
clean ▼ ▼ │
cleanup ─────────────────────────────────────┤
│ │
▼ │
sync ───────────────────────────────────────┤
│ │
▼ │
update_done ─────────────────────────────────────┘
│
▼
failed (stop)
↑
└─ retry > 3When: --action=start or fix_plan.json doesn't exist.
Actions:
docs/specs/[id]/tasks/TASK-*.mdid, title, status, lang, dependencies, complexity--from-task and --to-task to set task_rangefrom_num or > to_numstate.step = "choose_task"fix_plan.jsonOutput:
Ralph Loop | Step: init | Range: TASK-036→TASK-041
→ Found 6 tasks in range
→ Initialized fix_plan.json
→ Next: choose_taskWhen: state.step = "choose_task"
Actions:
pending tasks to only those within task_rangedone arraystate.step = "complete"state.current_task, state.current_task_file, state.current_task_langstate.step = "implementation"state.retry_count = 0Output:
Ralph Loop | Step: choose_task | Iteration: 3
→ Selected: TASK-037 "Implement caching layer"
→ Dependencies: satisfied
→ Next: implementationWhen: state.step = "implementation"
Actions:
/specs:task-implementation --lang=LANG --task="TASK-FILE"state.step = "review"state.step = "failed"state.error = "implementation failed"Output:
Ralph Loop | Step: implementation | Task: TASK-037
→ Running /specs:task-implementation --lang=spring --task="docs/specs/001-feature/tasks/TASK-037.md"
→ Success → Next: reviewWhen: state.step = "review"
Actions:
--no-confirm to prevent interactive blocking:
/specs:task-review --no-confirm --lang=LANG "TASK-FILE"TASK-FILE--review.md) to determine pass/failstate.step = "cleanup"state.retry_countretry_count >= 3:
state.step = "failed"state.error = "review failed after 3 retries"state.step = "fix"Output:
Ralph Loop | Step: review | Task: TASK-037 | Retry: 1/3
→ Running /specs:task-review --no-confirm --lang=spring "docs/specs/001-feature/tasks/TASK-037.md"
→ Reading review report
→ Clean → Next: cleanupWhen: state.step = "fix"
Actions:
docs/specs/[id]/tasks/TASK-XXX--review.md/specs:task-implementation --lang=LANG --task="TASK-FILE" (the task implementation command should read the review report and apply fixes)state.step = "review"state.step = "failed"state.error = "fix failed"Output:
Ralph Loop | Step: fix | Task: TASK-037 | Retry: 1/3
→ Reading review report: docs/specs/001-feature/tasks/TASK-037--review.md
→ Fixes applied → Next: reviewWhen: state.step = "cleanup"
Actions:
--no-confirm:
/specs:code-cleanup --no-confirm --lang=LANG --task="TASK-FILE"state.step = "sync"Output:
Ralph Loop | Step: cleanup | Task: TASK-037
→ Running /specs:code-cleanup --no-confirm --lang=spring --task="docs/specs/001-feature/tasks/TASK-037.md"
→ Cleanup complete → Next: syncWhen: state.step = "sync"
Actions:
/specs:spec-sync-with-code SPEC-FOLDER/ --after-task=TASK-IDstate.step = "update_done"Output:
Ralph Loop | Step: sync | Task: TASK-037
→ Running /specs:spec-sync-with-code docs/specs/001-feature/ --after-task=TASK-037
→ Sync complete → Next: update_doneWhen: state.step = "update_done"
Actions:
status: completed, completed_date: YYYY-MM-DDfix_plan.json:
pending to donestate.iterationstate.range_progress.done_in_rangestate.last_updateddone, if yes set dependencies_satisfied = truegit add -A && git commit -m "Ralph iteration N: TASK-ID [title]"state.step = "choose_task"Output:
Ralph Loop | Step: update_done | Task: TASK-037
→ Marked TASK-037 done
→ Progress: 2/6 in range (33%)
→ Iteration: 3
→ Next: choose_taskWhen: state.step = "complete"
Actions: Print completion summary and stop:
Ralph Loop | COMPLETE
═══════════════════════════════════════════════════════
Task Range: TASK-036 → TASK-041
Tasks Completed: 6/6
Total Iterations: 18
Deviations Detected: N
Learnings Captured: N
Run --action=start with a new range to continue.When: state.step = "failed"
Actions: Print error and stop:
Ralph Loop | FAILED
═══════════════════════════════════════════════════════
Task: TASK-037
Error: review failed after 3 retries
Fix the issues manually, then resume:
/developer-kit-specs:specs.ralph-loop --action=loop --spec=docs/specs/001-feature/Create docs/specs/[id]/_ralph_loop/run-ralph.sh:
#!/bin/bash
# Ralph Loop State Machine — CLI-Agnostic
# One invocation = one step
SPEC_FOLDER="$1"
FIX_PLAN="$SPEC_FOLDER/_ralph_loop/fix_plan.json"
# Read current step
STEP=$(jq -r '.state.step' "$FIX_PLAN")
TASK=$(jq -r '.state.current_task // "none"' "$FIX_PLAN")
ITERATION=$(jq -r '.state.iteration // 0' "$FIX_PLAN")
echo "Ralph Loop | Iteration: $ITERATION | Step: $STEP | Task: $TASK"
case "$STEP" in
init)
echo "→ Initializing... (already done)"
jq '.state.step = "choose_task"' "$FIX_PLAN" > tmp.json && mv tmp.json "$FIX_PLAN"
;;
choose_task)
# Pick next task within range
# (Implementation: filter pending, check deps, pick simplest)
NEXT=$(jq -r '.pending | .[0]' "$FIX_PLAN" 2>/dev/null)
if [ "$NEXT" = "null" ] || [ -z "$NEXT" ]; then
echo "→ No more tasks in range"
jq '.state.step = "complete"' "$FIX_PLAN" > tmp.json && mv tmp.json "$FIX_PLAN"
else
TASK_FILE=$(jq -r ".tasks[] | select(.id == \"$NEXT\") | .file" "$FIX_PLAN")
TASK_LANG=$(jq -r ".tasks[] | select(.id == \"$NEXT\") | .lang" "$FIX_PLAN")
echo "→ Selected: $NEXT"
jq --arg t "$NEXT" --arg f "$TASK_FILE" --arg l "$TASK_LANG" \
'.state.current_task = $t | .state.current_task_file = $f | .state.current_task_lang = $l | .state.step = "implementation" | .state.retry_count = 0' \
"$FIX_PLAN" > tmp.json && mv tmp.json "$FIX_PLAN"
fi
;;
implementation)
echo "→ [IMPLEMENTATION: Run task-implementation for $TASK]"
# In real implementation: call the actual command
jq '.state.step = "review"' "$FIX_PLAN" > tmp.json && mv tmp.json "$FIX_PLAN"
;;
review)
echo "→ [REVIEW: Run task-review for $TASK]"
# In real implementation: check results, on issues go to fix, on clean go to cleanup
jq '.state.step = "cleanup"' "$FIX_PLAN" > tmp.json && mv tmp.json "$FIX_PLAN"
;;
cleanup)
echo "→ [CLEANUP: Run code-cleanup for $TASK]"
# In real implementation: call the actual command
jq '.state.step = "sync"' "$FIX_PLAN" > tmp.json && mv tmp.json "$FIX_PLAN"
;;
fix)
echo "→ [FIX: Apply fixes for $TASK based on review report]"
# In real implementation: call the actual command or edit files
jq '.state.step = "review"' "$FIX_PLAN" > tmp.json && mv tmp.json "$FIX_PLAN"
;;
sync)
echo "→ [SYNC: Run spec-sync-with-code for $TASK]"
# In real implementation: call the actual command
jq '.state.step = "update_done"' "$FIX_PLAN" > tmp.json && mv tmp.json "$FIX_PLAN"
;;
update_done)
echo "→ [UPDATE_DONE: Marking $TASK as done]"
jq --arg t "$TASK" \
'.done += [$t] | .pending -= [$t] | .state.iteration += 1 | .state.step = "choose_task"' \
"$FIX_PLAN" > tmp.json && mv tmp.json "$FIX_PLAN"
;;
complete)
echo "═══════════════════════════════════════════════"
echo "Ralph Loop COMPLETE"
echo "═══════════════════════════════════════════════"
;;
failed)
echo "═══════════════════════════════════════════════"
echo "Ralph Loop FAILED"
ERROR=$(jq -r '.state.error // "unknown"' "$FIX_PLAN")
echo "Error: $ERROR"
echo "═══════════════════════════════════════════════"
;;
esac
echo ""# Start and loop (Claude Code)
/loop 5m /developer-kit-specs:specs.ralph-loop --action=start --spec=docs/specs/001-feature/ --from-task=TASK-036 --to-task=TASK-041
/loop 5m /developer-kit-specs:specs.ralph-loop --action=loop --spec=docs/specs/001-feature/ --from-task=TASK-036 --to-task=TASK-041Claude Code's /loop skill will repeatedly invoke this skill until state.step = "complete" or state.step = "failed".
cd docs/specs/001-feature/_ralph_loop/
# Claude Code
while :; do claude "Execute one step of Ralph Loop. Read fix_plan.json, run the current step, update state, and stop."; done
# Copilot CLI
while :; do copilot "Execute one step of Ralph Loop. Read fix_plan.json, run the current step, update state, and stop."; done
# Codex CLI
while :; do codex "Execute one step of Ralph Loop. Read fix_plan.json, run the current step, update state, and stop."; donedocs
plugins
developer-kit-ai
developer-kit-aws
agents
docs
skills
aws
aws-cli-beast
aws-cost-optimization
aws-drawio-architecture-diagrams
aws-sam-bootstrap
aws-cloudformation
aws-cloudformation-auto-scaling
aws-cloudformation-bedrock
aws-cloudformation-cloudfront
aws-cloudformation-cloudwatch
aws-cloudformation-dynamodb
aws-cloudformation-ec2
aws-cloudformation-ecs
aws-cloudformation-elasticache
references
aws-cloudformation-iam
references
aws-cloudformation-lambda
aws-cloudformation-rds
aws-cloudformation-s3
aws-cloudformation-security
aws-cloudformation-task-ecs-deploy-gh
aws-cloudformation-vpc
references
developer-kit-core
agents
commands
skills
developer-kit-devops
developer-kit-java
agents
commands
docs
skills
aws-lambda-java-integration
aws-rds-spring-boot-integration
aws-sdk-java-v2-bedrock
aws-sdk-java-v2-core
aws-sdk-java-v2-dynamodb
aws-sdk-java-v2-kms
aws-sdk-java-v2-lambda
aws-sdk-java-v2-messaging
aws-sdk-java-v2-rds
aws-sdk-java-v2-s3
aws-sdk-java-v2-secrets-manager
clean-architecture
graalvm-native-image
langchain4j-ai-services-patterns
references
langchain4j-mcp-server-patterns
references
langchain4j-rag-implementation-patterns
references
langchain4j-spring-boot-integration
langchain4j-testing-strategies
langchain4j-tool-function-calling-patterns
langchain4j-vector-stores-configuration
references
qdrant
references
spring-ai-mcp-server-patterns
spring-boot-actuator
spring-boot-cache
spring-boot-crud-patterns
spring-boot-dependency-injection
spring-boot-event-driven-patterns
spring-boot-openapi-documentation
spring-boot-project-creator
spring-boot-resilience4j
spring-boot-rest-api-standards
spring-boot-saga-pattern
spring-boot-security-jwt
assets
references
scripts
spring-boot-test-patterns
spring-data-jpa
references
spring-data-neo4j
references
unit-test-application-events
unit-test-bean-validation
unit-test-boundary-conditions
unit-test-caching
unit-test-config-properties
references
unit-test-controller-layer
unit-test-exception-handler
references
unit-test-json-serialization
unit-test-mapper-converter
references
unit-test-parameterized
unit-test-scheduled-async
references
unit-test-service-layer
references
unit-test-utility-methods
unit-test-wiremock-rest-api
references
developer-kit-php
developer-kit-project-management
developer-kit-python
developer-kit-specs
commands
docs
hooks
test-templates
tests
skills
developer-kit-tools
developer-kit-typescript
agents
docs
hooks
rules
skills
aws-cdk
aws-lambda-typescript-integration
better-auth
clean-architecture
drizzle-orm-patterns
dynamodb-toolbox-patterns
references
nestjs
nestjs-best-practices
nestjs-code-review
nestjs-drizzle-crud-generator
nextjs-app-router
nextjs-authentication
nextjs-code-review
nextjs-data-fetching
nextjs-deployment
nextjs-performance
nx-monorepo
react-code-review
react-patterns
shadcn-ui
tailwind-css-patterns
tailwind-design-system
references
turborepo-monorepo
typescript-docs
typescript-security-review
zod-validation-utilities
references
github-spec-kit