Claude Integration
LazyJJ integrates with Claude CLI for AI-assisted development workflows.
Prerequisites
Install Claude CLI:
npm install -g @anthropic-ai/claude-codeOptional but recommended:
- tmux - For workspace management
Commands
| Command | Shortcut | Purpose |
|---|---|---|
claude-start | clstart | Create JJ workspace + tmux session |
claude-stop | clstop | Stop and clean up workspace |
claude-resolve | clresolve | Resolve conflicts using Claude |
claude-review | clreview | Review a PR using Claude |
claude-checkpoint | - | Save checkpoint with message |
Workspace Management
Claude workspaces let you have Claude work on your code in an isolated JJ workspace:
# Start a Claude workspacejj claude-start my-feature
# Output:# Started tmux session: my-feature# Attach with: tmux attach -t my-featureThis creates:
- A JJ workspace at
.jj-workspaces/my-feature - A tmux session running Claude
When done:
# Stop and clean upjj claude-stop my-featureConflict Resolution
When you have merge conflicts, Claude can help:
# After a rebase with conflictsjj claude-resolveThis runs Claude on each conflicted file to help resolve it.
PR Review
Have Claude review a pull request:
# Review current PRjj claude-review
# Review specific PRjj claude-review 123Checkpointing
Create checkpoints while working:
# Save your progress with a messagejj claude-checkpoint "got auth working"This describes the current commit and creates a new one.
Why Claude + JJ is Powerful
The combination of Claude and JJ creates unique advantages:
1. Safe Experimentation
JJ’s operation log means Claude can try things without fear. If Claude makes a mistake:
jj undo # Reverse Claude's last actionjj op log # See what Claude didjj op restore <id> # Jump back if needed2. First-Class Conflicts
JJ’s conflict model means Claude can attempt merges or rebases without blocking you. If conflicts arise, they’re just marked—you can keep working.
3. Natural Language → Stack Operations
Claude understands stack-based workflows. You can ask:
- “Split this change into 3 stacked commits”
- “Rebase my stack onto main and resolve conflicts”
- “Edit the second commit in my stack to fix the bug”
Claude can manipulate your stack directly using JJ’s powerful commands.
Workflow Example
A typical AI-assisted development session:
# Start fresh from trunkjj stack-start
# Start a Claude workspace for your featurejj claude-start auth-feature
# Attach to Claude sessiontmux attach -t auth-feature
# ... Claude helps you implement the feature ...
# Checkpoint your work periodicallyjj claude-checkpoint "basic auth flow done"
# When done, stop the workspacejj claude-stop auth-feature
# Review and clean up your commitsjj stack-viewjj squash # if needed
# Create PRjj pr-stack-createTips
Multiple Claude Sessions
You can have multiple Claude workspaces:
jj claude-start feature-ajj claude-start feature-b
# List workspacesjj workspace list
# Attach to specific sessiontmux attach -t feature-aWithout tmux
If you don’t have tmux, claude-start still creates the workspace:
jj claude-start my-feature# tmux not available - start Claude manually in that directory
cd .jj-workspaces/my-featureclaudeCleaning Up Old Workspaces
# List all workspacesjj workspace list
# Forget a workspacejj workspace forget workspace-name
# Remove the directoryrm -rf .jj-workspaces/workspace-name
Ernesto Jiménez