Cookbook
Cookbook
This guide provides practical “recipes” for common scenarios you’ll encounter while using jjj with Jujutsu.
1. Handling Merge Conflicts
When two solutions modify the same lines, Jujutsu will create a conflict. Here’s how to handle it in a jjj context.
- Identify the conflict:
jj statuswill show conflicted files. - Fix the code: Edit the files and resolve the conflicts using standard
jjpatterns. - Update the solution: If the fix was for a solution like “Use connection pooling”, your change is already attached.
- Critique the collision: If the conflict revealed a deeper architectural issue, add a Critique to one or both solutions.
Terminal window jjj critique new "connection pooling" "This approach conflicts with the caching solution's logic." --severity medium
2. Decomposing a Large Feature
Large features should be broken down into manageable problems.
- Create the parent problem:
Terminal window jjj problem new "Build new search infrastructure" - Decompose into sub-problems:
Terminal window jjj problem new "Implement elasticsearch indexing" --parent "search infrastructure"jjj problem new "Create search API endpoint" --parent "search infrastructure" - Solve independently: Team members can now propose solutions for “elasticsearch indexing” and “search API endpoint” in parallel.
3. Self-Review and Draft Critiques
You can use jjj to document your own thought process before presenting code for review.
- Propose your solution:
jjj solution new "Optimistic UI update" --problem "flaky network" - Critique your own work: Document edge cases you’re worried about.
Terminal window jjj critique new "Optimistic UI" "What happens if the network is flaky?" --severity low - Address it: Link your subsequent commits to addressing this critique.
- Signal readiness: When you request a review, the reviewer can see what you’ve already considered.
4. Switching Between Competing Solutions
If you’re trying two different approaches for the same problem:
- Propose both:
Terminal window jjj solution new "Approach A: GraphQL" --problem "API redesign"jjj solution new "Approach B: REST" --problem "API redesign" - Toggle with
jjj resume:Terminal window jjj solution resume "GraphQL" # Switches your jj workspace to this solution's change# ... work on GraphQL approach ...jjj solution resume "REST" # Switches your jj workspace to this solution's change - Withdraw the loser: Once one approach is proven better, withdraw the other with a rationale.
Terminal window jjj solution withdraw "GraphQL" --rationale "GraphQL introduced too much complexity for this use case."
5. Preparing for Code Review
Before requesting a review, use jjj to document your thinking so reviewers have context:
- Submit for review to signal it’s ready for criticism:
Terminal window jjj solution submit "Add search index" - Add self-critiques for known concerns you haven’t fully resolved:
Terminal window jjj critique new "Add search index" "Index rebuild time on large datasets unknown" --severity medium - Assign a reviewer via a review critique:
Terminal window jjj critique new "Add search index" "Review requested" --reviewer @alice - Ask Alice to review: she runs
jjj statusand sees your solution in the REVIEW queue. When she raises a critique, you’ll see it in BLOCKED. When all critiques are resolved, she signs off withjjj solution lgtm "Add search index", and you can approve.
6. Tracking a Milestone
When planning a release, use milestones to group problems and track progress:
- Create the milestone:
Terminal window jjj milestone new "v1.0 Launch" --date 2025-09-01 - Tag problems to the milestone:
Terminal window jjj problem edit "Search is slow" --milestone "v1.0"jjj problem edit "Auth missing" --milestone "v1.0" - Check progress:
This shows which problems are open, in-progress, and solved for each milestone, so you can assess scope and schedule risk.
Terminal window jjj milestone roadmap
7. Handling an Abandoned Solution
If a team member leaves or a solution goes stale, you can cleanly hand it off or close it:
- Check the current state:
Terminal window jjj solution show "Old approach" - Reassign to yourself to pick it up:
Terminal window jjj solution assign "Old approach"jjj solution resume "Old approach" # Switch your workspace to this change - Or withdraw it with a rationale if the approach is no longer viable:
Terminal window jjj solution withdraw "Old approach" --rationale "Superseded by the new caching architecture."
8. Detecting File Overlaps Early
When multiple solutions modify the same files, merge conflicts are likely. Detect them before they happen:
# Check for overlapping filesjjj overlapsIf overlaps exist, you have several options:
- Coordinate: Talk to the other solution’s author and agree on an approach.
- Sequence: Withdraw one solution, approve the other first, then rebase.
- Critique: Raise a critique on one of the solutions noting the conflict risk.
Terminal window jjj critique new "connection pooling" "Overlaps with caching solution on src/db/pool.rs" --severity medium
The jjj status command also shows overlap warnings automatically.
9. Claiming Work Items
Use jjj next --claim to atomically find the highest-priority item and assign it to yourself:
# Grab the top itemjjj next --claim
# See what you claimed in JSONjjj next --claim --jsonThis is useful in team settings where multiple people may be looking for work at the same time. The claim is idempotent — running it again on an already-assigned item is a no-op.
10. Reviewing Project Health
Use jjj insights to get aggregate statistics about your project:
jjj insightsThis shows approval rates, average time to solve problems, critique resolution times, and top contributors. Use --json for structured output that can feed into dashboards or reports.
11. Using Search to Find Context
Use full-text or semantic search to find related work before starting something new:
# Full-text search across all entitiesjjj search "authentication"
# Search finds related entities even without exact matchjjj search "login security"
# Filter by typejjj search "token" --type solutionThis helps avoid duplicating work and surfaces critiques from previous related efforts.