skills/ralph-preflight/SKILL.md
Pre-flight check for Ralph TUI loops. Validates config, templates, prd.json, and environment before starting a loop. Run after /prd to verify everything is ready. Detects global CLAUDE.md conflicts, validates template variables, and provides launch commands.
npx skillsauth add ansarullahanasz360/cc-guide ralph-preflightInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Fast verification that everything is configured correctly before starting a Ralph loop. Run this after creating a PRD with /prd to validate and launch.
/prd to create a prd.jsonExecute these checks in order. Stop and report if critical issues are found.
Ralph loops can have global ~/.claude/CLAUDE.md override local project CLAUDE.md. Check and warn:
# Check if global CLAUDE.md exists
if [ -f ~/.claude/CLAUDE.md ]; then
echo "WARNING: Global CLAUDE.md exists at ~/.claude/CLAUDE.md"
echo "This may override your local CLAUDE.md during Ralph loops"
wc -l ~/.claude/CLAUDE.md
else
echo "OK: No global CLAUDE.md found"
fi
If global CLAUDE.md exists:
which ralph-tui && ralph-tui --version
# Check tmux (required for persistent sessions)
which tmux && tmux -V
# Check git (required for worktrees)
git --version
Check if .ralph-tui/ has data from a previous run that could interfere:
# Check for existing state
if [ -d .ralph-tui ]; then
echo "Found existing .ralph-tui/ directory"
# Check for progress file with content
if [ -f .ralph-tui/progress.md ] && [ -s .ralph-tui/progress.md ]; then
echo "⚠ progress.md exists with content ($(wc -l < .ralph-tui/progress.md) lines)"
fi
# Check for iteration logs
if [ -d .ralph-tui/iterations ] && [ "$(ls -A .ralph-tui/iterations 2>/dev/null)" ]; then
echo "⚠ iterations/ has $(ls .ralph-tui/iterations | wc -l) log files"
fi
# Check for session state
if [ -f .ralph-tui/state.json ]; then
echo "⚠ state.json exists (previous session state)"
fi
# Check for lock file (Ralph might be running)
if [ -f .ralph-tui.lock ]; then
echo "⚠ .ralph-tui.lock exists - Ralph may be running!"
fi
else
echo "OK: No existing .ralph-tui/ state"
fi
If existing state is found, determine the situation:
AskUserQuestion: "Found existing Ralph state from a previous run. What's the situation?"
├── "Previous run is complete, clean up for new PRD"
│ → Clean .ralph-tui/iterations/, progress.md, state.json
│ → Keep config.toml and templates
├── "Previous run is still active (different PRD)"
│ → Create new worktree for this PRD
│ → Keep current directory untouched
├── "Save progress to branch first, then clean"
│ → Commit current progress
│ → Clean for new PRD
└── "Let me check the progress first"
│ → Show progress.md contents
│ → Show iteration count
│ → Re-ask after review
Cleanup commands (if user chooses to clean):
# Remove iteration logs
rm -rf .ralph-tui/iterations/*
# Clear progress file (keep file, clear content)
echo "" > .ralph-tui/progress.md
# Remove session state
rm -f .ralph-tui/state.json
rm -f .ralph-tui.lock
rm -f .ralph-tui-session.json
# Verify cleanup
ls -la .ralph-tui/
echo "Cleaned. Ready for new Ralph loop."
If previous run is still active:
# Check current branch
CURRENT_BRANCH=$(git branch --show-current)
echo "Current branch: $CURRENT_BRANCH"
# Suggest worktree for new PRD
REPO_NAME=$(basename $(git rev-parse --show-toplevel))
echo "Suggested worktree: ../${REPO_NAME}-[new-prd-name]"
Then proceed to Phase 7 for worktree setup.
# Check project config exists
if [ -f .ralph-tui/config.toml ]; then
echo "OK: Config found at .ralph-tui/config.toml"
else
echo "ERROR: No .ralph-tui/config.toml found"
echo "Run: ralph-tui setup"
fi
Read config.toml and verify critical settings:
| Setting | Required Value | Check |
|---------|---------------|-------|
| tracker | "json" | Must be json for prd.json execution |
| agent | "claude" | Claude agent |
| prompt_template | Path exists | Template file must exist |
| model | "opus" or "sonnet" | Valid model |
| maxIterations | > 0 | Reasonable iteration limit |
ralph-tui template show | head -5
Verify it's loading from expected location (not default).
Get template path from config.toml prompt_template setting and verify file exists:
# Extract template path from config
grep "prompt_template" .ralph-tui/config.toml
# Verify file exists
ls -la [extracted-path]
Read the prompt.hbs and verify it uses these required variables:
PRD Variables:
{{prdName}} - Project name{{prdDescription}} - Project overview{{prdCompletedCount}} / {{prdTotalCount}} - Progress{{currentIteration}} - Current iteration number (REQUIRED in header)Task Variables:
{{taskId}} - Story ID (e.g., US-001){{taskTitle}} - Story title{{taskDescription}} - What and why (includes embedded tasks){{acceptanceCriteria}} - Auto-formatted checkbox list{{notes}} - Additional context{{dependsOn}} - PrerequisitesContext Variables:
{{codebasePatterns}} - Discovered patterns (optional)DEPRECATED (should NOT be in template):
{{recentProgress}} - Agent reads .ralph-tui/progress.md directly as first actionVerify template includes all critical elements:
Structure Checks:
{{recentProgress}} (agent reads file directly - this is redundant){{currentIteration}} in header for tracking.ralph-tui/progress.mdPRD.md in same directory as prd.jsonWorkflow Checks:
Rules Checks:
"type":"message", gibberish)Context References:
Flag these issues if found:
| Issue | Problem | Fix |
|-------|---------|-----|
| {{recentProgress}} in template | Redundant - agent reads file directly | Remove the section |
| No {{currentIteration}} | Can't track which iteration in logs | Add to header |
| No gibberish cleanup instruction | JSON fragments accumulate in progress.md | Add Phase 3 step 7 |
| Simple progress format | Future iterations lack context | Use verbose 4-section format |
| No "start with no memory" warning | Agent may not document thoroughly | Add to rules section |
Search for prd.json files:
find . -name "prd.json" -not -path "*/node_modules/*" 2>/dev/null
If multiple found, ask user to select. If none found, report and exit.
Read the prd.json and verify required fields:
{
"name": "required - kebab-case",
"description": "required - project context",
"branchName": "required - git branch name",
"userStories": [
{
"id": "required - e.g., US-001",
"title": "required - short title",
"description": "required - what and why",
"acceptanceCriteria": "required - array of strings",
"dependsOn": "optional - array of story IDs",
"notes": "optional - additional context",
"passes": "required - boolean, should be false initially"
}
]
}
Verify prd.json fields will map correctly to template:
| prd.json Field | Template Variable | Status |
|----------------|-------------------|--------|
| name | {{prdName}} | Check |
| description | {{prdDescription}} | Check |
| userStories[].id | {{taskId}} | Check |
| userStories[].title | {{taskTitle}} | Check |
| userStories[].description | {{taskDescription}} | Check |
| userStories[].acceptanceCriteria | {{acceptanceCriteria}} | Check |
| userStories[].notes | {{notes}} | Check |
| userStories[].dependsOn | {{dependsOn}} | Check |
Verify each story's description includes embedded tasks:
**Tasks:**
1. First task
2. Second task
WARNING: Tasks are NOT a separate field - they must be in the description.
Verify acceptanceCriteria is an array of strings (Ralph auto-converts to checkboxes).
if [ -f CLAUDE.md ]; then
echo "OK: Local CLAUDE.md found"
# Check it has key sections
grep -l "Commands\|Development\|Project" CLAUDE.md
else
echo "WARNING: No local CLAUDE.md - Ralph will rely on global context"
fi
Check for human-readable PRD document:
find . -name "PRD.md" -o -name "prd.md" | head -5
If found, note the path for the prompt template enhancement.
Verify progress file path from config:
grep "progressFile" .ralph-tui/config.toml
# Default: .ralph-tui/progress.md
Present a clear summary:
═══════════════════════════════════════════════════════════════════════════
Ralph TUI Pre-Flight Check Results
═══════════════════════════════════════════════════════════════════════════
Environment
├── Global CLAUDE.md: ✗ Not found (good) / ⚠ Found (may conflict)
├── Ralph TUI: ✓ v0.x.x installed
├── tmux: ✓ v3.x installed
├── git: ✓ v2.x installed
└── Existing State: ✓ Clean / ⚠ Previous run detected (action taken)
Existing State Details (if found)
├── progress.md: [X lines] / Empty
├── iterations/: [X files] / Empty
├── state.json: Found / Not found
└── Lock file: ⚠ Running / Not found
Configuration (.ralph-tui/config.toml)
├── Tracker: json ✓
├── Agent: claude ✓
├── Model: opus ✓
├── Max Iterations: 70 ✓
├── Template Path: .ralph-tui/templates/prompt.hbs ✓
└── PRD Path: [discovered path] ✓
Template (.ralph-tui/templates/prompt.hbs)
├── File exists: ✓
├── PRD variables: ✓
├── Task variables: ✓
├── Context variables: ✓
├── Workflow section: ✓
└── Completion signals: ✓
PRD (docs/prds/[name]/prd.json)
├── Name: [prd-name] ✓
├── Branch: [branch-name] ✓
├── Stories: [count] stories ✓
├── All have IDs: ✓
├── All have descriptions: ✓
├── All have acceptance criteria: ✓
└── Tasks embedded in descriptions: ✓
Project Context
├── Local CLAUDE.md: ✓ Found
├── PRD.md: ✓ Found at [path]
└── Progress tracking: .ralph-tui/progress.md (clean)
═══════════════════════════════════════════════════════════════════════════
If any issues were found, list them with severity:
Issues Found:
├── [CRITICAL] Global CLAUDE.md may override local context
├── [CRITICAL] Existing Ralph state - may confuse model with old progress
├── [CRITICAL] Lock file present - Ralph may already be running
├── [WARNING] Story US-003 missing tasks in description
└── [INFO] Model set to sonnet, opus recommended for complex work
AskUserQuestion: "How do you want to run this Ralph loop?"
├── "Branch only" - Create/switch to feature branch in current directory
├── "Worktree" - Create isolated worktree for parallel development
└── "Already set up" - Skip branch/worktree setup
# Determine base branch
git branch --show-current
# Create and checkout feature branch
git checkout -b [branchName-from-prd]
# Get repo name and PRD name
REPO_NAME=$(basename $(git rev-parse --show-toplevel))
PRD_NAME=[name-from-prd]
# Create worktree
git worktree add ../${REPO_NAME}-${PRD_NAME} -b [branchName-from-prd]
# Show next steps
echo "Worktree created at: ../${REPO_NAME}-${PRD_NAME}"
echo "cd ../${REPO_NAME}-${PRD_NAME}"
Provide ready-to-copy commands:
═══════════════════════════════════════════════════════════════════════════
Launch Commands
═══════════════════════════════════════════════════════════════════════════
Option 1: Run in new tmux session (recommended)
───────────────────────────────────────────────────────────────────────────
tmux new-session -d -s ralph-[prd-name] "ralph-tui run --prd [prd-path]"
tmux attach-session -t ralph-[prd-name]
# Press 's' to start, then Ctrl+B D to detach
Option 2: Run directly (stays in foreground)
───────────────────────────────────────────────────────────────────────────
ralph-tui run --prd [prd-path]
Option 3: Run with verification (recommended first time)
───────────────────────────────────────────────────────────────────────────
ralph-tui run --prd [prd-path] --verify
Monitoring:
───────────────────────────────────────────────────────────────────────────
# Check progress
cat .ralph-tui/progress.md
# View iteration logs
ralph-tui logs
# Check session status
ralph-tui status
# Reattach to tmux
tmux attach-session -t ralph-[prd-name]
═══════════════════════════════════════════════════════════════════════════
| Variable | Source | Description |
|----------|--------|-------------|
| {{prdName}} | prd.json name | Project name |
| {{prdDescription}} | prd.json description | Project context |
| {{prdCompletedCount}} | Calculated | Completed stories |
| {{prdTotalCount}} | Calculated | Total stories |
| {{currentIteration}} | Calculated | Current iteration number |
| {{taskId}} | userStories[].id | Current story ID |
| {{taskTitle}} | userStories[].title | Current story title |
| {{taskDescription}} | userStories[].description | Story description (includes tasks) |
| {{acceptanceCriteria}} | userStories[].acceptanceCriteria | Auto-formatted checkboxes |
| {{notes}} | userStories[].notes | Additional context |
| {{dependsOn}} | userStories[].dependsOn | Prerequisites |
| {{codebasePatterns}} | .ralph-tui/progress.md | Discovered patterns |
DEPRECATED - Do NOT use:
| Variable | Reason |
|----------|--------|
| {{recentProgress}} | Redundant - agent reads .ralph-tui/progress.md directly as first action every iteration |
| Issue | Solution |
|-------|----------|
| Global CLAUDE.md overrides local | Rename ~/.claude/CLAUDE.md to .bak |
| Existing state from previous run | Clean iterations/, progress.md, state.json OR use worktree |
| Lock file present | Another Ralph may be running; check tmux sessions |
| Template not loading | Check prompt_template path in config.toml |
| Tasks not showing | Embed tasks in description field, not separate |
| acceptanceCriteria empty | Ensure it's an array of strings |
| Progress corrupted | Check .ralph-tui.lock, use ralph-tui resume |
| Model confused by old progress | Clean progress.md before starting new PRD |
| Gibberish/JSON in progress.md | Template should include cleanup instructions in Phase 3 |
| Duplicate progress entries | Ralph auto-appends + agent appends; use cleanup instructions |
| Template uses {{recentProgress}} | Remove it - agent reads file directly (redundant) |
| Missing {{currentIteration}} | Add to header for iteration tracking |
| Sparse progress notes | Use verbose 4-section format; add "no memory" warning |
ralph-tui template show # Show current template
ralph-tui doctor # Diagnose issues
ralph-tui config show # Show merged config
ralph-tui status # Check session status
ralph-tui resume # Resume interrupted session
ralph-tui logs # View iteration logs
development
Decide HOW to run a coding task — interactive, goal mode, or a workflow — then author the launch-ready prompt or goal package for Claude Code, Codex, or Antigravity. Use when the user says "launchpad", "start a goal", "set up a goal/sprint", "should this be a goal or interactive", "plan an autonomous run", "I want to brain-dump a task", "help me write a goal prompt", or is about to kick off a long autonomous run and wants it scoped, delegated, and verifiable first.
development
Use when turning founder requirements, research packets, plans, specs, and system designs into one or more independently executable Claude Code, Cloud Code, or Codex implementation sprints with story writing, review, execution, optional verification, and sprint-level commits.
tools
Interactive Claude Code repository setup and optimization. Configures the complete ecosystem - skills, commands, subagents, hooks, rules, MCPs, and plugins. Invoke with /setup-claude init or /setup-claude audit.
development
Create self-verifying PRDs for autonomous execution. Interviews users to gather requirements, then generates structured prd.json with phased implementation and appropriate testing strategies. Supports 7 task categories with type-specific workflows. Use when user says "create a prd", "prd for", "plan a feature", "plan this", "write prd", or wants to plan any multi-step implementation work.