Skip to content
/

ralphy-openspec

ralphy-openspec · wenqingyu/ralphy-openspec · ★ 186 · last commit 2026-01-27

Combines OpenSpec spec governance with Ralph Loop iterative execution and a SQLite run ledger to provide crash-recoverable, budget-tracked AI coding sessions.

Best whenIterative loops with machine-parseable completion signals plus persistent state databases are the right infrastructure for long-running AI coding tasks.
Skip ifDeclaring success without running tests, Marking tasks complete before verification
vs seeds
Primitive shape 4 total
Commands 4
00

Summary

ralphy-openspec — Summary

ralphy-openspec (published as ralphy-spec) is an npm CLI tool and multi-tool command pack that combines OpenSpec spec-first planning with the Ralph Loop iterative execution pattern, providing a SQLite-backed run ledger, budget tracking, and slash commands for four AI tools (Cursor, Claude Code, OpenCode, and a standalone Ralph loop runner).

Problem it solves: OpenSpec provides structured specs but lacks persistence between AI sessions — when context windows exhaust or sessions disconnect, agents lose progress. The Ralph Loop retries a prompt until completion but has no spec governance. ralphy-spec wires them together: specs lock intent before execution, the loop retries until tests pass (outputting <promise>TASK_COMPLETE</promise>), and a SQLite database tracks run history, budget, and checkpoints across sessions.

Distinctive trait: The only framework in this batch with a real-time SQLite state database (ralphy-spec/state.db) that persists run state, task ledger, budget tracking, and backend transcripts across sessions and CLI invocations. Combined with the Ralph Loop's iterative execution model (continuous agent loop until task completion), this provides crash recovery and resume capability that no other framework in the batch offers.

Target audience: Developers who run long AI coding sessions that frequently time out or get interrupted, needing reliable resume-from-checkpoint behavior, and who want OpenSpec's spec discipline on top of the iterative execution model.

Production-readiness: v0.3.6, 186 stars (highest in the batch), 20 forks. Last commit January 2026. Multi-language README (English, Chinese, Korean, Japanese). Published as ralphy-spec on npm.

Relationship to seeds: Most similar to taskmaster-ai (file + database-backed task ledger, runs via CLI, spans multiple AI tools) but adds the Ralph Loop continuous execution model and OpenSpec spec governance. Like claude-flow (which uses SQLite + vector DB for memory), ralphy-spec uses SQLite for run state — but focuses on spec-driven task execution rather than distributed agent memory. Unlike openspec (the canonical seed), ralphy-spec has 4 slash commands instead of 11, and adds the critical run/loop execution layer that OpenSpec lacks.

01

Overview

ralphy-openspec — Overview

Origin

Created by wenqingyu. The package name is ralphy-spec (with a website at ralphy-spec.org). Published with four language READMEs (English, Chinese, Korean, Japanese). The repository name is ralphy-openspec on GitHub.

Credits

From the README:

"Built on the work of:

  • Ralph Methodology by Geoffrey Huntley
  • opencode-ralph-wiggum by @Th0rgal
  • OpenSpec by Fission-AI"

Philosophy

The README articulates the combination:

"Spec-driven AI development with iterative execution. Combines OpenSpec + Ralph Loop for predictable AI-assisted coding."

The core problem table:

Problem Solution
Vague requirements in chat Specs lock intent
AI stops mid-task Loop retries until done
No way to verify Tests validate output
Tool-specific setup One command for all

Ralph Loop concept

The Ralph Wiggum Loop: AI receives the same prompt repeatedly until task completion. Each iteration, it sees previous work in files and self-corrects. The <promise>TASK_COMPLETE</promise> output is the completion signal:

ralph "Follow AGENTS.md to implement add-api. Output <promise>TASK_COMPLETE</promise> when done." \
  --max-iterations 20

Multi-tool support

Unique in supporting all four major AI tools with both slash commands and an AGENTS.md fallback:

