Plan-Apply-Unify Loop โ Structured AI-assisted development for OpenCode.
npx openpaul
Works on Mac, Windows, and Linux.
"Quality over speed-for-speed's-sake. In-session context over subagent sprawl."
๐ Documentation ยท Why OpenPAUL ยท Getting Started ยท The Loop ยท Commands
OpenPAUL is an OpenCode adaptation of the Plan-Apply-Unify Loop project, originally created by Chris Kahler for Claude Code.
I build with Claude Code every day. It's incredibly powerful โ when you give it the right context.
The problem? Context rot. As your session fills up, quality degrades. Subagents spawn with fresh context but return ~70% quality work that needs cleanup. Plans get created but never closed. State drifts. You end up debugging AI output instead of shipping features.
OpenPAUL fixes this with three principles:
Loop integrity โ Every plan closes with UNIFY. No orphan plans. UNIFY reconciles what was planned vs what happened, updates state, logs decisions. This is the heartbeat.
In-session context โ Subagents are expensive and produce lower quality for implementation work. OpenPAUL keeps development in-session with properly managed context. Subagents are reserved for discovery and research โ their job IS to gather context.
Acceptance-driven development โ Acceptance criteria are first-class citizens, not afterthoughts. Define done before starting. Every task references its AC. BDD format: Given [precondition] / When [action] / Then [outcome].
The complexity is in the system, not your workflow. Behind the scenes: structured state management, XML task formatting, loop enforcement. What you see: a few commands that keep you on track.
AI-assisted developers who want structure without bureaucracy.
You describe what you want, OpenCode builds it, and OpenPAUL ensures:
No sprint ceremonies. No story points. No enterprise theater. Just a system that keeps AI-assisted development reliable.
This makes openpaul available in every OpenCode session on your machine.
~/.config/opencode/opencode.json.{
"plugins": {
"npm": [
"openpaul"
]
}
}
~/.cache/opencode/node_modules/ and load them.This limits openpaul to a specific project.
opencode.json:{
"plugins": {
"npm": [
"openpaul"
]
}
}
./opencode.json.Run /openpaul:help inside OpenCode to verify installation.
For the best experience, use OpenPAUL with OpenCARL (github.com/KrisGray/opencarl) โ a dynamic rule injection system that enforces OpenPAUL workflow discipline automatically.
// ~/.config/opencode/opencode.json
{
"plugins": {
"npm": [
"openpaul",
"@krisgray/opencarl"
]
}
}
YOU: I want to add a dark mode toggle to my React app
# OpenCARL auto-loads OpenPAUL rules when it detects .openpaul/
YOU: /openpaul:init
OpenPAUL: โ Created .openpaul/ with PROJECT.md, ROADMAP.md, STATE.md
YOU: /openpaul:plan
OpenPAUL: Describe what you're building...
YOU: Dark mode toggle that:
- Remembers preference in localStorage
- Defaults to system preference
- Toggles without page reload
OpenPAUL: Created PLAN.md with:
โ Objective: Add persistent dark mode toggle
โ AC-1: Given user visits, When no preference, Then use system
โ AC-2: Given user clicks toggle, When in light, Then switch to dark
โ Task 1: Create ThemeContext
โ Task 2: Add CSS variables
โ Task 3: Create ThemeToggle component
โ Boundary: DO NOT change auth components
YOU: Looks good. /openpaul:apply
OpenPAUL:
โ Task 1: Created ThemeContext (verified: imports work)
โ Task 2: Added CSS variables (verified: themes render)
โ Task 3: Created ThemeToggle (verified: toggle works)
YOU: /openpaul:unify
OpenPAUL:
โ Created SUMMARY.md
โ Updated STATE.md
โ Recorded 3 decisions
Done! Loop complete. State preserved for next session.
| Without OpenCARL | With OpenCARL |
|---|---|
| Manual workflow discipline | Auto-enforced loop rules |
| Easy to skip UNIFY | Blocked from skipping |
| Context bloat | Rules load on-demand |
| Inconsistent quality | Consistent enforcement |
Here's a complete workflow example showing OpenPAUL in action:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ YOU: I need to add user authentication to my app โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ STEP 1: Initialize OpenPAUL โ
โ โ
โ /openpaul:init โ
โ โ
โ Creates: .openpaul/ directory with PROJECT.md, ROADMAP.md, โ
โ STATE.md, and phases/ folder โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ STEP 2: Plan Your Work โ
โ โ
โ /openpaul:plan โ
โ โ
โ OpenPAUL prompts you to describe what you want to build, โ
โ then generates a structured PLAN.md with: โ
โ - Objective (what & why) โ
โ - Acceptance Criteria (Given/When/Then) โ
โ - Tasks with files, actions, verification steps โ
โ - Boundaries (what NOT to change) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ STEP 3: Review & Approve โ
โ โ
โ YOU: The plan looks good, let's do it โ
โ โ
โ (Or: "Actually, I also need password reset" โ plan updated) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ STEP 4: Execute the Plan โ
โ โ
โ /openpaul:apply โ
โ โ
โ Tasks execute sequentially: โ
โ โ Task 1: Create User model (verified: tests pass) โ
โ โ Task 2: Add login endpoint (verified: curl returns 200) โ
โ โ Task 3: Create login UI (verified: renders correctly) โ
โ โธ Task 4: Checkpoint โ Verify login flow manually? โ
โ โ
โ YOU: approved โ
โ โ
โ โ Task 5: Add session management โ
โ โ All tasks complete โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ STEP 5: Close the Loop (REQUIRED!) โ
โ โ
โ /openpaul:unify โ
โ โ
โ Creates SUMMARY.md: โ
โ - What was built โ
โ - Plan vs actual comparison โ
โ - Decisions made โ
โ - Issues deferred โ
โ โ
โ Updates STATE.md with: โ
โ - Current position โ
โ - Accumulated decisions โ
โ - Next phase/plan โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ STEP 6: Continue Development โ
โ โ
โ /openpaul:progress โ
โ โ
โ Shows: "Phase 1 complete. Next: Phase 2 - User Profile" โ
โ Suggests: ONE next action โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
YOU: /openpaul:plan
OpenPAUL: What would you like to build?
YOU: I need to add a dark mode toggle to my React app. It should:
- Remember the user's preference in localStorage
- Default to system preference on first visit
- Toggle without page reload
OpenPAUL: [Creates PLAN.md]
## Plan: Dark Mode Toggle
### Objective
Add a persistent dark mode toggle with system preference detection
### Acceptance Criteria
- **AC-1**: Given user visits app, When no preference stored, Then use system preference
- **AC-2**: Given user clicks toggle, When in light mode, Then switch to dark and save
- **AC-3**: Given user returns, When preference stored, Then apply saved preference
### Tasks
1. Create ThemeContext with useLocalStorage hook
2. Add CSS variables for dark/light themes
3. Create ThemeToggle component
4. Integrate into App.tsx
### Boundaries
- DO NOT change: auth-related components, API routes
YOU: Looks good. /openpaul:apply
OpenPAUL: [Executes tasks one by one with verification...]
YOU: /openpaul:unify
OpenPAUL: [Creates SUMMARY.md, updates STATE.md]
Done. Loop complete.
Resume work after a break:
[New session]
YOU: /openpaul:resume
OpenPAUL:
## Session Restored
**Last Session:** 2024-01-15
**Stopped at:** Phase 2, Plan 3 - User Profile
**Status:** 2/4 tasks complete
**What was built:**
- Profile display component
- Edit profile form
**What's next:**
Task 3: Add avatar upload
File: src/components/AvatarUpload.tsx
Action: Create component with drag-drop and crop preview
**Suggested command:** /openpaul:apply .openpaul/phases/02-profile/02-03-PLAN.md
OpenCARL (github.com/KrisGray/opencarl) is a dynamic rule injection system that loads rules based on context. Together, they create a powerful AI-assisted development experience.
| OpenPAUL | OpenCARL |
|---|---|
| Structured workflow (PLAN โ APPLY โ UNIFY) | Dynamic rule injection |
| Guides planning & execution | Loads rules based on context |
| Ensures loop closure | Keeps context lean |
| State persistence | Preferences persistence |
The synergy: OpenCARL loads OpenPAUL-specific rules when you're working in an OpenPAUL project, enforcing workflow discipline without bloating every session.
Add both to your opencode.json:
// ~/.config/opencode/opencode.json (global)
{
"plugins": {
"npm": [
"openpaul",
"@krisgray/opencarl"
]
}
}
Or project-local:
// ./opencode.json (project root)
{
"plugins": {
"npm": [
"openpaul",
"@krisgray/opencarl"
]
}
}
# 1. Initialize both systems
/openpaul:init
/opencarl setup
# 2. OpenCARL detects .openpaul/ directory
# โ Automatically loads OpenPAUL-specific rules:
# - "Loop enforcement (PLAN โ APPLY โ UNIFY)"
# - "Boundary protection for DO NOT CHANGE sections"
# - "Verification required for every task"
# 3. Plan your work
/openpaul:plan
# OpenCARL injects planning rules:
# - "Define acceptance criteria before tasks"
# - "Every task needs files, action, verify, done"
# - "Set boundaries โ what NOT to change"
# 4. Execute the plan
/openpaul:apply
# OpenCARL injects execution rules:
# - "Run tests after implementation changes"
# - "Verify each task before moving on"
# - "Log deviations from plan"
# 5. Close the loop (required!)
/openpaul:unify
# OpenCARL injects closure rules:
# - "Create SUMMARY.md documenting what was built"
# - "Compare plan vs actual"
# - "Record decisions for future sessions"
YOU: /openpaul:plan
OpenPAUL: Creates plan structure...
OpenCARL: [Injects OpenPAUL + Development rules]
โ DEVELOPMENT_RULE_0: Code over explanation - show, don't tell
โ DEVELOPMENT_RULE_1: Prefer editing existing files over creating new
โ OPENPAUL_RULE_0: Loop enforcement - no skipping UNIFY
โ OPENPAUL_RULE_1: Every task needs verification
YOU: [Describe the feature you want]
OpenPAUL: Generates PLAN.md with:
- Objective
- Acceptance Criteria (Given/When/Then)
- Tasks with verification steps
- Boundaries
YOU: /openpaul:apply
OpenPAUL: Executes tasks sequentially...
OpenCARL: [Injects execution rules + context tracking]
โ Running tests after changes
โ Verifying each task
โ Logging deviations
[... work happens ...]
OpenPAUL: Task complete. Checkpoint: Run tests?
YOU: yes
OpenPAUL: Tests pass. Next task...
OpenCARL: [Context depleting โ Injects fresh session rules]
[... more work ...]
YOU: /openpaul:unify
OpenPAUL: Creates SUMMARY.md, updates STATE.md
OpenCARL: [Injects closure rules]
โ Document what was built
โ Compare plan vs actual
โ Record decisions
Done. Loop complete. State preserved for next session.
When OpenCARL detects you're working in an OpenPAUL project:
DO NOT CHANGE sections in plans are sacred.These rules load automatically when you're in .openpaul/ context and disappear when you're not.
If you have an existing project using .paul/ directory:
.paul/ to .openpaul/OpenPAUL will automatically detect and use .openpaul/ for new files while still reading from .paul/ for backward compatibility.
Every unit of work follows this cycle:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ PLAN โโโถ APPLY โโโถ UNIFY โ
โ โ
โ Define Execute Reconcile โ
โ work tasks & close โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Create an executable plan with:
Execute the approved plan:
Close the loop (required!):
Never skip UNIFY. Every plan needs closure. This is what separates structured development from chaos.
OpenPAUL provides 26 commands organized by purpose. Run /openpaul:help for the complete reference.
| Command | What it does |
|---|---|
/openpaul:init |
Initialize OpenPAUL in a project |
/openpaul:plan [phase] |
Create an executable plan |
/openpaul:apply [path] |
Execute an approved plan |
/openpaul:unify [path] |
Reconcile and close the loop |
/openpaul:help |
Show command reference |
/openpaul:status |
Show loop position (deprecated โ use progress) |
| Command | What it does |
|---|---|
/openpaul:pause [reason] |
Create handoff for session break |
/openpaul:resume [path] |
Restore context and continue |
/openpaul:progress [context] |
Smart status + ONE next action |
/openpaul:handoff [context] |
Generate comprehensive handoff |
| Command | What it does |
|---|---|
/openpaul:add-phase <desc> |
Append phase to roadmap |
/openpaul:remove-phase <N> |
Remove future phase |
| Command | What it does |
|---|---|
/openpaul:milestone <name> |
Create new milestone |
/openpaul:complete-milestone |
Archive and tag milestone |
/openpaul:discuss-milestone |
Articulate vision before starting |
| Command | What it does |
|---|---|
/openpaul:discuss <phase> |
Capture decisions before planning |
/openpaul:assumptions <phase> |
See Claude's intended approach |
/openpaul:discover <topic> |
Explore options before planning |
/openpaul:consider-issues |
Triage deferred issues |
| Command | What it does |
|---|---|
/openpaul:research <topic> |
Deploy research agents |
/openpaul:research-phase <N> |
Research unknowns for a phase |
| Command | What it does |
|---|---|
/openpaul:flows |
Configure skill requirements |
/openpaul:config |
View/modify OpenPAUL settings |
/openpaul:map-codebase |
Generate codebase overview |
| Command | What it does |
|---|---|
/openpaul:verify |
Guide manual acceptance testing |
/openpaul:plan-fix |
Plan fixes for UAT issues |
.openpaul/
โโโ PROJECT.md # Project context and requirements
โโโ ROADMAP.md # Phase breakdown and milestones
โโโ STATE.md # Loop position and session state
โโโ config.md # Optional integrations
โโโ SPECIAL-FLOWS.md # Optional skill requirements
โโโ phases/
โโโ 01-foundation/
โ โโโ 01-01-PLAN.md
โ โโโ 01-01-SUMMARY.md
โโโ 02-features/
โโโ 02-01-PLAN.md
โโโ 02-01-SUMMARY.md
STATE.md tracks:
When you resume work, /openpaul:resume reads STATE.md and suggests exactly ONE next action. No decision fatigue.
---
phase: 01-foundation
plan: 01
type: execute
autonomous: true
---
Goal, Purpose, Output
@-references to relevant files
## AC-1: Feature Works
Given [precondition]
When [action]
Then [outcome]
Create login endpoint
src/api/auth/login.ts
Implementation details...
curl command returns 200
## DO NOT CHANGE
- database/migrations/*
- src/lib/auth.ts
Every task has: files, action, verify, done. If you can't specify all four, the task is too vague.
OpenPAUL has a companion: OpenCARL (Context Augmentation & Reinforcement Layer).
OpenCARL is a dynamic rule injection system. Instead of bloating your context with static prompts, OpenCARL loads rules just-in-time based on what you're doing:
| Trigger | Rules Loaded |
|---|---|
Working in .openpaul/ directory |
OpenPAUL domain activates |
| Writing code | DEVELOPMENT rules load |
| Managing projects | PROJECTS rules load |
OpenPAUL-specific rules OpenCARL enforces:
The OpenPAUL domain contains 14 rules that govern structured AI development. They load when you're in an OpenPAUL project, disappear when you're not. Your context stays lean.
Without OpenCARL: You'd need massive static prompts in every session. With OpenCARL: Rules activate when relevant, disappear when not.
Acceptance criteria aren't afterthoughts โ they're the foundation:
Why OpenPAUL minimizes subagents for development work:
| Issue | Impact |
|---|---|
| Launch cost | 2,000-3,000 tokens to spawn |
| Context gathering | Starts fresh, researches from scratch |
| Resynthesis | Results must be integrated back |
| Quality gap | ~70% compared to in-session work |
| Rework | Subagent output often needs cleanup |
When OpenPAUL does use subagents:
For implementation, OpenPAUL keeps everything in-session with proper context management.
The loop isn't optional:
PLAN โโโถ APPLY โโโถ UNIFY
โ โ โ [Loop complete]
OpenPAUL supports modular integrations configured in .openpaul/config.md:
| Integration | Purpose |
|---|---|
| SonarQube | Code quality metrics and issues |
| Future | Linting, CI/CD, test runners |
For projects with specialized requirements, .openpaul/SPECIAL-FLOWS.md defines skills that must be loaded before execution:
## Required Skills
| Skill | Work Type | Priority |
| ---------------- | ------------- | -------- |
| /frontend-design | UI components | required |
| /revops-expert | Landing pages | required |
APPLY blocks until required skills are confirmed loaded.
Commands not found after install?
openpaul is listed in your opencode.json plugins sectionCommands not working as expected?
/openpaul:help to verify installation~/.cache/opencode/node_modules/openpaul/Loop position seems wrong?
.openpaul/STATE.md for current state/openpaul:progress for guided next actionResuming after a break?
/openpaul:resume โ it reads state and handoffs automatically| Ad-hoc | OpenPAUL |
|---|---|
| No structure | Explicit planning gates |
| State drifts | STATE.md tracks everything |
| No closure | Mandatory UNIFY |
| Decisions lost | Decisions logged |
OpenPAUL takes a different approach from GSD:
| Aspect | GSD | OpenPAUL |
|---|---|---|
| Execution | Parallel subagents | In-session context |
| Loop | Optional closure | Mandatory UNIFY |
| Criteria | Embedded in tasks | First-class AC section |
| Rules | Static prompts | CARL dynamic loading |
Same comprehensive coverage, different philosophy. OpenPAUL prioritizes quality over speed-for-speed's-sake. See OPENPAUL-VS-GSD.md for full comparison.
| Traditional | OpenPAUL |
|---|---|
| Documentation-first | Execution-first |
| Human-readable specs | AI-executable prompts |
| Separate from code | Colocated in .openpaul/ |
Plan-Apply-Unify Loop was originally created by Chris Kahler for Claude Code.
OpenPAUL is an OpenCode adaptation, maintained by Kristian Gray.
The original project can be found on Chris Kahler's GitHub profile.
MIT License. See LICENSE for details.
Kristian Gray โ OpenPAUL Maintainer
Original Author โ Chris Kahler (Plan-Apply-Unify Loop creator)
OpenCode is powerful. OpenPAUL makes it reliable.