Sandbox
@LarsCowe/bmalph

BMAD planning and Ralph loop for agent workflows

bmalph installs two linked systems into a project: BMAD for planning and Ralph for autonomous implementation. It adds the right instructions, commands, skills, or rule files for the chosen platform, then moves planned work into Ralph’s task loop when you run `bmalph implement`. The workflow is built around the CLI and the bundled assets in `bmad/` and `ralph/`. That lets builders plan with one assistant, then hand the work to a repeatable implementation loop with the same project context.

406 stars50 forksTypeScriptUpdated 12d ago
Who it's for

Builders who want their coding assistant to follow a shared planning-to-implementation workflow across Claude Code, Codex, Cursor, or similar tools.

What it delivers

You can plan work in BMAD and hand it off to Ralph without redoing the setup by hand.

What it does

Project initialization

`bmalph init` installs BMAD, Ralph, and platform-specific instructions into the target project.

Platform detection

The CLI auto-detects the assistant platform from project markers and can also take `--platform`.

Planning phases

BMAD supports analysis, planning, and solutioning phases with commands like brainstorm, PRD, architecture, and stories.

Ralph transition

`bmalph implement` turns BMAD artifacts into Ralph’s fix plan and spec files.

Autonomous loop

`bmalph run` starts Ralph’s loop, which picks stories, runs TDD-style implementation, commits changes, and advances through the plan.

Update and health checks

`bmalph upgrade`, `bmalph doctor`, `bmalph status`, and `bmalph check-updates` keep the install current and healthy.

Platform-specific delivery

Commands are delivered as Claude Code slash commands, Codex skills, or a shared command index for other supported editors and CLIs.

Swarm mode

`bmalph run --swarm` can split work across multiple Ralph workers in separate git worktrees.

How to get it

  1. 1Run
    npm install -g bmalph
  2. 2Run
    cd my-project
    bmalph init --name my-project
    
    # To target a specific platform, add --platform (e.g. codex, cursor, windsurf)
    # Without --platform, bmalph auto-detects strong project markers and
    # prompts interactively when detection is ambiguous or missing
  3. 3The simplest way to remove all bmalph files
    bmalph reset
  4. 4If the CLI is unavailable, remove these directories and files manually
    rm -rf _bmad/ .ralph/ bmalph/
  5. 5Run
    # Human-readable output
    bmalph doctor
    
    # JSON output for scripting
    bmalph doctor --json

README

bmalph

npm npm downloads license node CI codecov

BMAD-METHOD planning + Ralph autonomous implementation, wired through platform-specific instructions, skills, and command indexes.

bmalph workflow diagram

What is bmalph?

bmalph bundles and installs two AI development systems:

  • BMAD-METHOD — Planning agents and workflows (Phases 1-3)
  • Ralph — Autonomous implementation loop (Phase 4)

bmalph provides:

  • bmalph init — Install both systems
  • bmalph upgrade — Update to latest versions
  • bmalph doctor — Check installation health
  • bmalph implement — Transition from BMAD to Ralph
  • bmalph run — Start Ralph loop with live dashboard
  • bmalph check-updates — Check for upstream updates
  • bmalph status — Show project status and phase
  • bmalph reset — Remove all bmalph files
  • bmalph watch(deprecated) Use bmalph run instead

Supported Platforms

bmalph works with multiple AI coding assistants. Each platform gets BMAD planning (Phases 1-3). The Ralph autonomous loop (Phase 4) requires a CLI-based platform.

PlatformIDTierInstructions FileCommands
Claude Codeclaude-codefullCLAUDE.md.claude/commands/ directory
OpenAI CodexcodexfullAGENTS.mdCodex Skills (.agents/skills/)
OpenCodeopencodefullAGENTS.mdOpenCode Skills (.opencode/skills/)
Cursorcursorfull (experimental).cursor/rules/bmad.mdc_bmad/COMMANDS.md
Windsurfwindsurfinstructions-only.windsurf/rules/bmad.md_bmad/COMMANDS.md
GitHub Copilotcopilotfull (experimental).github/copilot-instructions.md_bmad/COMMANDS.md
Aideraiderinstructions-onlyCONVENTIONS.md_bmad/COMMANDS.md

Tiers:

  • full — Phases 1-4. BMAD planning + Ralph autonomous implementation loop.
  • instructions-only — Phases 1-3. BMAD planning only. Ralph is not available.

Prerequisites

  • Node.js 20+
  • Bash (WSL or Git Bash on Windows)
  • A supported AI coding platform (see table above)
  • For Ralph loop (Phase 4): Claude Code (claude), Codex CLI (codex), OpenCode (opencode), Copilot CLI (copilot), or Cursor CLI (cursor-agent; older agent installs are also supported)

