From ralph
Use this skill when the user invokes "/ralph" to set up a project for the autonomous Ralph loop. Conducts a short PM interview, writes a prose brief plus a story list, and configures the loop's planner cadence. Migrates v1 .ralph/ directories on the fly. Never starts implementing. The user runs `ralph` from a terminal afterward.
How this skill is triggered — by the user, by Claude, or both
Slash command
/ralph:ralphThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Your job in this skill is to **scope** Ralph's autonomous coding loop. Write a **prose brief** that survives across every loop iteration, draft the story list, and decide how often the loop's planner agent should review progress. Then exit. The user runs `ralph` separately.
Your job in this skill is to scope Ralph's autonomous coding loop. Write a prose brief that survives across every loop iteration, draft the story list, and decide how often the loop's planner agent should review progress. Then exit. The user runs ralph separately.
CRITICAL: NEVER start implementing within this session. After setup is complete, tell the user to run ralph from a terminal.
The single most important thing you produce is .ralph/brief.md. It is prose, not bullets. Each loop iteration loads it as the plan-time context. The builder agent reads it before picking a story; the planner agent treats it as read-only ground truth.
Steve Jobs's exit criterion: if you cannot describe the work in two paragraphs, the planning isn't done yet. If you find yourself writing a four-page brief, you don't understand the scope well enough. Go back and ask one more question, or push back to narrow the work.
Before asking the user anything, do this on your own:
CLAUDE.md if it exists in the project root. Note any conventions, patterns, or external context sources mentioned (issue trackers, spec dirs, dashboards, design docs).If .ralph/ already exists, check what's there before proceeding (see "Existing .ralph/" below).
Now ask the user at most three questions, in one round. Don't go back and forth. The exit criterion is 'I can write the brief in two paragraphs'. If you have that already from the user's prompt + discovery, skip questions entirely.
Good questions are about scope edges, invariants, and what to not do:
Bad questions ask for things you should infer or research:
The loop runs a planner agent every Nth iteration. Lower = more PM oversight, higher cost. Pick one:
| Scope size | Cadence | When |
|---|---|---|
| Small (≤4 stories, isolated change) | 3 | Greenfield small features, single-file refactors |
| Medium (5-10 stories) | 5 | Multi-file features, typical CRUD work |
| Large (>10 stories or cross-cutting) | 10 | Big migrations, feature suites |
Defend the cadence in one line within the brief (e.g. 'Cadence 5. Moderate scope, dependencies between stories warrant a mid-run sanity check'). The user can override later by editing .ralph/state.json.
.ralph/brief.mdThis is the artifact that carries plan-time context across every loop iteration. Write it as prose. Two paragraphs minimum, four maximum.
Required sections:
# {Project / Feature Name}
## What we're building
{One paragraph. The shape of the thing. End state described in plain language.
Reference frameworks/files by name where relevant. This is what the builder
reads before every story to remember why it's working.}
## What's out of scope
{One short paragraph or 3-5 bullets. The walls. What we ruled out and why.
This is the most-skipped section and the most valuable one. It stops the
builder from drifting into adjacent work.}
## Invariants
{Bullets. Things that must remain true throughout. Examples:
- "All endpoints stay backwards-compatible, no contract changes"
- "Existing tests must keep passing"
- "No new top-level dependencies without flagging"
- "User-facing copy is owned by {someone}, don't author new strings"}
## Context
{Optional. Links/refs to external sources used during planning: Linear issues,
spec docs, design files. One-liners: pointers, not summaries.}
## Cadence
Planner runs every {N} iterations. {One sentence rationale.}
If you can't fill all four sections meaningfully, you don't have enough context. Go back to Step 2 and ask one more question, or tell the user the scope is too vague to plan.
.ralph/stories.jsonThe to-do list. Story shape stays compatible with v1 so existing tooling works:
{
"project": "Project Name",
"description": "One-line summary",
"stories": [
{
"id": "PROJ-001",
"title": "Short imperative title",
"description": "What this story implements (2-3 sentences). Don't repeat the brief; describe the local change.",
"acceptance_criteria": [
"Verifiable criterion 1",
"Verifiable criterion 2",
"Tests pass"
],
"priority": 1,
"passes": false
}
]
}
Each story must fit in one Claude context window. Right-sized examples:
If you can't describe a story in 2-3 sentences, split it.
priority: 1 runs first. Earlier stories must not depend on later ones. Typical order: data models → services → controllers/routes → UI.
Each criterion must be verifiable, not vague.
Good: "API returns 401 for unauthenticated requests" / "User model has email + password fields" / "Feature test covers the happy path"
Bad: "Works correctly" / "Good UX" / "Handles edge cases"
Always include at least one of: "Tests pass" or "Feature test covers the happy path".
Detect the project type and set sensible defaults:
artisan file present): test command php artisan test --compact or vendor/bin/pest --compactpackage.json): check scripts.testpyproject.toml / setup.py): pytestStory IDs: use a 3-5 letter project prefix + zero-padded number (e.g. TODO-001, INV-014).
.ralph/state.jsonInitial state, picked up by the loop on first run:
{
"version": 2,
"status": "initialized",
"project_dir": "<absolute path>",
"started_at": "<ISO 8601 UTC>",
"updated_at": "<ISO 8601 UTC>",
"iteration": 0,
"last_builder_iteration": 0,
"last_planner_iteration": 0,
"planner_cadence": <number from Step 3>,
"next_role": "builder",
"stories_total": <int>,
"stories_complete": 0,
"stories_incomplete": <int>,
"last_commit": null,
"last_commit_sha": null,
"last_planner_note": null,
"builder_executor": "claude",
"planner_executor": "claude",
"builder_model": "claude-sonnet-4-6",
"planner_model": "claude-opus-4-7",
"total_cost_usd": 0,
"pid": null,
"last_log_path": null,
"migration": null
}
.ralph/progress.txt:
# {Project Name} Progress Log
---
.ralph/learnings.txt (only if it doesn't already exist; preserve across runs):
# {Project Name} Learnings
## Codebase Patterns
(Patterns discovered during implementation will be added here)
## Gotchas
(Project-specific warnings will be added here)
---
.ralph/logs/ directory (empty; the loop populates it).
Update .gitignore to include .ralph if it's not already listed. Create the file if missing.
.ralph/ handlingIf .ralph/ already exists when the user runs /ralph:
brief.md exists. Ask: do they want to (a) keep the brief and add new stories, (b) keep the brief and replace the story list, or (c) start over with a new brief? Preserve learnings.txt by default unless they explicitly say to reset.
brief.md missing but stories.json or roadmap.json present. This is a v1 directory. The loop will auto-migrate on first run, but doing it here gives the user a real brief instead of a stub. Offer: (a) walk through the PM interview now to write a proper brief, then carry the existing stories forward, or (b) skip, let the loop auto-migrate with a stub brief. Recommend (a).
When a v1 .ralph/ is present:
.ralph/roadmap.json (if any) to .ralph/archive/roadmap.v1.json for reference.stories.json content as input. Many of those stories are likely still valid; reuse them where they fit, drop the rest, add new ones from the conversation.brief.md that incorporates what's already been built (read progress.txt and recent git log) plus what's still ahead.learnings.txt and progress.txt.If you encounter an old --roadmap invocation (a phase prompt mentioning <ready>PHASE_READY</ready>), do not honor it. Tell the user that v2 dropped phase mode and that they should describe the whole feature in a single /ralph call. The brief replaces what the roadmap used to do. High-level structure now lives in prose, not in a JSON tree.
Report what was created:
✓ Brief written to .ralph/brief.md ({2 sentences from the brief})
✓ {N} stories in .ralph/stories.json
✓ Planner cadence: every {N} iterations
✓ State initialized in .ralph/state.json
✓ .ralph added to .gitignore
To start the loop, run from a terminal in this directory:
ralph # foreground, watch progress
nohup ralph & # detached, log to nohup.out
tmux new -s ralph 'ralph' # in a tmux session
Useful subcommands:
ralph status current iteration, cost, last commit
ralph tail follow .ralph/progress.txt
ralph stop graceful stop (finishes current iteration)
Do NOT start implementing. The user must run ralph from a terminal.
Creates, edits, and optimizes skills for Claude Code, including drafting, evaluating with test prompts, iterating on performance, and improving skill descriptions for better triggering accuracy.
npx claudepluginhub mischasigtermans/by-mischa --plugin ralph