worktree-pr

Manage git worktrees with PR workflow and multi-agent review (Claude + Codex). Use when developing features in isolation with easy rollback.

108 stars

Best use case

worktree-pr is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Manage git worktrees with PR workflow and multi-agent review (Claude + Codex). Use when developing features in isolation with easy rollback.

Teams using worktree-pr should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/worktree-pr/SKILL.md --create-dirs "https://raw.githubusercontent.com/alfredolopez80/multi-agent-ralph-loop/main/.claude/skills/worktree-pr/skill.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/worktree-pr/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How worktree-pr Compares

Feature / Agentworktree-prStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Manage git worktrees with PR workflow and multi-agent review (Claude + Codex). Use when developing features in isolation with easy rollback.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

Related Guides

SKILL.md Source

# Git Worktree + PR Workflow

## v2.88 Key Changes (MODEL-AGNOSTIC)

- **Model-agnostic**: Uses model configured in `~/.claude/settings.json` or CLI/env vars
- **No flags required**: Works with the configured default model
- **Flexible**: Works with GLM-5, Claude, Minimax, or any configured model
- **Settings-driven**: Model selection via `ANTHROPIC_DEFAULT_*_MODEL` env vars

**ultrathink** - Take a deep breath. We're not here to write code. We're here to make a dent in the universe.

## The Vision
Isolation should make every change safer and more inevitable.

## Your Work, Step by Step
1. **Decide isolation**: Confirm if a worktree is needed.
2. **Create worktree**: One feature, one isolated workspace.
3. **Coordinate work**: Keep subagents aligned in one tree.
4. **Review & PR**: Multi-agent review before merge.
5. **Cleanup**: Merge or close with clean rollback.

## Ultrathink Principles in Practice
- **Think Different**: Use isolation to de-risk change.
- **Obsess Over Details**: Keep contexts and branches consistent.
- **Plan Like Da Vinci**: Map the PR flow before execution.
- **Craft, Don't Code**: Prefer small, clean diffs.
- **Iterate Relentlessly**: Fix and re-review until clean.
- **Simplify Ruthlessly**: Remove unnecessary branches.

# Git Worktree + PR Workflow (v2.20)

## Overview

This skill enables isolated feature development using git worktrees with a PR-based merge workflow and multi-agent code review.

**Key Principles:**
- **ONE worktree per feature/task** (not per subagent)
- Multiple subagents work in the **same** worktree
- Human-in-the-loop via `AskUserQuestion` for isolation decisions
- Easy rollback by closing PR and deleting worktree

## Prerequisites

- **WorkTrunk**: `brew install max-sixty/worktrunk/wt`
- **GitHub CLI**: `brew install gh`
- **Codex CLI**: For GPT-5 reviews

## Commands

| Command | Description |
|---------|-------------|
| `ralph worktree <task>` | Create isolated worktree + launch Claude |
| `ralph worktree-pr <branch>` | Create PR with Claude + Codex review |
| `ralph worktree-merge <pr>` | Approve and merge PR |
| `ralph worktree-fix <pr>` | Apply fixes from review comments |
| `ralph worktree-close <pr>` | Close PR and cleanup without merge |
| `ralph worktree-status` | Show all worktrees and PR status |
| `ralph worktree-cleanup` | Clean up merged worktrees |

## Workflow

### 1. Create Isolated Worktree

```bash
ralph worktree "implement oauth authentication"
# Creates: .worktrees/ai-ralph-20260103-implement-oauth-authentication/
# Branch: ai/ralph/20260103-implement-oauth-authentication
```

### 2. Develop Feature

All subagents work in the **same** worktree:
- Backend developer → `src/api/oauth.ts`
- Frontend developer → `src/ui/login.tsx`
- Test architect → `tests/oauth.test.ts`
- Docs writer → `docs/oauth.md`

Each subagent makes local commits but does NOT push.

### 3. Create PR with Multi-Agent Review

```bash
ralph worktree-pr ai/ralph/20260103-implement-oauth-authentication
```

This will:
1. Push branch to origin
2. Create draft PR
3. Get Claude Opus review (logic, edge cases, quality)
4. Get Codex GPT-5 review (security, performance)
5. Post reviews as PR comments
6. Show approval/rejection status

### 4. Handle Review Feedback

**If reviews pass:**
```bash
ralph worktree-merge <pr-number>
# Squash merges, deletes branch, cleans up worktree
```

**If reviews find issues:**
```bash
ralph worktree-fix <pr-number>
# Opens Claude in worktree with review comments as context
```

**If you want to abandon:**
```bash
ralph worktree-close <pr-number>
# Closes PR, deletes branch, cleans up worktree
```

## When to Use Worktrees

### Good Candidates
- New feature with multiple components
- Refactoring >5 files
- Experimental or risky changes
- Changes that may need rollback

### Not Needed
- Single-line hotfixes
- Documentation typo fixes
- Config adjustments
- Clear, simple tasks

## Orchestrator Integration

The orchestrator automatically asks about worktree isolation (Step 2b):

```yaml
AskUserQuestion:
  questions:
    - question: "¿Este cambio requiere un worktree aislado?"
      header: "Isolation"
      multiSelect: false
      options:
        - label: "Sí, crear worktree"
          description: "Feature nueva, refactor grande, cambio experimental"
        - label: "No, branch actual"
          description: "Hotfix, cambio menor, ajuste simple"
```

## Subagent Context