Installation

npm install -g bmalph

Quick Start

cd my-project
bmalph init --name my-project

# To target a specific platform, add --platform (e.g. codex, cursor, windsurf)
# Without --platform, bmalph auto-detects strong project markers and
# prompts interactively when detection is ambiguous or missing

Workflow

Step 1: Initialize

cd my-project
bmalph init

Platform resolution: --platform flag > auto-detect from project markers > interactive prompt > default claude-code

Strong markers such as .cursor/, .claude/, .opencode/, .windsurf/, .github/copilot-instructions.md, and .aider.conf.yml are auto-detected directly. Root-only AGENTS.md and CLAUDE.md are treated as weak hints and may still trigger the interactive platform prompt.

This installs:

  • _bmad/ — BMAD agents and workflows
  • .ralph/ — Ralph loop, libs, templates (drivers for claude-code, codex, opencode, copilot, and cursor)
  • bmalph/ — State management (config.json, stores selected platform)
  • Updates the platform's instructions file with BMAD workflow instructions (e.g. CLAUDE.md, AGENTS.md, .cursor/rules/bmad.mdc)
  • Delivers BMAD commands using the platform's native mechanism (Claude Code: .claude/commands/; Codex: .agents/skills/; OpenCode: .opencode/skills/; Cursor, Windsurf, Copilot, and Aider: _bmad/COMMANDS.md)

Migrating from standalone BMAD

If you already have BMAD installed (a _bmad/ directory), bmalph init works as a migration path:

  • _bmad/ (framework files) will be replaced with the bmalph-managed version
  • _bmad-output/ (your planning artifacts: PRDs, architecture, stories) is not touched
  • If you've customized framework files inside _bmad/, commit first so you can review changes with git diff

Step 2: Plan with BMAD (Phases 1-3)

Work interactively with BMAD agents in your AI coding assistant.

  • Claude Code — use /bmalph to see your current phase and available commands.
  • OpenAI Codex — use Codex Skills such as $analyst and $create-prd.
  • Cursor — Read _bmad/COMMANDS.md and ask Cursor to run the BMAD master agent.
  • Windsurf, Copilot, Aider — use _bmad/COMMANDS.md as the command reference and ask the assistant to follow the named BMAD workflow.
PhaseAgentCommands
1 AnalysisAnalystBP, MR, DR, TR, CB
2 PlanningPM / UX DesignerCP, VP, EP, CU
3 SolutioningArchitect / PMCA, CE, IR

Validation commands (validate-brief, validate-prd, validate-ux, validate-architecture, validate-epics-stories) run the same workflow in Validate mode. In Claude Code, invoke them as slash commands; on other platforms use the equivalent entry from _bmad/COMMANDS.md or Codex Skills.

Phase 1 — Analysis

  • BP Brainstorm Project — guided facilitation through brainstorming techniques
  • MR Market Research — market analysis, competitive landscape, customer needs
  • DR Domain Research — industry domain deep dive
  • TR Technical Research — technical feasibility, architecture options
  • CB Create Brief — guided experience to nail down your product idea

Phase 2 — Planning

  • CP Create PRD — expert led facilitation to produce your PRD (required)
  • VP Validate PRD — validate PRD is comprehensive and cohesive
  • EP Edit PRD — improve and enhance an existing PRD
  • CU Create UX — guidance through realizing the plan for your UX

Phase 3 — Solutioning

  • CA Create Architecture — guided workflow to document technical decisions (required)
  • CE Create Epics and Stories — create the epics and stories listing (required)
  • IR Implementation Readiness — ensure PRD, UX, architecture, and stories are aligned (required)

Anytime Commands

Available in any phase for supporting tasks:

  • QS Quick Spec — lightweight spec for small tasks without full planning
  • QD Quick Dev — quick implementation for small tasks
  • DP Document Project — analyze existing project to produce documentation
  • GPC Generate Project Context — scan codebase to generate LLM-optimized context
  • CC Correct Course — navigate significant changes mid-project
  • WD Write Document — tech writer agent for documentation
  • MG Mermaid Generate — create Mermaid diagrams
  • VD Validate Document — review documents against standards
  • BSP Brainstorming — interactive idea generation techniques (core, distinct from BP)
  • ID Index Docs — create lightweight doc index for LLM scanning
  • SD Shard Document — split large documents into smaller files
  • ES Editorial Review (Structure) — propose document reorganization
  • AR Adversarial Review — critical content review for QA
  • US Update Standards — update tech-writer documentation standards
  • EC Explain Concept — create technical explanations with examples
  • _bmad/COMMANDS.md — generated command reference for platforms without native slash commands

