aiblueprint-cli 1.4.15 → 1.4.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -11
- package/claude-code-config/skills/setup-ralph/SKILL.md +117 -0
- package/claude-code-config/skills/setup-ralph/scripts/setup.sh +278 -0
- package/claude-code-config/skills/setup-ralph/steps/step-00-init.md +215 -0
- package/claude-code-config/skills/setup-ralph/steps/step-01-interactive-prd.md +366 -0
- package/claude-code-config/skills/setup-ralph/steps/step-02-create-stories.md +273 -0
- package/claude-code-config/skills/setup-ralph/steps/step-03-finish.md +245 -0
- package/dist/cli.js +153 -558
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -276,17 +276,6 @@ The CLI automatically manages your `~/.claude/settings.json` with:
|
|
|
276
276
|
}
|
|
277
277
|
]
|
|
278
278
|
}
|
|
279
|
-
],
|
|
280
|
-
"PostToolUse": [
|
|
281
|
-
{
|
|
282
|
-
"matcher": "Edit|Write|MultiEdit",
|
|
283
|
-
"hooks": [
|
|
284
|
-
{
|
|
285
|
-
"type": "command",
|
|
286
|
-
"command": "bun ~/.claude/hooks/hook-post-file.ts"
|
|
287
|
-
}
|
|
288
|
-
]
|
|
289
|
-
}
|
|
290
279
|
]
|
|
291
280
|
}
|
|
292
281
|
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: setup-ralph
|
|
3
|
+
description: Setup the Ralph autonomous AI coding loop - ships features while you sleep
|
|
4
|
+
argument-hint: "<project-path> [-i/--interactive] [-f/--feature <name>]"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
<objective>
|
|
8
|
+
Set up the Ralph autonomous coding loop in any project. Ralph runs AI agents in a loop, picking tasks from a PRD, implementing one at a time, committing after each, and accumulating learnings until all tasks are complete.
|
|
9
|
+
|
|
10
|
+
**This skill ONLY sets up Ralph - you run the commands yourself.**
|
|
11
|
+
</objective>
|
|
12
|
+
|
|
13
|
+
<quick_start>
|
|
14
|
+
**Setup Ralph interactively (recommended):**
|
|
15
|
+
```bash
|
|
16
|
+
/setup-ralph -i
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
**Setup for specific feature:**
|
|
20
|
+
```bash
|
|
21
|
+
/setup-ralph -f 01-add-authentication
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
**What this does:**
|
|
25
|
+
1. Creates `.claude/ralph/` structure in your project
|
|
26
|
+
2. Runs setup script to create all Ralph files
|
|
27
|
+
3. (If -i): Brainstorms PRD with you interactively
|
|
28
|
+
4. Transforms PRD into user stories (prd.json)
|
|
29
|
+
5. Shows you the command to run Ralph (you run it yourself)
|
|
30
|
+
|
|
31
|
+
**After setup, you run:**
|
|
32
|
+
```bash
|
|
33
|
+
bun run .claude/ralph/ralph.sh -f <feature-name>
|
|
34
|
+
```
|
|
35
|
+
</quick_start>
|
|
36
|
+
|
|
37
|
+
<critical_rule>
|
|
38
|
+
🛑 NEVER run ralph.sh or any execution commands automatically
|
|
39
|
+
🛑 NEVER execute the loop - only set up files and show instructions
|
|
40
|
+
✅ ALWAYS let the user copy and run commands themselves
|
|
41
|
+
✅ ALWAYS end by showing the exact command to run
|
|
42
|
+
</critical_rule>
|
|
43
|
+
|
|
44
|
+
<when_to_use>
|
|
45
|
+
**Use this skill when:**
|
|
46
|
+
- Starting a new feature that can be broken into small stories
|
|
47
|
+
- Setting up Ralph in a new project
|
|
48
|
+
- Creating a new feature PRD interactively
|
|
49
|
+
|
|
50
|
+
**Don't use for:**
|
|
51
|
+
- Simple single-file changes
|
|
52
|
+
- Exploratory work without clear requirements
|
|
53
|
+
- Major refactors without acceptance criteria
|
|
54
|
+
</when_to_use>
|
|
55
|
+
|
|
56
|
+
<parameters>
|
|
57
|
+
| Flag | Description |
|
|
58
|
+
|------|-------------|
|
|
59
|
+
| `<project-path>` | Path to the project (defaults to current directory) |
|
|
60
|
+
| `-i, --interactive` | Interactive mode: brainstorm PRD with AI assistance |
|
|
61
|
+
| `-f, --feature <name>` | Feature folder name (e.g., `01-add-auth`) |
|
|
62
|
+
|
|
63
|
+
**Examples:**
|
|
64
|
+
```bash
|
|
65
|
+
/setup-ralph /path/to/project -i # Interactive PRD creation
|
|
66
|
+
/setup-ralph . -f 01-add-auth # Setup for specific feature
|
|
67
|
+
/setup-ralph -i -f 02-user-dashboard # Interactive with specific name
|
|
68
|
+
```
|
|
69
|
+
</parameters>
|
|
70
|
+
|
|
71
|
+
<state_variables>
|
|
72
|
+
| Variable | Type | Description |
|
|
73
|
+
|----------|------|-------------|
|
|
74
|
+
| `{project_path}` | string | Absolute path to target project |
|
|
75
|
+
| `{ralph_dir}` | string | Path to .claude/ralph in project |
|
|
76
|
+
| `{feature_name}` | string | Feature folder name (e.g., `01-add-auth`) |
|
|
77
|
+
| `{feature_dir}` | string | Path to task folder |
|
|
78
|
+
| `{interactive_mode}` | boolean | Whether to brainstorm PRD interactively |
|
|
79
|
+
| `{prd_content}` | string | PRD markdown content |
|
|
80
|
+
| `{user_stories}` | array | User stories extracted from PRD |
|
|
81
|
+
| `{branch_name}` | string | Git branch for the feature |
|
|
82
|
+
</state_variables>
|
|
83
|
+
|
|
84
|
+
<entry_point>
|
|
85
|
+
Load `steps/step-00-init.md`
|
|
86
|
+
</entry_point>
|
|
87
|
+
|
|
88
|
+
<step_files>
|
|
89
|
+
| Step | File | Purpose |
|
|
90
|
+
|------|------|---------|
|
|
91
|
+
| 00 | `step-00-init.md` | Parse flags, run setup script, create structure |
|
|
92
|
+
| 01 | `step-01-interactive-prd.md` | Interactive PRD brainstorming and creation |
|
|
93
|
+
| 02 | `step-02-create-stories.md` | Transform PRD into user stories (prd.json) |
|
|
94
|
+
| 03 | `step-03-finish.md` | Show run command (user runs it themselves) |
|
|
95
|
+
</step_files>
|
|
96
|
+
|
|
97
|
+
<scripts>
|
|
98
|
+
| Script | Purpose |
|
|
99
|
+
|--------|---------|
|
|
100
|
+
| `scripts/setup.sh` | Creates all Ralph files in the project |
|
|
101
|
+
</scripts>
|
|
102
|
+
|
|
103
|
+
<execution_rules>
|
|
104
|
+
1. **Progressive Loading**: Load one step at a time
|
|
105
|
+
2. **Script Execution**: Use scripts/setup.sh to create files atomically
|
|
106
|
+
3. **Interactive Mode**: If -i flag, run brainstorming conversation
|
|
107
|
+
4. **State Persistence**: Track progress in feature_dir/progress.txt
|
|
108
|
+
5. **Resume Support**: Detect existing PRD.md and resume from there
|
|
109
|
+
6. **NEVER RUN RALPH**: Only setup and show commands - user runs them
|
|
110
|
+
</execution_rules>
|
|
111
|
+
|
|
112
|
+
<success_criteria>
|
|
113
|
+
✅ Ralph structure created at {project_path}/.claude/ralph
|
|
114
|
+
✅ Feature folder created with PRD.md, prd.json, progress.txt
|
|
115
|
+
✅ User stories properly formatted in prd.json
|
|
116
|
+
✅ Clear run command provided to user (they run it themselves)
|
|
117
|
+
</success_criteria>
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# Ralph Setup Script - Creates all Ralph files atomically
|
|
3
|
+
# Usage: ./setup.sh <project-path> [feature-name]
|
|
4
|
+
|
|
5
|
+
set -e
|
|
6
|
+
|
|
7
|
+
PROJECT_PATH="${1:-.}"
|
|
8
|
+
FEATURE_NAME="${2:-01-feature}"
|
|
9
|
+
|
|
10
|
+
# Resolve absolute path
|
|
11
|
+
PROJECT_PATH=$(cd "$PROJECT_PATH" && pwd)
|
|
12
|
+
RALPH_DIR="$PROJECT_PATH/.claude/ralph"
|
|
13
|
+
TASKS_DIR="$RALPH_DIR/tasks"
|
|
14
|
+
FEATURE_DIR="$TASKS_DIR/$FEATURE_NAME"
|
|
15
|
+
|
|
16
|
+
echo "🚀 Setting up Ralph in: $PROJECT_PATH"
|
|
17
|
+
echo "📁 Feature: $FEATURE_NAME"
|
|
18
|
+
|
|
19
|
+
# Create directory structure
|
|
20
|
+
mkdir -p "$RALPH_DIR"
|
|
21
|
+
mkdir -p "$FEATURE_DIR"
|
|
22
|
+
|
|
23
|
+
# Create ralph.sh (main loop script)
|
|
24
|
+
cat > "$RALPH_DIR/ralph.sh" << 'RALPH_SH'
|
|
25
|
+
#!/bin/bash
|
|
26
|
+
# Ralph - Autonomous AI Coding Loop
|
|
27
|
+
# Usage: ./ralph.sh -f <feature-folder> [-n <max-iterations>]
|
|
28
|
+
|
|
29
|
+
set -e
|
|
30
|
+
|
|
31
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
32
|
+
MAX_ITERATIONS=10
|
|
33
|
+
FEATURE_FOLDER=""
|
|
34
|
+
|
|
35
|
+
# Parse arguments
|
|
36
|
+
while [[ $# -gt 0 ]]; do
|
|
37
|
+
case $1 in
|
|
38
|
+
-f|--feature)
|
|
39
|
+
FEATURE_FOLDER="$2"
|
|
40
|
+
shift 2
|
|
41
|
+
;;
|
|
42
|
+
-n|--max)
|
|
43
|
+
MAX_ITERATIONS="$2"
|
|
44
|
+
shift 2
|
|
45
|
+
;;
|
|
46
|
+
*)
|
|
47
|
+
echo "Unknown option: $1"
|
|
48
|
+
echo "Usage: ./ralph.sh -f <feature-folder> [-n <max-iterations>]"
|
|
49
|
+
exit 1
|
|
50
|
+
;;
|
|
51
|
+
esac
|
|
52
|
+
done
|
|
53
|
+
|
|
54
|
+
if [ -z "$FEATURE_FOLDER" ]; then
|
|
55
|
+
echo "❌ Error: Feature folder required"
|
|
56
|
+
echo "Usage: ./ralph.sh -f <feature-folder> [-n <max-iterations>]"
|
|
57
|
+
echo ""
|
|
58
|
+
echo "Available features:"
|
|
59
|
+
ls -1 "$SCRIPT_DIR/tasks/" 2>/dev/null || echo " No features found. Create one first!"
|
|
60
|
+
exit 1
|
|
61
|
+
fi
|
|
62
|
+
|
|
63
|
+
TASK_DIR="$SCRIPT_DIR/tasks/$FEATURE_FOLDER"
|
|
64
|
+
|
|
65
|
+
if [ ! -d "$TASK_DIR" ]; then
|
|
66
|
+
echo "❌ Error: Feature folder not found: $TASK_DIR"
|
|
67
|
+
echo ""
|
|
68
|
+
echo "Available features:"
|
|
69
|
+
ls -1 "$SCRIPT_DIR/tasks/" 2>/dev/null || echo " No features found"
|
|
70
|
+
exit 1
|
|
71
|
+
fi
|
|
72
|
+
|
|
73
|
+
PRD_FILE="$TASK_DIR/prd.json"
|
|
74
|
+
PROGRESS_FILE="$TASK_DIR/progress.txt"
|
|
75
|
+
PROMPT_FILE="$SCRIPT_DIR/prompt.md"
|
|
76
|
+
|
|
77
|
+
if [ ! -f "$PRD_FILE" ]; then
|
|
78
|
+
echo "❌ Error: prd.json not found in $TASK_DIR"
|
|
79
|
+
exit 1
|
|
80
|
+
fi
|
|
81
|
+
|
|
82
|
+
# Get story counts
|
|
83
|
+
TOTAL_STORIES=$(jq '.userStories | length' "$PRD_FILE")
|
|
84
|
+
COMPLETED=$(jq '[.userStories[] | select(.passes == true)] | length' "$PRD_FILE")
|
|
85
|
+
|
|
86
|
+
echo "╔════════════════════════════════════════════════════════════╗"
|
|
87
|
+
echo "║ 🤖 RALPH STARTING ║"
|
|
88
|
+
echo "╠════════════════════════════════════════════════════════════╣"
|
|
89
|
+
echo "║ Feature: $FEATURE_FOLDER"
|
|
90
|
+
echo "║ Stories: $COMPLETED / $TOTAL_STORIES completed"
|
|
91
|
+
echo "║ Max iterations: $MAX_ITERATIONS"
|
|
92
|
+
echo "╚════════════════════════════════════════════════════════════╝"
|
|
93
|
+
echo ""
|
|
94
|
+
|
|
95
|
+
for ((i=1; i<=$MAX_ITERATIONS; i++)); do
|
|
96
|
+
# Refresh counts
|
|
97
|
+
COMPLETED=$(jq '[.userStories[] | select(.passes == true)] | length' "$PRD_FILE")
|
|
98
|
+
REMAINING=$((TOTAL_STORIES - COMPLETED))
|
|
99
|
+
|
|
100
|
+
echo ""
|
|
101
|
+
echo "═══════════════════════════════════════════════════════════════"
|
|
102
|
+
echo "📍 Iteration $i / $MAX_ITERATIONS | Completed: $COMPLETED / $TOTAL_STORIES | Remaining: $REMAINING"
|
|
103
|
+
echo "═══════════════════════════════════════════════════════════════"
|
|
104
|
+
echo ""
|
|
105
|
+
|
|
106
|
+
# Run Claude with the prompt
|
|
107
|
+
OUTPUT=$(claude -p --dangerously-skip-permissions \
|
|
108
|
+
"@$PRD_FILE @$PROGRESS_FILE @$PROMPT_FILE" 2>&1 \
|
|
109
|
+
| tee /dev/stderr) || true
|
|
110
|
+
|
|
111
|
+
# Check for completion signal
|
|
112
|
+
if echo "$OUTPUT" | grep -q "<promise>COMPLETE</promise>"; then
|
|
113
|
+
echo ""
|
|
114
|
+
echo "╔════════════════════════════════════════════════════════════╗"
|
|
115
|
+
echo "║ ✅ RALPH COMPLETE ║"
|
|
116
|
+
echo "╠════════════════════════════════════════════════════════════╣"
|
|
117
|
+
echo "║ All $TOTAL_STORIES stories completed in $i iterations!"
|
|
118
|
+
echo "╚════════════════════════════════════════════════════════════╝"
|
|
119
|
+
exit 0
|
|
120
|
+
fi
|
|
121
|
+
|
|
122
|
+
sleep 2
|
|
123
|
+
done
|
|
124
|
+
|
|
125
|
+
echo ""
|
|
126
|
+
echo "╔════════════════════════════════════════════════════════════╗"
|
|
127
|
+
echo "║ ⚠️ MAX ITERATIONS ║"
|
|
128
|
+
echo "╠════════════════════════════════════════════════════════════╣"
|
|
129
|
+
echo "║ Reached $MAX_ITERATIONS iterations. Run again to continue."
|
|
130
|
+
echo "╚════════════════════════════════════════════════════════════╝"
|
|
131
|
+
exit 1
|
|
132
|
+
RALPH_SH
|
|
133
|
+
|
|
134
|
+
chmod +x "$RALPH_DIR/ralph.sh"
|
|
135
|
+
echo "✅ Created ralph.sh"
|
|
136
|
+
|
|
137
|
+
# Create prompt.md (agent instructions)
|
|
138
|
+
cat > "$RALPH_DIR/prompt.md" << 'PROMPT_MD'
|
|
139
|
+
# Ralph Agent Instructions
|
|
140
|
+
|
|
141
|
+
## Your Task
|
|
142
|
+
|
|
143
|
+
You are an autonomous AI coding agent running in a loop. Each iteration, you implement ONE user story from the PRD.
|
|
144
|
+
|
|
145
|
+
## Execution Sequence
|
|
146
|
+
|
|
147
|
+
1. **Read Context**
|
|
148
|
+
- Read the PRD (prd.json) to understand all user stories
|
|
149
|
+
- Read progress.txt to see patterns and learnings from previous iterations
|
|
150
|
+
- Identify the **highest priority** story where `passes: false`
|
|
151
|
+
|
|
152
|
+
2. **Check Git Branch**
|
|
153
|
+
- Verify you're on the correct branch (see `branchName` in prd.json)
|
|
154
|
+
- If not, checkout the branch: `git checkout <branchName>` or create it
|
|
155
|
+
|
|
156
|
+
3. **Implement ONE Story**
|
|
157
|
+
- Focus on implementing ONLY the selected story
|
|
158
|
+
- Follow the acceptance criteria exactly
|
|
159
|
+
- Make minimal changes to achieve the goal
|
|
160
|
+
|
|
161
|
+
4. **Verify Quality**
|
|
162
|
+
- Run typecheck (if applicable): `pnpm tsc --noEmit` or `npm run typecheck`
|
|
163
|
+
- Run tests (if applicable): `pnpm test` or `npm test`
|
|
164
|
+
- Fix any issues before proceeding
|
|
165
|
+
|
|
166
|
+
5. **Commit Changes**
|
|
167
|
+
- Stage your changes: `git add .`
|
|
168
|
+
- Commit with format: `feat: [STORY-ID] - [Title]`
|
|
169
|
+
- Example: `feat: US-001 - Add login form validation`
|
|
170
|
+
|
|
171
|
+
6. **Update PRD**
|
|
172
|
+
- Update prd.json to mark the story as `passes: true`
|
|
173
|
+
- Add any notes about the implementation
|
|
174
|
+
|
|
175
|
+
7. **Log Learnings**
|
|
176
|
+
- Append to progress.txt with format:
|
|
177
|
+
|
|
178
|
+
```
|
|
179
|
+
## [Date] - [Story ID]: [Title]
|
|
180
|
+
- What was implemented
|
|
181
|
+
- Files changed
|
|
182
|
+
- **Learnings:**
|
|
183
|
+
- Patterns discovered
|
|
184
|
+
- Gotchas encountered
|
|
185
|
+
---
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
## Codebase Patterns
|
|
189
|
+
|
|
190
|
+
Check the TOP of progress.txt for patterns discovered by previous iterations:
|
|
191
|
+
- Follow existing patterns
|
|
192
|
+
- Add new patterns when you discover them
|
|
193
|
+
- Update patterns if they're outdated
|
|
194
|
+
|
|
195
|
+
## Stop Condition
|
|
196
|
+
|
|
197
|
+
**If ALL stories have `passes: true`**, output this exact text:
|
|
198
|
+
|
|
199
|
+
<promise>COMPLETE</promise>
|
|
200
|
+
|
|
201
|
+
This signals the loop to stop.
|
|
202
|
+
|
|
203
|
+
## Critical Rules
|
|
204
|
+
|
|
205
|
+
- 🛑 NEVER implement more than ONE story per iteration
|
|
206
|
+
- 🛑 NEVER skip the verification step (typecheck/tests)
|
|
207
|
+
- 🛑 NEVER commit if tests are failing
|
|
208
|
+
- ✅ ALWAYS check progress.txt for patterns FIRST
|
|
209
|
+
- ✅ ALWAYS update prd.json after implementing
|
|
210
|
+
- ✅ ALWAYS append learnings to progress.txt
|
|
211
|
+
PROMPT_MD
|
|
212
|
+
|
|
213
|
+
echo "✅ Created prompt.md"
|
|
214
|
+
|
|
215
|
+
# Create empty prd.json template
|
|
216
|
+
cat > "$FEATURE_DIR/prd.json" << 'PRD_JSON'
|
|
217
|
+
{
|
|
218
|
+
"branchName": "feat/FEATURE_NAME",
|
|
219
|
+
"userStories": []
|
|
220
|
+
}
|
|
221
|
+
PRD_JSON
|
|
222
|
+
|
|
223
|
+
# Replace placeholder
|
|
224
|
+
sed -i '' "s/FEATURE_NAME/${FEATURE_NAME}/g" "$FEATURE_DIR/prd.json" 2>/dev/null || \
|
|
225
|
+
sed -i "s/FEATURE_NAME/${FEATURE_NAME}/g" "$FEATURE_DIR/prd.json"
|
|
226
|
+
|
|
227
|
+
echo "✅ Created prd.json"
|
|
228
|
+
|
|
229
|
+
# Create progress.txt template
|
|
230
|
+
cat > "$FEATURE_DIR/progress.txt" << PROGRESS_TXT
|
|
231
|
+
# Ralph Progress Log
|
|
232
|
+
Started: $(date +%Y-%m-%d)
|
|
233
|
+
Feature: $FEATURE_NAME
|
|
234
|
+
|
|
235
|
+
## Codebase Patterns
|
|
236
|
+
(Add discovered patterns here - Ralph will read these each iteration)
|
|
237
|
+
|
|
238
|
+
---
|
|
239
|
+
|
|
240
|
+
PROGRESS_TXT
|
|
241
|
+
|
|
242
|
+
echo "✅ Created progress.txt"
|
|
243
|
+
|
|
244
|
+
# Create empty PRD.md
|
|
245
|
+
cat > "$FEATURE_DIR/PRD.md" << 'PRD_MD'
|
|
246
|
+
# Feature: [Feature Name]
|
|
247
|
+
|
|
248
|
+
## Vision
|
|
249
|
+
[What this feature accomplishes]
|
|
250
|
+
|
|
251
|
+
## Problem
|
|
252
|
+
[What problem does this solve]
|
|
253
|
+
|
|
254
|
+
## Solution
|
|
255
|
+
[High-level approach]
|
|
256
|
+
|
|
257
|
+
## User Stories
|
|
258
|
+
[Will be converted to prd.json]
|
|
259
|
+
|
|
260
|
+
## Technical Notes
|
|
261
|
+
[Implementation details, constraints, dependencies]
|
|
262
|
+
PRD_MD
|
|
263
|
+
|
|
264
|
+
echo "✅ Created PRD.md"
|
|
265
|
+
|
|
266
|
+
echo ""
|
|
267
|
+
echo "╔════════════════════════════════════════════════════════════╗"
|
|
268
|
+
echo "║ ✅ RALPH SETUP COMPLETE ║"
|
|
269
|
+
echo "╠════════════════════════════════════════════════════════════╣"
|
|
270
|
+
echo "║ Structure created at: $RALPH_DIR"
|
|
271
|
+
echo "║ Feature folder: $FEATURE_DIR"
|
|
272
|
+
echo "╠════════════════════════════════════════════════════════════╣"
|
|
273
|
+
echo "║ Next steps:"
|
|
274
|
+
echo "║ 1. Edit PRD.md with your feature requirements"
|
|
275
|
+
echo "║ 2. Run /ralph -i to brainstorm PRD interactively"
|
|
276
|
+
echo "║ 3. Transform PRD to user stories in prd.json"
|
|
277
|
+
echo "║ 4. Run: bun run $RALPH_DIR/ralph.sh -f $FEATURE_NAME"
|
|
278
|
+
echo "╚════════════════════════════════════════════════════════════╝"
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: step-00-init
|
|
3
|
+
description: Parse flags, set up Ralph structure, detect existing PRD
|
|
4
|
+
prev_step: null
|
|
5
|
+
next_step: steps/step-01-interactive-prd.md
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Step 0: Initialize Ralph
|
|
9
|
+
|
|
10
|
+
## MANDATORY EXECUTION RULES (READ FIRST):
|
|
11
|
+
|
|
12
|
+
- 🛑 NEVER skip the setup script - it creates files atomically
|
|
13
|
+
- 🛑 NEVER run ralph.sh - only set up files and show commands
|
|
14
|
+
- ✅ ALWAYS resolve project path to absolute path
|
|
15
|
+
- ✅ ALWAYS check for existing Ralph structure before creating
|
|
16
|
+
- ✅ ALWAYS let user run commands themselves
|
|
17
|
+
- 📋 YOU ARE an initializer, not an executor
|
|
18
|
+
- 💬 FOCUS on parsing flags and setting up structure only
|
|
19
|
+
- 🚫 FORBIDDEN to create PRD content in this step
|
|
20
|
+
- 🚫 FORBIDDEN to execute ralph.sh
|
|
21
|
+
|
|
22
|
+
## EXECUTION PROTOCOLS:
|
|
23
|
+
|
|
24
|
+
- 🎯 Parse all flags before taking any action
|
|
25
|
+
- 💾 Run setup script to create file structure
|
|
26
|
+
- 📖 Complete setup fully before next step
|
|
27
|
+
- 🚫 FORBIDDEN to load next step until structure exists
|
|
28
|
+
|
|
29
|
+
## CONTEXT BOUNDARIES:
|
|
30
|
+
|
|
31
|
+
- User arguments are available in the skill invocation
|
|
32
|
+
- No previous state exists (this is the first step)
|
|
33
|
+
- Setup script will create all necessary files
|
|
34
|
+
|
|
35
|
+
## YOUR TASK:
|
|
36
|
+
|
|
37
|
+
Initialize Ralph by parsing flags, running the setup script, and preparing for PRD creation.
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## EXECUTION SEQUENCE:
|
|
42
|
+
|
|
43
|
+
### 1. Parse User Arguments
|
|
44
|
+
|
|
45
|
+
Extract from skill arguments:
|
|
46
|
+
|
|
47
|
+
```yaml
|
|
48
|
+
# DEFAULTS
|
|
49
|
+
project_path: "." # Current directory if not specified
|
|
50
|
+
interactive_mode: false # -i or --interactive
|
|
51
|
+
setup_only: false # --setup-only
|
|
52
|
+
feature_name: null # -f or --feature <name>
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
**Parsing Rules:**
|
|
56
|
+
- First non-flag argument = project_path
|
|
57
|
+
- `-i` or `--interactive` = interactive_mode: true
|
|
58
|
+
- `--setup-only` = setup_only: true
|
|
59
|
+
- `-f <name>` or `--feature <name>` = feature_name
|
|
60
|
+
|
|
61
|
+
### 2. Validate Project Path
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
# Check project exists
|
|
65
|
+
if [ ! -d "{project_path}" ]; then
|
|
66
|
+
echo "Error: Project path not found"
|
|
67
|
+
exit 1
|
|
68
|
+
fi
|
|
69
|
+
|
|
70
|
+
# Resolve to absolute path
|
|
71
|
+
project_path=$(cd "{project_path}" && pwd)
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### 3. Generate Feature Name (if not provided)
|
|
75
|
+
|
|
76
|
+
If `{feature_name}` is null:
|
|
77
|
+
- Use AskUserQuestion to get feature name
|
|
78
|
+
- Generate kebab-case ID: `NN-feature-name`
|
|
79
|
+
- NN = next available number (01, 02, 03...)
|
|
80
|
+
|
|
81
|
+
**If interactive_mode = false and no feature_name:**
|
|
82
|
+
```yaml
|
|
83
|
+
questions:
|
|
84
|
+
- header: "Feature"
|
|
85
|
+
question: "What is the name of this feature? (will be used for folder name)"
|
|
86
|
+
options:
|
|
87
|
+
- label: "Let me type it"
|
|
88
|
+
description: "I'll provide a custom feature name"
|
|
89
|
+
multiSelect: false
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### 4. Set State Variables
|
|
93
|
+
|
|
94
|
+
```yaml
|
|
95
|
+
{project_path}: "/absolute/path/to/project"
|
|
96
|
+
{ralph_dir}: "{project_path}/.claude/ralph"
|
|
97
|
+
{tasks_dir}: "{ralph_dir}/tasks"
|
|
98
|
+
{feature_name}: "01-feature-name"
|
|
99
|
+
{feature_dir}: "{tasks_dir}/{feature_name}"
|
|
100
|
+
{interactive_mode}: true/false
|
|
101
|
+
{setup_only}: true/false
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### 5. Check for Existing Structure
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
# Check if Ralph already exists
|
|
108
|
+
if [ -d "{ralph_dir}" ]; then
|
|
109
|
+
echo "✅ Ralph structure already exists"
|
|
110
|
+
fi
|
|
111
|
+
|
|
112
|
+
# Check if feature folder exists
|
|
113
|
+
if [ -d "{feature_dir}" ]; then
|
|
114
|
+
echo "✅ Feature folder already exists"
|
|
115
|
+
# Check for existing PRD
|
|
116
|
+
if [ -f "{feature_dir}/PRD.md" ]; then
|
|
117
|
+
echo "📄 Found existing PRD.md"
|
|
118
|
+
{has_existing_prd} = true
|
|
119
|
+
fi
|
|
120
|
+
if [ -f "{feature_dir}/prd.json" ]; then
|
|
121
|
+
# Check if prd.json has stories
|
|
122
|
+
stories_count=$(jq '.userStories | length' "{feature_dir}/prd.json")
|
|
123
|
+
if [ "$stories_count" -gt 0 ]; then
|
|
124
|
+
echo "📋 Found $stories_count user stories in prd.json"
|
|
125
|
+
{has_user_stories} = true
|
|
126
|
+
fi
|
|
127
|
+
fi
|
|
128
|
+
fi
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### 6. Run Setup Script
|
|
132
|
+
|
|
133
|
+
**Use Bash tool to run the setup script:**
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
# Make script executable and run it
|
|
137
|
+
chmod +x /Users/melvynx/.claude/skills/setup-ralph/scripts/setup.sh
|
|
138
|
+
/Users/melvynx/.claude/skills/setup-ralph/scripts/setup.sh "{project_path}" "{feature_name}"
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
The setup script creates:
|
|
142
|
+
- `.claude/ralph/ralph.sh` (main loop)
|
|
143
|
+
- `.claude/ralph/prompt.md` (agent instructions)
|
|
144
|
+
- `.claude/ralph/tasks/{feature_name}/PRD.md` (empty template)
|
|
145
|
+
- `.claude/ralph/tasks/{feature_name}/prd.json` (empty stories)
|
|
146
|
+
- `.claude/ralph/tasks/{feature_name}/progress.txt` (learning log)
|
|
147
|
+
|
|
148
|
+
### 7. Determine Next Step
|
|
149
|
+
|
|
150
|
+
**Decision Tree:**
|
|
151
|
+
|
|
152
|
+
```
|
|
153
|
+
If {setup_only} = true:
|
|
154
|
+
→ Show success message, END workflow
|
|
155
|
+
|
|
156
|
+
If {has_user_stories} = true:
|
|
157
|
+
→ Skip to step-03-finish.md (ready to run)
|
|
158
|
+
|
|
159
|
+
If {has_existing_prd} = true AND content is not template:
|
|
160
|
+
→ Skip to step-02-create-stories.md (transform PRD to stories)
|
|
161
|
+
|
|
162
|
+
If {interactive_mode} = true:
|
|
163
|
+
→ Load step-01-interactive-prd.md (brainstorm PRD)
|
|
164
|
+
|
|
165
|
+
Else:
|
|
166
|
+
→ Ask user what to do next
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
**If need to ask:**
|
|
170
|
+
```yaml
|
|
171
|
+
questions:
|
|
172
|
+
- header: "Next Step"
|
|
173
|
+
question: "Ralph is set up. What would you like to do next?"
|
|
174
|
+
options:
|
|
175
|
+
- label: "Create PRD interactively (Recommended)"
|
|
176
|
+
description: "Brainstorm and create PRD with AI assistance"
|
|
177
|
+
- label: "I'll write PRD manually"
|
|
178
|
+
description: "Edit PRD.md yourself, then run /setup-ralph again"
|
|
179
|
+
- label: "Transform existing PRD to stories"
|
|
180
|
+
description: "I already have a PRD, just create user stories"
|
|
181
|
+
multiSelect: false
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
---
|
|
185
|
+
|
|
186
|
+
## SUCCESS METRICS:
|
|
187
|
+
|
|
188
|
+
✅ Project path resolved to absolute path
|
|
189
|
+
✅ Feature name generated or provided
|
|
190
|
+
✅ Setup script executed successfully
|
|
191
|
+
✅ All Ralph files created
|
|
192
|
+
✅ State variables properly set
|
|
193
|
+
✅ Next step determined
|
|
194
|
+
|
|
195
|
+
## FAILURE MODES:
|
|
196
|
+
|
|
197
|
+
❌ Project path doesn't exist
|
|
198
|
+
❌ Setup script fails
|
|
199
|
+
❌ Permission denied creating directories
|
|
200
|
+
❌ Feature name contains invalid characters
|
|
201
|
+
|
|
202
|
+
## INIT PROTOCOLS:
|
|
203
|
+
|
|
204
|
+
- Always use absolute paths
|
|
205
|
+
- Always run setup script (it's idempotent)
|
|
206
|
+
- Never modify existing PRD.md if it has content
|
|
207
|
+
- Use AskUserQuestion for any user decisions
|
|
208
|
+
|
|
209
|
+
## NEXT STEP:
|
|
210
|
+
|
|
211
|
+
Based on decision tree above, load the appropriate next step.
|
|
212
|
+
|
|
213
|
+
<critical>
|
|
214
|
+
Remember: This step ONLY sets up structure. PRD content is created in step-01.
|
|
215
|
+
</critical>
|