@manojlds/ralphi
v0.6.5
Published
Pi-native ralph extension with skill commands and fresh-context loop sessions.
Readme
ralphi
ralphi is a Pi-native implementation of the Ralph autonomous loop pattern.
The name is literal: Ralph + Pi = ralphi.
It gives you a structured, repeatable workflow for planning and implementing features with fresh-context loop iterations.
What ralphi does
ralphi provides a phased workflow plus an autonomous implementation loop:
/ralphi-init— initialize project config and guardrails/ralphi-prd— generate PRD markdown from a feature idea/ralphi-convert— convert PRD markdown into.ralphi/prd.json/ralphi-loop-start— run iterative implementation against.ralphi/prd.json
Core behavior:
- Commands are namespaced under
/ralphi-* - Completion is driven by the
ralphi_phase_donetool - Loop iterations run in fresh child sessions
.ralphi/prd.jsonis the source of truth for pending stories (status != done)- Loop supports explicit completion (
complete: true) and auto-completes when no pending stories remain
Install
From npm (recommended)
pi install npm:@manojlds/ralphiThis installs the package and loads its bundled extension + skills automatically.
If you prefer editing settings manually, add this to ~/.pi/agent/settings.json:
{
"packages": [
"npm:@manojlds/ralphi"
]
}Then restart Pi or run /reload.
Local development / path install
For developing ralphi itself, use a direct path in project-level .pi/settings.json:
{
"packages": [
".."
]
}This overrides the npm package so local changes are picked up live.
Quick start (typical flow)
1) Initialize project settings
/ralphi-initThis phase prepares .ralphi/config.yaml and establishes rules/commands for the project.
2) Create a PRD
/ralphi-prd <name> <description>Example:
/ralphi-prd loop-guidance add loop trajectory guard and review gatesIf name or description is omitted in TUI mode, ralphi prompts for them.
3) Convert PRD markdown to .ralphi/prd.json
/ralphi-convert tasks/prd-<feature>.md4) Start the autonomous loop
/ralphi-loop-start --max-iterations 50Monitor and control with:
/ralphi-loop-status/ralphi-loop-open [loopId]/ralphi-loop-controller [loopId]/ralphi-loop-stop [loopId]
How the loop works
When you run /ralphi-loop-start:
- A controller loop is created.
- Runtime runs preflight validation. Loop start fails fast if required setup is missing:
.ralphi/config.yamlwithcommands.ralphi/prd.jsonwith validbranchName+userStories- git repository + pre-commit configured to run
ralphi check
- Runtime enforces PRD branch alignment from
.ralphi/prd.json(branchName):- if branch exists, runtime switches to it
- if branch is missing, TUI prompts whether to create from
mainor current branch
- Each iteration starts in a fresh child session.
- The loop skill reads:
.ralphi/config.yaml.ralphi/prd.json.ralphi/progress.txt
- It implements the next pending story by priority (
status: open/in_progress). - It signals completion via
ralphi_phase_done. - Runtime finalizes the iteration and either:
- starts another iteration, or
- ends the loop (
complete: true, user stop, max iterations, or no pending PRD stories).
Iteration/session model
- Controller session tracks loop lifecycle
- Iteration sessions isolate context
- Status is persisted in
.ralphi/runtime-state.json
Commands reference
| Command | Purpose |
|---|---|
| /ralphi-init | Run init phase with finalize + rewind flow |
| /ralphi-prd <name> <description> | Run PRD generation phase |
| /ralphi-convert <prd-file> | Convert PRD markdown to .ralphi/prd.json |
| /ralphi-finalize <runId> | Manually finalize a run (internal/recovery) |
| /ralphi-loop-start [--max-iterations N] | Start autonomous loop |
| /ralphi-loop-next <loopId> | Trigger next iteration (internal) |
| /ralphi-loop-stop [loopId] | Request loop stop |
| /ralphi-loop-open [loopId] | Jump to active/recent iteration session |
| /ralphi-loop-controller [loopId] | Return to controller session |
| /ralphi-loop-status | Show active runs/loops |
| /ralphi-loop-validate | Validate loop preflight prerequisites |
| /ralphi-loop-guidance-show | Show loop guidance from config |
| /ralphi-loop-guidance-set <guidance> | Set loop.guidance in config |
| /ralphi-loop-guidance-clear | Clear loop.guidance in config |
Tools reference
ralphi_phase_done
Marks a phase/iteration complete and queues finalize behavior.
Required fields:
runIdphasesummary
Optional fields:
outputs: string[]complete: boolean(loop-only meaningful; set true to end loop)reviewPasses: number(loop metadata)trajectory: ON_TRACK | RISK | DRIFT(loop metadata)trajectoryNotes: stringcorrectivePlan: string(required when strict DRIFT guard is enabled)reflectionSummary: string(required on reflection-checkpoint iterations)nextIterationPlan: string(required on reflection-checkpoint iterations)
ralphi_ask_user_question
Structured interactive question tool for init/prd/convert phases.
Supports:
- single-select and multi-select
- optional
Otherfree-text path - headless
providedAnswersfor non-interactive mode
Configuration (.ralphi/config.yaml)
Typical config:
project:
name: "my-project"
language: "TypeScript"
framework: "Pi extension"
commands:
test: "npm run test"
lint: "npm run lint"
typecheck: "npm run typecheck"
rules:
- "run npm run check before finalizing"
- "keep changes scoped to one story"
loop:
guidance: "Take a step back each iteration and reassess PRD alignment."
reviewPasses: 1
trajectoryGuard: "require_corrective_plan"
reflectEvery: 3
reflectInstructions: "Reassess PRD alignment, risks, and confidence before coding."
boundaries:
never_touch:
- "*.lock"
- ".env*"
engine: "pi"
max_retries: 3Important sections
commands: quality gates used during executionrules: injected into system prompt as project constraintsloop.guidance: loop-specific steering textloop.reviewPasses: minimum expected review passes before completionloop.trajectoryGuard:offwarn_on_driftrequire_corrective_plan
loop.reflectEvery: reflection checkpoint cadence in iterations (default-off when missing or<= 0)loop.reflectInstructions: optional project-specific checkpoint prompt contentboundaries.never_touch: files/patterns that must not be modified
Reflection checkpoints (opt-in, gradual rollout)
Reflection cadence is disabled by default. Enable it only when you want checkpoint iterations:
loop:
reflectEvery: 3Checkpoint behavior:
- Every
Nth iteration (reflectEvery) gets a[REFLECTION CHECKPOINT]prompt block. /ralphi-loop-statusshows countdown text (for example,next reflection in 2 iterations).- At checkpoint completion,
ralphi_phase_donemust include:reflectionSummarynextIterationPlan
Optional custom instructions:
loop:
reflectEvery: 3
reflectInstructions: "Reassess drift risk, dependencies, and confidence before implementation."Suggested migration path:
- Start with a conservative cadence (
reflectEvery: 5or higher). - Run a few loops and verify the checkpoint outputs are useful.
- Add
reflectInstructionsonce your team wants a project-specific reflection template. - Tighten cadence (for example,
reflectEvery: 3then2) only after adoption is stable.
PRD data model (.ralphi/prd.json)
Loop expects stories in userStories with:
idtitleprioritystatus(open|in_progress|done)dependsOn(optionalstring[]of story IDs)
Selection behavior:
- Loop selects highest-priority unblocked story (dependencies satisfied).
- It prefers
status: open, then may resumestatus: in_progress.
When all stories are status: done, loop can terminate.
Operational tips
- Keep each story small enough for one iteration.
- Use
/ralphi-loop-opento inspect in-flight iteration work. - If an iteration can’t finalize, use
/ralphi-finalize <runId>. - Use
/ralphi-loop-statusbefore starting new loops.
CLI helper
ralphi ships a project-local quality-check CLI:
npx --no-install ralphi checkIt reads .ralphi/config.yaml and runs configured commands in sequence.
Local development
npm install
npm run check
npm run ralphi:check
npm pack --dry-runChangelog
For release history and migration notes, see CHANGELOG.md.