Note: EP means Edit PRD in the bmm workflow (Phase 2) and Editorial Review — Prose in the core module. PM is Party Mode in core. The bmm meanings are the primary workflow codes.

Step 3: Implement with Ralph (Phase 4)

Note: Ralph is only available on full tier platforms (Claude Code, OpenAI Codex, OpenCode, GitHub Copilot, Cursor). Instructions-only platforms (Windsurf, Aider) support Phases 1-3 only. GitHub Copilot and Cursor support is experimental.

Run bmalph implement from the terminal, or use the /bmalph-implement slash command in Claude Code.

This transitions your BMAD artifacts into Ralph's format:

  1. Reads your stories from BMAD output
  2. Generates .ralph/@fix_plan.md with ordered tasks
  3. Copies specs to .ralph/specs/ with changelog tracking
  4. Instructs you to start the Ralph autonomous loop

Then start Ralph:

bmalph run

Advanced: Ralph loads the platform drivers internally. Start the loop with bmalph run, or run bash .ralph/ralph_loop.sh directly if you need to bypass the CLI.

Ralph picks stories one by one, implements with TDD, and commits. The loop stops when all stories are done or the circuit breaker triggers.

Incremental Development

bmalph supports iterative development cycles:

BMAD (Epic 1) → bmalph implement → Ralph works on Epic 1
     ↓
BMAD (add Epic 2) → bmalph implement → Ralph sees changes + picks up Epic 2

Smart Merge: When you run bmalph implement again after Ralph has made progress:

  • Completed stories ([x]) are preserved in the new fix_plan
  • New stories from BMAD are added as pending ([ ])

Specs Changelog: .ralph/SPECS_CHANGELOG.md shows what changed in specs since the last run, so Ralph knows what's new or modified.

CLI Reference

CommandDescription
bmalph initInstall BMAD + Ralph into project
bmalph upgradeUpdate bundled assets to current version
bmalph doctorCheck installation health
bmalph check-updatesCheck if bundled BMAD/Ralph versions are up to date
bmalph statusShow current project status and phase
bmalph implementTransition BMAD planning artifacts to Ralph format
bmalph runStart Ralph loop with live dashboard
bmalph resetRemove all bmalph files from the project
bmalph watch(deprecated) Use bmalph run instead

Global options

FlagDescription
--verboseEnable debug logging
--no-colorDisable colored output
--quietSuppress non-essential output
-C, --project-dir <path>Run in specified directory
--versionShow version
--helpShow help

init options

FlagDescriptionDefault
-n, --name <name>Project namedirectory name
-d, --description <desc>Project description(prompted)
--platform <id>Target platform (claude-code, codex, opencode, cursor, windsurf, copilot, aider)auto-detect
--dry-runPreview changes without writing files

implement options

FlagDescription
--forceOverride pre-flight validation errors

check-updates options

FlagDescription
--jsonOutput as JSON

doctor options

FlagDescription
--jsonOutput as JSON

status options

FlagDescription
--jsonOutput as JSON

upgrade options

FlagDescription
--forceSkip confirmation prompts
--dry-runPreview changes

reset options

FlagDescription
--dry-runPreview changes
--forceSkip confirmation prompt

run options

FlagDescription
--driver <platform>Override platform driver (claude-code, codex, opencode, copilot, cursor)
--review [mode]Quality review: enhanced (every 5 loops) or ultimate (every story). Claude Code only
--interval <ms>Dashboard refresh interval in milliseconds (default: 2000)
--no-dashboardRun Ralph without the dashboard overlay
--swarm [count]Run N parallel workers in git worktrees (default: 2, max: 6). Requires >= 2 epics

watch options

Deprecated: Use bmalph run instead. The watch command will be removed in a future release.

FlagDescription
--interval <ms>Refresh interval in milliseconds (default: 2000)

Command Delivery

bmalph bundles 54 BMAD and bmalph command definitions. Delivery varies by platform:

  • Claude Code — installed as files in .claude/commands/ (invoke with /command-name)
  • OpenAI Codex — delivered as Codex Skills in .agents/skills/ (invoke with $command-name)
  • OpenCode — delivered as OpenCode Skills in .opencode/skills/
  • Cursor — discoverable via _bmad/COMMANDS.md; ask Cursor to run the BMAD master agent
  • Windsurf, Copilot, Aider — discoverable via _bmad/COMMANDS.md reference index

Key commands (Claude Code syntax):

