AgentSkillsCN

ralph-init

以 Ralph 工作流结构(规格、提示、循环脚本)初始化项目。适用于启动新项目,或为现有项目添加 Ralph 工作流时使用。

SKILL.md
--- frontmatter
name: ralph-init
description: Initialize a project with Ralph workflow structure (specs, prompts, loop script). Use when starting a new project or adding Ralph workflow to an existing project.

Ralph Init

Initialize a project with the Ralph workflow for autonomous AI-driven development.

The Ralph Workflow

Ralph is Geoffrey Huntley's loop-based autonomous development methodology.

Three Phases:

  1. Define - Write specs for topics of concern (specs/*.md)
  2. Plan - Gap analysis: compare specs vs code → IMPLEMENTATION_PLAN.md
  3. Build - Implement one task per loop, commit, repeat

Core Principles:

  • Context is everything - Fresh context each iteration, subagents preserve main context
  • Backpressure steers quality - Tests/typechecks/lints reject invalid work
  • Let Ralph Ralph - Trust self-correction through iteration, plans are disposable

Reference: Ralph Playbook

Project Structure

IMPORTANT: Workflow files ALWAYS at project root. Specs in specs/ at root.

code
project/
├── loop.sh                    # Ralph loop script (runs from here)
├── PROMPT_plan.md             # Planning mode prompt
├── PROMPT_build.md            # Building mode prompt
├── IMPLEMENTATION_PLAN.md     # Task list (generated/updated by Ralph)
├── AGENTS.md                  # Operational guide (~60 lines max, brief!)
├── specs/                     # Specifications directory
│   ├── README.md              # Lookup table: spec → code
│   └── [topic].md             # One spec per topic of concern
└── src/                       # Source code
    └── lib/                   # Shared utilities & components

Why root? The loop runs from project root. PROMPTs reference specs/* and @IMPLEMENTATION_PLAN.md. Everything must be accessible from root.

AGENTS.md must stay brief: Operational commands only. No status updates, no progress notes. Those go in IMPLEMENTATION_PLAN.md. A bloated AGENTS.md pollutes every loop's context.

Step 1: Gather Project Info

Ask the user:

  1. Project name - Name for AGENTS.md header
  2. Specs location - Where will specs live? (default: specs/)
  3. Source location - Where is source code? (default: src)
  4. Project goal - One sentence describing what success looks like
  5. Key commands - Build, test, typecheck, lint commands (can leave as placeholders)

Step 2: Copy Templates

Templates location: ~/.claude/skills/ralph-init/templates/

TemplateDestinationNotes
loop.sh./loop.shchmod +x
PROMPT_plan.md./PROMPT_plan.mdReplace {{SPECS_DIR}}, {{SOURCE_DIR}}, {{LIB_DIR}}, {{PROJECT_GOAL}}
PROMPT_build.md./PROMPT_build.mdReplace {{SPECS_DIR}}, {{SOURCE_DIR}}, {{LIB_DIR}}
AGENTS.md./AGENTS.mdReplace all {{...}} placeholders with project commands
IMPLEMENTATION_PLAN.md./IMPLEMENTATION_PLAN.mdEmpty starting point
specs-README.md./specs/README.mdClean lookup table template

CRITICAL: Copy templates VERBATIM. Do NOT improvise. The numbered rules (99999, 999999, etc.) are intentional.

Step 3: Create specs/README.md

The specs README is a lookup table linking specs to code. Follow the Loom pattern:

markdown
# [Project] Specifications

[One-line description]

## [Category Name]

| Spec | Code | Purpose |
|------|------|---------|
| [spec-name.md](./spec-name.md) | [dir/](../src/dir/) | Brief purpose |

Keep it clean:

  • No workflow documentation (that's in PROMPT files)
  • No verbose explanations
  • Just specs linked to code they affect
  • Group by logical category if many specs

Step 4: Make Executable

bash
chmod +x loop.sh

Step 5: Summary

code
Ralph initialized!

Created at project root:
  loop.sh                 - Run with ./loop.sh or ./loop.sh plan
  PROMPT_plan.md          - Planning mode (gap analysis)
  PROMPT_build.md         - Building mode (implementation)
  AGENTS.md               - Operational guide (keep brief!)
  IMPLEMENTATION_PLAN.md  - Task list
  specs/README.md         - Spec index

Usage:
  1. Write specs in specs/
  2. ./loop.sh plan       # Generate implementation plan
  3. Review plan
  4. ./loop.sh            # Start building

Template Placeholders

PlaceholderDescriptionExample
{{PROJECT_NAME}}Project name for AGENTS.mdMy App
{{SPECS_DIR}}Path to specs from rootspecs/
{{SOURCE_DIR}}Path to source codesrc
{{LIB_DIR}}Path to shared utilitiessrc/lib
{{PROJECT_GOAL}}One-sentence success criteria"Build a task management app"
{{TEST_CMD}}Test commandnpm test or [test command]
{{TYPECHECK_CMD}}Typecheck commandnpm run check or [typecheck command]
{{LINT_CMD}}Lint commandnpm run lint or [lint command]
{{BUILD_CMD}}Build commandnpm run build or [build command]
{{DEV_CMD}}Dev server commandnpm run dev or [dev command]