When working in a worktree, subagents receive:

```yaml
WORKTREE_CONTEXT:
  path: .worktrees/ai-ralph-YYYYMMDD-feature/
  branch: ai/ralph/YYYYMMDD-feature
  isolated: true
```

Subagent rules:
1. Work in the specified path
2. Make frequent local commits
3. **DO NOT push** - orchestrator manages PR
4. Coordinate with other subagents
5. Signal completion: `SUBAGENT_COMPLETE: [description]`

## Security

Each worktree has hardened security:
- Hooks disabled (`core.hooksPath → .git-hooks-disabled`)
- Credentials disabled per worktree
- Push configured for `current` branch only

## Example Session

```bash
# User request: "Add OAuth authentication"

# Orchestrator asks about worktree
> ¿Este cambio requiere un worktree aislado?
> [Sí, crear worktree] ← User selects

# Create worktree
$ ralph worktree "oauth-authentication"
✓ Created worktree: .worktrees/ai-ralph-20260103-oauth-authentication
✓ Branch: ai/ralph/20260103-oauth-authentication
✓ Security hardening applied

# Subagents work in parallel in SAME worktree
# ... backend, frontend, tests, docs ...

# All subagents complete
# Orchestrator creates PR with review
$ ralph worktree-pr ai/ralph/20260103-oauth-authentication
✓ Pushed to origin
✓ Created PR #42
✓ Claude review: APPROVED
✓ Codex review: APPROVED with suggestions

# User decides to merge
$ ralph worktree-merge 42
✓ PR #42 merged (squash)
✓ Branch deleted
✓ Worktree cleaned up
```

## Troubleshooting

### WorkTrunk not found
```bash
brew install max-sixty/worktrunk/wt
wt config shell install
source ~/.zshrc
```

### PR creation fails
```bash
gh auth status  # Verify GitHub auth
gh auth login   # Re-authenticate if needed
```

### Worktree conflicts
```bash
git worktree prune  # Clean orphaned metadata
ralph worktree-status  # Check current state
```

Related Skills

vercel-react-best-practices

108
from alfredolopez80/multi-agent-ralph-loop

React and Next.js performance optimization guidelines from Vercel Engineering. Use when writing, reviewing, or refactoring React/Next.js code. Triggers on tasks involving React components, Next.js pages, data fetching, bundle optimization, or performance improvements.

vault

108
from alfredolopez80/multi-agent-ralph-loop

Living knowledge base management. Actions: search (query vault), save (store learning), index (update indices), compile (raw->wiki->rules graduation), init (create vault structure). Follows Karpathy pipeline: ingest->compile->query. Use when: (1) searching accumulated knowledge, (2) saving learnings, (3) compiling raw notes into wiki, (4) initializing a new vault. Triggers: /vault, 'vault search', 'knowledge base', 'save learning'.

testing-anti-patterns

108
from alfredolopez80/multi-agent-ralph-loop

Custom skill for testing-anti-patterns

task-visualizer

108
from alfredolopez80/multi-agent-ralph-loop

Visualize task dependencies and progress (Gastown-style)

task-classifier

108
from alfredolopez80/multi-agent-ralph-loop

Classifies task complexity (1-10) for model and agent routing

task-batch

108
from alfredolopez80/multi-agent-ralph-loop

Autonomous batch task execution with PRD parsing, task decomposition, and continuous execution until all tasks complete. Uses /orchestrator internally. Stops only for major failures (no internet, token limit, system crash). Use when: (1) processing task lists autonomously, (2) PRD-driven development, (3) batch feature implementation. Triggers: /task-batch, 'batch tasks', 'process PRD', 'run task queue'.

tap-explorer

108
from alfredolopez80/multi-agent-ralph-loop

Tree of Attacks with Pruning for systematic code analysis

stop-slop

108
from alfredolopez80/multi-agent-ralph-loop

A skill for removing AI-generated writing patterns ('slop') from prose. Eliminates telltale signs of AI writing like filler phrases, excessive hedging, overly formal language, and mechanical sentence structures. Use when: writing content that should sound human and natural, editing AI-generated drafts, cleaning up prose for publication, or any content that needs to sound authentic rather than AI-generated. Triggers: 'stop-slop', 'remove AI tells', 'clean up prose', 'make it sound human', 'edit AI writing'.

spec

108
from alfredolopez80/multi-agent-ralph-loop

Produce a verifiable technical specification before coding. 6 mandatory sections: Interfaces, Behaviors, Invariants (from Aristotle Phase 2), File Plan, Test Plan, Exit Criteria (executable bash commands + expected results). Use when: (1) before implementing features with complexity > 4, (2) as Step 1.5 in orchestrator workflow, (3) when requirements need formalization. Triggers: /spec, 'create spec', 'write specification', 'technical spec'.

smart-fork

108
from alfredolopez80/multi-agent-ralph-loop

Smart Forking - Find and fork from relevant historical sessions using parallel memory search across vault, memvid, handoffs, and ledgers

ship

108
from alfredolopez80/multi-agent-ralph-loop

Pre-launch shipping checklist orchestrating /gates, /security, /browser-test, /perf. Ensures nothing ships without passing all quality checks. Use when: (1) before deploying, (2) before merging to main, (3) before release. Triggers: /ship, 'ship it', 'ready to deploy', 'pre-launch check'.

senior-software-engineer

108
from alfredolopez80/multi-agent-ralph-loop

Global skill enforcing senior software engineering best practices