CommandDescription
/bmalphBMAD master agent — navigate phases
/analystAnalyst agent
/pmProduct Manager agent
/architectArchitect agent
/devDeveloper agent
/smScrum Master agent
/qaQA agent
/ux-designerUX Designer agent
/tech-writerTech Writer agent
/quick-flow-solo-devQuick Flow solo developer agent
/create-prdCreate PRD workflow
/create-architectureCreate architecture workflow
/create-epics-storiesCreate epics and stories
/bmad-helpList all BMAD commands

For the full list:

  • Claude Code: run /bmad-help
  • OpenAI Codex: inspect .agents/skills/
  • OpenCode: inspect .opencode/skills/
  • Cursor, Windsurf, Copilot, Aider: open _bmad/COMMANDS.md

Transition to Ralph

Use bmalph implement (or /bmalph-implement in Claude Code) to transition from BMAD planning to Ralph implementation.

Project Structure (after init)

project/
├── _bmad/                     # BMAD agents, workflows, core
│   ├── config.yaml            # Generated platform/project config
│   ├── COMMANDS.md            # Generated command reference index
│   ├── _config/               # Generated manifests
│   │   ├── task-manifest.csv  # Combined task manifest
│   │   ├── workflow-manifest.csv # Combined workflow manifest
│   │   └── bmad-help.csv      # Combined help manifest
│   ├── core/
│   │   ├── agents/            # Master agent
│   │   ├── tasks/             # Workflow tasks
│   │   ├── workflows/         # Brainstorming, party-mode, etc.
│   │   ├── module.yaml        # Core module metadata
│   │   └── module-help.csv    # Core module help entries
│   └── bmm/
│       ├── agents/            # Analyst, PM, Architect, Dev, QA, etc.
│       ├── data/              # Templates (project-context-template.md)
│       ├── workflows/         # Phase 1-4 workflows
│       ├── teams/             # Agent team definitions
│       ├── module.yaml        # BMM module metadata
│       └── module-help.csv    # BMM module help entries
├── _bmad-output/              # BMAD planning artifacts (generated)
│   ├── planning-artifacts/    # PRD, architecture, stories
│   ├── implementation-artifacts/ # Sprint plans (optional)
│   └── brainstorming/         # Brainstorm sessions (optional)
├── .ralph/                    # Ralph autonomous loop (drivers for claude-code, codex, opencode, copilot, and cursor)
│   ├── ralph_loop.sh          # Main loop script
│   ├── ralph_import.sh        # Import requirements into Ralph
│   ├── ralph_monitor.sh       # Monitor loop progress
│   ├── .ralphrc               # Ralph configuration
│   ├── RALPH-REFERENCE.md     # Ralph usage reference
│   ├── drivers/               # Platform driver scripts
│   │   ├── claude-code.sh     # Claude Code driver (uses `claude`)
│   │   ├── codex.sh           # OpenAI Codex driver (uses `codex exec`)
│   │   ├── opencode.sh        # OpenCode driver (uses `opencode run`)
│   │   ├── copilot.sh         # GitHub Copilot driver (uses `copilot`, experimental)
│   │   ├── cursor.sh          # Cursor driver (uses `cursor-agent`/`agent`, experimental)
│   │   └── cursor-agent-wrapper.sh # Wrapper for Windows .cmd Cursor installs
│   ├── lib/                   # Shell libraries
│   ├── docs/generated/        # Generated documentation
│   ├── specs/                 # Copied from _bmad-output during transition
│   ├── logs/                  # Loop execution logs
│   ├── PROMPT.md              # Iteration prompt template
│   ├── PROJECT_CONTEXT.md     # Extracted project context (after bmalph implement)
│   ├── SPECS_CHANGELOG.md     # Spec diff since last run (after bmalph implement)
│   ├── SPECS_INDEX.md         # Prioritized spec file index (after bmalph implement)
│   ├── @AGENT.md              # Agent build instructions
│   └── @fix_plan.md           # Generated task list (after bmalph implement)
├── bmalph/                    # State management
│   ├── config.json            # Project config (name, description, platform)
│   └── state/                 # Phase tracking data
├── .claude/                   # Claude Code specific
│   └── commands/              # Slash commands (claude-code only)
└── <instructions file>        # Varies by platform (see Supported Platforms)

The instructions file and command directory depend on the configured platform. See the Supported Platforms table for details.

How Ralph Works