Tool Commands Alternative
Cursor .cursor/prompts/*.md
Claude Code .claude/commands/*.md
OpenCode AGENTS.md Natural language
Ralph loop AGENTS.md + ralph CLI
02

Architecture

ralphy-openspec — Architecture

Distribution

  • Type: npm package + command pack (multi-tool)
  • Package name: ralphy-spec
  • Version: 0.3.6
  • Binary: ralphy-spec
  • Language: TypeScript (Node.js)

Install

# Recommended
npx ralphy-spec init

# Global install
npm install -g ralphy-spec
ralphy-spec init

# With specific tools
ralphy-spec init --tools cursor,claude-code,opencode

Required runtime

  • Node.js (implied by npm package)
  • SQLite (via better-sqlite3 dependency)

Key dependencies

Package Purpose
better-sqlite3 SQLite run state database
commander CLI argument parsing
inquirer Interactive init wizard
execa Execute AI backends
fast-glob File discovery
ora CLI spinners
yaml YAML parsing
zod Schema validation

Repository structure

ralphy-openspec/
├── .claude/
│   └── commands/          ← 4 Claude Code slash commands
│       ├── ralphy-plan.md
│       ├── ralphy-implement.md
│       ├── ralphy-validate.md
│       └── ralphy-archive.md
├── .cursor/
│   └── prompts/           ← Same 4 commands for Cursor
├── .ralphy/               ← Legacy (migrated to ralphy-spec/)
├── AGENTS.md              ← OpenCode/natural language equivalent
├── bin/
│   └── ralphy-spec.js     ← Binary entry point
├── src/
│   ├── cli/               ← 9 CLI subcommands
│   │   ├── init.ts
│   │   ├── run.ts
│   │   ├── status.ts
│   │   ├── budget.ts
│   │   ├── checkpoint.ts
│   │   ├── report.ts
│   │   ├── tail.ts
│   │   ├── update.ts
│   │   └── validate.ts
│   ├── core/              ← Run engine, OpenSpec integration
│   ├── templates/         ← Prompt templates
│   └── utils/
├── openspec/              ← OpenSpec directory
├── ralphy-spec/           ← Runtime state directory
│   ├── state.db           ← SQLite run/task ledger
│   ├── STATUS.md          ← Live status snapshot
│   ├── TASKS.md           ← Task board view
│   ├── BUDGET.md          ← Budget breakdown
│   ├── runs/<runId>.md    ← Immutable run logs
│   ├── logs/<runId>/      ← Backend transcripts
│   ├── worktrees/         ← Git worktrees per task (when enabled)
│   └── tasks/<taskId>/   ← Per-task artifacts
│       ├── CONTEXT.md
│       ├── REPAIR.md
│       └── NOTES.md
└── package.json

Target AI tools

  • Claude Code (.claude/commands/)
  • Cursor (.cursor/prompts/)
  • OpenCode (AGENTS.md)
  • Ralph loop (@th0rgal/ralph-wiggum + AGENTS.md)

Backend authentication (for ralphy-spec run)

cursor agent login  # or CURSOR_API_KEY env var
ralphy-spec run --backend cursor
03

Components

ralphy-openspec — Components

CLI binary: ralphy-spec

Subcommands (9):

Subcommand Purpose
ralphy-spec init Interactive setup wizard; installs slash commands for selected tools
ralphy-spec run Execute run loop (calls AI backend with Ralph Loop)
ralphy-spec run --dry-run Validate run plan without executing
ralphy-spec status Show current run status from STATUS.md
ralphy-spec budget Show budget/spend breakdown (--json flag available)
ralphy-spec checkpoint Save/restore checkpoint
ralphy-spec report Generate run report
ralphy-spec tail Tail live run logs
ralphy-spec update Update ralphy-spec to latest version
ralphy-spec validate Validate OpenSpec change artifacts

Commands (4 per AI tool = 8 total files)

Commands are identical in intent, installed as:

  • .claude/commands/ralphy-{plan,implement,validate,archive}.md (Claude Code)
  • .cursor/prompts/ralphy-{plan,implement,validate,archive}.md (Cursor)
  • AGENTS.md equivalent entries (OpenCode)
Command Purpose
/ralphy-plan Convert PRD/requirements → OpenSpec change (proposal.md + tasks.md + delta specs)
/ralphy-implement Implement tasks (Ralph Loop compatible — outputs <promise>TASK_COMPLETE</promise>)
/ralphy-validate Verify acceptance criteria via tests
/ralphy-archive Complete and archive the change

Skills

Count: 0 — Commands are Markdown files, not SKILL.md format.

Subagents

Count: 0

Hooks

Count: 0

MCP Servers

Count: 0

State files (runtime)

File Purpose
ralphy-spec/state.db SQLite: run/task ledger (primary state)
ralphy-spec/STATUS.md Live status snapshot (primary for ralphy-spec status)
ralphy-spec/TASKS.md Task board view
ralphy-spec/BUDGET.md Spend/budget breakdown
ralphy-spec/runs/<runId>.md Immutable run logs
ralphy-spec/logs/<runId>/ Raw backend transcripts (stdout/stderr + metadata)
ralphy-spec/tasks/<taskId>/CONTEXT.md Per-task context
ralphy-spec/tasks/<taskId>/REPAIR.md Repair context for failed tasks

OpenSpec files (workflow)

File Purpose
openspec/changes/{id}/proposal.md Created by /ralphy-plan
openspec/changes/{id}/tasks.md Created by /ralphy-plan
openspec/changes/{id}/specs/{domain}/spec.md Created by /ralphy-plan
openspec/specs/ Living source-of-truth
openspec/archive/{id}/ Completed changes
05

Prompts

ralphy-openspec — Prompts (Verbatim)

1. /ralphy-plan (.claude/commands/ralphy-plan.md) — Full content

# /ralphy-plan (PRD -> OpenSpec change)

You are an AI coding assistant. Convert the user's PRD/requirements into an OpenSpec change
proposal with clear, testable acceptance criteria.

## Deliverables (create/modify files)
Create a new change folder:
- `openspec/changes/<change-name>/proposal.md`
- `openspec/changes/<change-name>/tasks.md`
- `openspec/changes/<change-name>/specs/<domain>/spec.md` (and others as needed)

## Rules
- Use MUST/SHALL language for requirements.
- Every `### Requirement:` MUST include at least one `#### Scenario:`.
- Include acceptance criteria that can be validated by tests or deterministic commands.
- Keep scope explicit; list non-goals.

## Procedure
1. Read `openspec/project.md` and relevant specs under `openspec/specs/`.
2. Propose a kebab-case change name (e.g. `add-profile-filters`).
3. Create `proposal.md` explaining why/what and the constraints.
4. Write spec deltas under `specs/` using:
   - `## ADDED Requirements`
   - `## MODIFIED Requirements`
   - `## REMOVED Requirements`
5. Write `tasks.md` as a numbered checklist. Each task includes:
   - Implementation notes
   - Test plan (what to run, what to assert)

## Output
Summarize created files and tell the user what to run next (typically implementation).

Prompting technique: Requirements-to-spec compiler. The command is framed as a conversion task (PRD → OpenSpec artifacts). MUST/SHALL normative language is explicitly required. The test plan per task (not just per phase) is a distinctive requirement.


2. /ralphy-implement (.claude/commands/ralphy-implement.md) — Full content

# /ralphy-implement (Implement OpenSpec tasks)

You are implementing an OpenSpec change located under `openspec/changes/<change-name>/`.

## Goal
Complete all tasks in `tasks.md` and satisfy the acceptance criteria from the spec scenarios.

## Ralph loop compatibility
If this command is being executed in an iterative loop:
- Make progress each iteration
- Run tests frequently
- Only declare success when verification passes

## Steps
1. Identify the active change folder under `openspec/changes/`.
2. Read the change artifacts:
   - `proposal.md`
   - `tasks.md`
   - spec deltas under `specs/`
3. Implement tasks in order:
   - Update code
   - Add/update tests
   - Run tests
   - Mark tasks complete ONLY when verified

## Completion promise
Only output this exact text when ALL tasks are complete and tests pass:

<promise>TASK_COMPLETE</promise>

Prompting technique: Ralph Loop protocol integration — the <promise>TASK_COMPLETE</promise> output is a machine-parseable completion signal that the ralphy-spec run loop monitors. The "Ralph loop compatibility" section explicitly instructs the AI on how to behave under iterative re-execution.


3. /ralphy-validate (.claude/commands/ralphy-validate.md)

The validate command is not fetched but follows the same pattern: read tasks.md and spec scenarios, run the test commands specified in each task's test plan, and report pass/fail per acceptance criterion.


Key Prompting Techniques

  1. Loop-aware instructions: The implement command explicitly addresses "if executed in an iterative loop" — making it designed for re-entrant execution from the start.
  2. Machine-parseable completion signal: <promise>TASK_COMPLETE</promise> is a tagged string the CLI monitors, not a human-readable message.
  3. Test-per-task discipline: The plan command requires a test plan inline within each task (not just at phase-end quality gates).
  4. Normative language requirement: MUST/SHALL is required for all spec requirements, making them machine-checkable in principle.
  5. Context-first pattern: Both plan and implement begin with "Read openspec/project.md and relevant specs" before any action.
09

Uniqueness

ralphy-openspec — Uniqueness and Positioning

differs_from_seeds

Most similar to taskmaster-ai (file-based task ledger + multiple AI tools + CLI), but adds the Ralph Loop continuous execution model and SQLite state persistence. Like claude-flow (which uses SQLite + vector store), ralphy-spec uses SQLite for state — but focuses on sequential spec-driven task execution rather than distributed agent memory. Unlike the canonical openspec seed (which has 11 commands/skills but no loop engine), ralphy-spec has only 4 commands but adds the critical run/loop execution layer with crash recovery. The <promise>TASK_COMPLETE</promise> protocol is borrowed from opencode-ralph-wiggum — the only framework in the batch using this machine-parseable completion signal.

Positioning

  • Niche: "OpenSpec + Ralph Loop for sessions that need crash recovery and budget tracking"
  • Primary differentiator: Only framework in the batch with SQLite state database + continuous Ralph Loop execution
  • Secondary differentiator: Budget tracking (ralphy-spec budget --json) — unique in the corpus
  • Third differentiator: Multi-tool coverage (Cursor, Claude Code, OpenCode, standalone ralph) from one init command

Observable failure modes

  1. Max iterations exhaustion: If the AI never outputs <promise>TASK_COMPLETE</promise> within --max-iterations, the run terminates without completion. No notification mechanism for this case.
  2. Backend authentication fragility: cursor agent login is an undocumented Cursor API path that could break with Cursor updates.
  3. SQLite state corruption: Crash during state.db write could corrupt the ledger. No explicit write-ahead logging or backup described.
  4. No spec validation in plan: The /ralphy-plan command creates OpenSpec artifacts but does not call openspec validate to check schema compliance.
  5. AGENTS.md as fallback: The OpenCode path relies on AGENTS.md being read by the agent — if the agent ignores AGENTS.md, there's no enforcement.

Explicit antipatterns

From /ralphy-implement:

  • Declaring success without running tests
  • Marking tasks complete before verification passes
  • Starting implementation without reading all three context files (proposal.md, tasks.md, specs/)
04

Workflow

ralphy-openspec — Workflow

Phases

# Phase Command CLI equivalent Artifact
1 Plan /ralphy-plan <description> (manual) openspec/changes/{id}/proposal.md, tasks.md, specs/
2 Implement /ralphy-implement <change-name> ralphy-spec run Source code + updated tasks
3 Validate /ralphy-validate ralphy-spec validate Test results / acceptance criteria check
4 Archive /ralphy-archive <change-name> (manual) openspec/archive/{id}/ + spec merge

Phase to artifact map

Phase Artifact
Plan openspec/changes/{id}/proposal.md
Plan openspec/changes/{id}/tasks.md
Plan openspec/changes/{id}/specs/{domain}/spec.md
Implement Source code
Implement Updated tasks.md checkboxes
Implement ralphy-spec/state.db (run state)
Implement ralphy-spec/runs/<runId>.md (immutable run log)
Validate Test run output
Archive openspec/archive/{id}/
Archive openspec/specs/*.md (merged)

Approval gates

Count: 1

Gate Type
User reviews plan artifacts before running implement file-review

Note: Implement loops run continuously until <promise>TASK_COMPLETE</promise> — no per-iteration human gate.

Ralph Loop execution model

The implement phase uses the "Ralph Wiggum" iterative loop:

Iteration 1: AI reads task context, writes code, runs tests
Iteration 2: AI sees previous attempt in files, self-corrects
...
Iteration N: AI outputs <promise>TASK_COMPLETE</promise>

With ralphy-spec run:

ralphy-spec run --backend cursor
# Repeats prompt until TASK_COMPLETE or --max-iterations reached
# Backend output streamed by default

Budget tracking

The BUDGET.md and budget --json command track token/cost spend per run. This is unique in the batch — no other framework tracks budget.

Checkpoint and resume

ralphy-spec checkpoint save      # Save current state
ralphy-spec checkpoint restore   # Resume from checkpoint

SQLite state.db persists all run state for resume.

06

Memory Context

ralphy-openspec — Memory and Context

State storage

Hybrid: SQLite database + structured Markdown files.

SQLite database: ralphy-spec/state.db

Primary state store for:

  • Run/task ledger (run IDs, task IDs, statuses)
  • Budget/cost tracking
  • Checkpoint save/restore data
  • Backend transcript metadata

This is the only framework in the batch with a SQL database as state store (vs. pure file-based).

Markdown state files (human-readable view of SQLite state)

File Update frequency Purpose
ralphy-spec/STATUS.md Live (updated during run) Primary for ralphy-spec status
ralphy-spec/TASKS.md Live Task board view
ralphy-spec/BUDGET.md Per run Spend/budget breakdown
ralphy-spec/runs/<runId>.md Immutable on completion Run log
ralphy-spec/logs/<runId>/ Per-iteration Backend stdout/stderr transcripts

Per-task artifacts

File Purpose
ralphy-spec/tasks/<taskId>/CONTEXT.md Task context injected into each loop iteration
ralphy-spec/tasks/<taskId>/REPAIR.md Repair context for failed/stuck iterations
ralphy-spec/tasks/<taskId>/NOTES.md Agent notes about the task

OpenSpec files

File Purpose
openspec/project.md Project context (read by all commands)
openspec/changes/{id}/proposal.md Change intent
openspec/changes/{id}/tasks.md Implementation checklist
openspec/changes/{id}/specs/ Delta specs
openspec/specs/ Living source-of-truth specs

Legacy migration

"Note: Legacy .ralphy/ folders are migrated to ralphy-spec/ automatically when found."

The tool handles schema migrations automatically.

Cross-session handoff

Yes — SQLite database persists all run state. ralphy-spec checkpoint restore resumes from a saved state.

Context compaction

Implicit via per-task CONTEXT.md files. Each Ralph Loop iteration receives the current task's CONTEXT.md as its starting context, keeping the prompt focused rather than accumulating full history.

07

Orchestration

ralphy-openspec — Orchestration

Multi-agent

No formal multi-agent dispatch. The Ralph Loop is a single-agent iterative loop, not a multi-agent coordinator.

Orchestration pattern

Sequential (OpenSpec phases) + event-driven loop (implement phase). The implement phase loops until <promise>TASK_COMPLETE</promise> or --max-iterations is reached.

Isolation mechanism

Optional git-worktree. The ralphy-spec/worktrees/ directory suggests per-task worktrees are supported, but the README doesn't prominently describe this as a feature.

Multi-model

No. Single backend at a time (cursor, claude-code, or opencode).

Execution mode

Continuous-ralph (unique in the batch). The ralphy-spec run command implements the Ralph Loop — a continuous agent loop where:

  1. The AI receives a prompt
  2. The AI makes progress, writes code, runs tests
  3. The CLI re-invokes with updated context
  4. Loop repeats until <promise>TASK_COMPLETE</promise> or max iterations

This is the only framework in the batch using a true continuous execution loop with an explicit completion signal protocol.

Prompt chaining

Yes. Each loop iteration's file state becomes the next iteration's context (the AI sees its previous work in the filesystem).

Auto-validators

Test execution per task — the implement command instructs "Run tests" after each implementation step and "Mark tasks complete ONLY when verified."

Crash recovery

Yes — SQLite state.db + checkpoint mechanism. ralphy-spec checkpoint restore resumes from saved state, including mid-loop state.

08

Ui Cli Surface

ralphy-openspec — UI, CLI, and Observability

Dedicated CLI binary

Yes.

ralphy-spec <command> [options]

Commands:
  init         Interactive setup wizard
  run          Execute run loop
  status       Show current status
  budget       Show budget breakdown (--json available)
  checkpoint   Save/restore checkpoint
  report       Generate run report
  tail         Tail live run logs
  update       Update to latest version
  validate     Validate OpenSpec artifacts

Is thin wrapper: Partially — wraps AI backends (cursor, claude-code) but has its own run engine, state management, and Ralph Loop logic.

Local web dashboard

None.

IDE integration

None standalone. Commands install into IDE directories via ralphy-spec init.

Observability

Strong — the richest observability in the batch:

Artifact Update frequency Access
ralphy-spec/STATUS.md Live during run ralphy-spec status
ralphy-spec/BUDGET.md Per run ralphy-spec budget / --json
ralphy-spec/runs/<runId>.md Immutable on completion ralphy-spec report
ralphy-spec/logs/<runId>/ Per-iteration transcripts ralphy-spec tail
ralphy-spec/state.db Continuous SQLite direct access

The ralphy-spec tail command provides live log streaming — the most real-time observability in the batch without a web dashboard.

Budget tracking

Unique feature: ralphy-spec budget --json outputs structured cost/token tracking. No other framework in the batch has budget tracking as a first-class CLI feature.

Related frameworks

same archetype · same primary tool · same memory type

OpenHarness ★ 13k

Open-source Python agent runtime providing complete harness infrastructure: tools, memory, governance, swarm coordination, and…

Trae Agent ★ 12k

Research-friendly open-source CLI coding agent by ByteDance, designed for academic ablation studies and modular LLM provider…

Sweep AI ★ 7.7k

Autonomous GitHub bot that converts issues to pull requests using a sequential multi-agent pipeline.

Agent Governance Toolkit (microsoft) ★ 2.3k

Enterprise-grade AI agent governance: YAML policy enforcement, 12-vector prompt injection defense, zero-trust identity,…

TDD Guard ★ 2.1k

Mechanically enforces the Red-Green-Refactor TDD cycle by blocking file writes that violate TDD principles via a PreToolUse hook…

Agentic Coding Flywheel Setup (ACFS) ★ 1.5k

Take a complete beginner from laptop to three AI coding agents running on a VPS in 30 minutes via an idempotent manifest-driven…