| name | jj-workspace-experiments |
| description | Create isolated jj workspaces for testing changes, running experiments in parallel, and exploring alternative implementations. Use when testing breaking changes, comparing different approaches, or running long-running operations without blocking other work. (project) |
Jj Workspace Experiments
Overview
Create isolated jj workspaces in the work/ directory to test changes, run experiments concurrently, and explore alternative implementations without affecting the main workspace. All workspaces share the same repository history, enabling seamless switching and comparison between approaches.
When to Use
Use this skill when:
- Testing breaking changes or refactors that might not work
- Comparing multiple implementation approaches side-by-side
- Running long-running tests or builds without blocking other work
- Exploring alternative solutions to a problem concurrently
- Testing changes that require extensive experimentation
- Working on multiple independent features simultaneously
Core Workflows
Single Experiment Workspace
Create a workspace to test changes in isolation.
1. Create the Workspace
jj workspace add --name=<experiment-name> work/<directory-name>
Examples:
jj workspace add --name=async-refactor work/async-refactor
jj workspace add --name=new-db-layer work/new-db-layer
jj workspace add --name=api-v2 work/api-v2
The workspace starts from the current commit (@) by default. To start from a different commit:
jj workspace add --name=<name> -r <revision> work/<directory>
2. Work in the Workspace
Navigate to the workspace and make changes:
cd work/<directory-name>
Changes are visible from the main workspace via jj log - all workspaces share the repository history.
3. Evaluate and Decide
After testing:
If successful: Merge the changes back to the main branch:
jj rebase -s <experiment-name>@ -d @
If unsuccessful: Simply forget the workspace:
jj workspace forget <experiment-name>
rm -rf work/<directory-name>
The commits remain in the repository history but can be abandoned if needed.
Parallel Experiments
Test multiple approaches simultaneously by creating multiple workspaces.
1. Create Multiple Workspaces
jj workspace add --name=approach-a work/approach-a
jj workspace add --name=approach-b work/approach-b
jj workspace add --name=approach-c work/approach-c
Each workspace starts from the same commit, creating parallel branches of development.
2. Implement Different Approaches
Work in each workspace independently:
cd work/approach-a
cd work/approach-b
cd work/approach-c
3. Compare Results
From the main workspace, compare implementations:
jj log -r 'working_copies()'
jj diff -r approach-a@ -r approach-b@
jj show approach-a@
4. Choose Winner and Clean Up
Select the best approach and merge it:
jj rebase -s approach-b@ -d @
jj workspace forget approach-a
jj workspace forget approach-c
rm -rf work/approach-a work/approach-c
Long-Running Operations
Use a workspace to run long builds/tests without blocking other work.
1. Create Workspace for Long Operation
jj workspace add --name=test-run work/test-run
2. Start Long Operation
cd work/test-run
buck2 test //... &
3. Continue Work Elsewhere
While the operation runs, work normally in the main workspace:
cd $REPO_ROOT
4. Check Results When Ready
Return to the test workspace to check results:
cd work/test-run
Advanced Patterns
Testing Changes on Different Base Commits
Create workspaces from different commits to test compatibility:
jj workspace add --name=current-test work/current-test
jj workspace add --name=backport-test -r @-- work/backport-test
jj workspace add --name=main-test -r main work/main-test
Darcs-Style Multiple Workspaces
Create a sparse main workspace with all real work in sub-workspaces:
jj sparse set --clear --add work
jj workspace add work/feature-a
jj workspace add work/feature-b
jj workspace add work/bugfix-123
Now the main workspace is empty, but work/ contains multiple full checkouts that all share the repository history.
Workspace as Scratch Space
Create temporary workspaces for quick experiments:
jj workspace add --name=scratch work/scratch
cd work/scratch
jj workspace forget scratch
rm -rf work/scratch
Best Practices
Naming Conventions
Use descriptive names that indicate purpose:
- Experiments:
sqlite-vs-postgres, algorithm-a, refactor-v2
- Features:
feature-auth, feature-search
- Tests:
test-integration, perf-benchmark
- Scratch:
scratch, temp-experiment
Workspace Lifecycle
- Create workspace with clear purpose
- Work in isolation until complete or failed
- Evaluate results and make decision
- Merge successful work or forget failed attempts
- Clean up directories after forgetting
Managing Multiple Workspaces
List active workspaces regularly:
jj workspace list
Keep track of workspace purposes in notes or commit messages.
Resource Considerations
Each workspace is a full working copy, consuming disk space. Clean up unused workspaces promptly.
Workspace Commands Reference
jj workspace add --name=<name> work/<dir>
jj workspace add --name=<name> -r <rev> work/<dir>
jj workspace list
jj workspace forget <name>
jj log -r 'working_copies()'
<workspace-name>@
Limitations
- Disk space: Each workspace is a full working copy
- Manual cleanup: Must remember to forget and remove old workspaces
- Coordination: When working in multiple workspaces, ensure you're in the correct directory
- Build artifacts: Each workspace has its own build outputs, which can consume significant space
Related Skills
jj-clone-third-party - For examining external repositories
jj-graft-third-party - For integrating third-party repository history