Ralph is a bash loop that spawns fresh AI coding sessions using a platform driver matching the configured platform:

  • Claude Code driver — invokes claude with --output-format json, --permission-mode bypassPermissions, --allowedTools, and explicit --resume <session_id>
  • Codex driver — invokes codex exec --json --sandbox workspace-write with explicit --resume <session_id>
  • OpenCode driver — invokes opencode run --agent build --format json with optional --continue --session <session_id>
  • Copilot driver (experimental) — invokes copilot --autopilot --yolo with plain-text output
  • Cursor driver (experimental) — invokes cursor-agent -p --force --output-format json, persists session_id for --resume, and switches to stream-json only for live output

Each iteration:

  1. Pick the next unchecked story from @fix_plan.md
  2. Implement with TDD (tests first, then code)
  3. Commit the changes
  4. Move to the next story

Safety mechanisms:

  • Circuit breaker — prevents infinite loops on failing stories
  • Response analyzer — detects stuck or repeating outputs
  • Code review — optional quality review (--review [mode], Claude Code only). Enhanced: periodic review every 5 loops. Ultimate: review after every completed story. A read-only session analyzes git diffs and feeds structured findings into the next implementation loop
  • Completion — loop exits when all @fix_plan.md items are checked off

Cursor-specific runtime checks:

  • bmalph doctor validates command -v jq in the bash environment Ralph uses
  • bmalph doctor validates command -v cursor-agent and cursor-agent status
  • bmalph run --driver cursor runs the same bash-scoped preflight before the loop starts

Run bmalph run to start the loop with a live dashboard, or bmalph run --no-dashboard for headless mode. Press Ctrl+C to stop the loop at any time.

Swarm Mode (Parallel Workers)

bmalph run --swarm [N] spawns N Ralph loops in isolated git worktrees, each working on different epics simultaneously. Stories are partitioned by epic using greedy bin-packing for balanced distribution.

  • Each worker gets its own @fix_plan.md with only its assigned stories
  • Workers run on separate branches (swarm/worker-1, swarm/worker-2, etc.)
  • Rate limits are divided across workers; starts are staggered by 5s
  • After all workers complete, branches are merged back sequentially
  • .ralph/ state is excluded from merges; the fix plan is rebuilt from combined completions
  • On source code conflict, the merge stops and branches are preserved for manual resolution

Requirements: clean working tree, at least 2 incomplete epics, full-tier platform, not on detached HEAD.

Troubleshooting

Windows: Bash Not Found

Ralph requires bash to run. On Windows, install one of:

Git Bash (Recommended)

# Install Git for Windows from https://git-scm.com/downloads
# Git Bash is included and works well with bmalph
# bmalph prefers Git Bash over broken Windows bash.exe shims

WSL (Windows Subsystem for Linux)

# In PowerShell as Administrator
wsl --install
# Then restart and run bmalph from WSL terminal

Permission Denied

If you get permission errors:

# Claude Code only: broaden the tool allowlist in the managed config
# .ralph/.ralphrc
ALLOWED_TOOLS="Write,Read,Edit,MultiEdit,Glob,Grep,Task,TodoWrite,WebFetch,WebSearch,EnterPlanMode,ExitPlanMode,NotebookEdit,Bash"

# Keep interactive approval workflows out of unattended Claude loops
CLAUDE_PERMISSION_MODE="bypassPermissions"

# Keep the loop unattended by continuing after detected denials
PERMISSION_DENIAL_MODE="continue"

# Reset stale session state an

Files in the repo

Repository payload29 top-level entries
  • __mocks__
  • .claude
  • .github
  • bin
  • bmad
  • docs
  • ralph
  • scripts
  • slash-commands
  • src
  • tests
  • .gitattributes
  • .gitignore
  • .prettierignore
  • .prettierrc
  • .release-please-manifest.json
  • bundled-versions.json
  • CHANGELOG.md
  • CLAUDE.md
  • CONTRIBUTING.md
  • eslint.config.js
  • LICENSE
  • package-lock.json
  • package.json
  • README.md
  • release-please-config.json
  • tsconfig.json
  • vitest.config.e2e.ts
  • vitest.config.ts

Discussion (0)

Ask about usage, or say what you built with it

Sign in to join the discussion.

No comments yet. Be the first to say what this is good for.

More harnesses

affaan-m/
ECC
affaan-m/ECCHarnesses

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

258k
ruvnet/rufloHarnesses

🌊 The original agent meta-harness. Deploy intelligent multi-player swarms, coordinate autonomous workflows, and build conversational AI systems. Features adaptive memory, self-learning intelligence, RAG integration, and native Claude Code / Codex / Hermes and many more Integrated

72k

Practical patterns, starters & CLI tools for loop engineering with AI coding agents. Design systems that prompt and orchestrate agents (inspired by Addy Osmani and Boris Cherny). Includes loop-audit, loop-init, loop-cost.

11k