|
| 1 | +AGENTS: jj (Jujutsu) Workflow for this repo |
| 2 | + |
| 3 | +Scope: Applies to the whole repository. Use jj as the primary VCS interface; interoperate with Git only when explicitly required. |
| 4 | + |
| 5 | +**Principles** |
| 6 | +- Prefer small, stacked changes with `jj new` and `jj describe`. |
| 7 | +- Use one workspace per parallel task under `ws/<name>`. |
| 8 | +- Keep workspaces lean with per-workspace sparse sets. |
| 9 | +- Keep Git interop explicit: use `jj git fetch/push` only when requested. |
| 10 | + |
| 11 | +**Workspaces** |
| 12 | +- Create: `jj workspace add --name <name> [-r <rev>] [--sparse-patterns {copy|full|empty}] ws/<name>` |
| 13 | +- List: `jj workspace list` |
| 14 | +- Rename: `jj workspace rename <new-name>` |
| 15 | +- Forget (before removing dir): `jj workspace forget <name>` then `rm -rf ws/<name>` |
| 16 | +- Fix stale WC (after history edits elsewhere): `jj workspace update-stale` |
| 17 | +- Convention: name workspaces `feat-...`, `bug-...`, `exp-...`. Base from `main` unless otherwise specified. |
| 18 | +- Note: `/ws/` is ignored by `.gitignore` so nested workspaces don’t pollute the main workspace. |
| 19 | + |
| 20 | +**Sparse Working Copies** |
| 21 | +- Show current: `jj sparse list` |
| 22 | +- Minimal set: `jj sparse set --clear --add <path> [--add <path> ...]` |
| 23 | +- Add/remove paths: `jj sparse set --add <path> [--remove <path>]` |
| 24 | +- Reset to full: `jj sparse reset` |
| 25 | +- Edit interactively: `jj sparse edit` (one pattern per line) |
| 26 | +- Patterns are prefix-based (not globs). Examples: |
| 27 | + - `--add packages/sdk` includes that subtree |
| 28 | + - `--add docs` includes docs |
| 29 | + - `--add README.md` includes a single file |
| 30 | + |
| 31 | +**Daily Flow** |
| 32 | +- Start a change: `jj new [-r <base>]` then edit |
| 33 | +- Review: `jj status` and `jj diff` (or `jj diff -r @-..@`) |
| 34 | +- Save description: `jj describe -m "<message>"` |
| 35 | +- Log: `jj log` (multiple workspaces appear as `<workspace>@`) |
| 36 | + |
| 37 | +**Git Interop** |
| 38 | +- Fetch: `jj git fetch [<remote>]` (updates Git refs and imports into jj) |
| 39 | +- Push: `jj git push -r <rev> [--allow-new]` (export to Git). Configure targets with `git.fetch` / `git.push` in config when needed. |
| 40 | +- Private work stays in jj unless explicitly pushed. |
| 41 | + |
| 42 | +**Recommended Config (optional, safe)** |
| 43 | +Add to `.jj/repo/config.toml` or via `jj config set --repo`: |
| 44 | + |
| 45 | +```toml |
| 46 | +[aliases] |
| 47 | +# Short logs relative to main |
| 48 | +l = ["log", "-r", "(main..@):: | (main..@)-"] |
| 49 | +# One-change diff |
| 50 | +d = ["diff", "-r", "@-..@"] |
| 51 | +# Push current change (allow creating a push bookmark) |
| 52 | +pp = ["git", "push", "-r", "@", "--allow-new"] |
| 53 | + |
| 54 | +[ui] |
| 55 | +# Optional: make `jj` default to a reversed log |
| 56 | +default-command = ["log", "--reversed"] |
| 57 | +``` |
| 58 | + |
| 59 | +Per-user identity (set once): |
| 60 | +- `jj config set --user user.name "Your Name"` |
| 61 | +- `jj config set --user user.email "[email protected]"` |
| 62 | + |
| 63 | +**Parallel Work Examples** |
| 64 | +- Feature vs. fix: |
| 65 | + - `jj workspace add --name feat-x -r main ws/feat-x` |
| 66 | + - `jj workspace add --name bug-123 -r main ws/bug-123` |
| 67 | + - Narrow sparse in each workspace to what you actually touch. |
| 68 | +- Ephemeral debug off an old rev: |
| 69 | + - `jj workspace add --name debug-<id> -r <rev> ws/debug-<id>` |
| 70 | + - Inspect, then: `jj workspace forget debug-<id> && rm -rf ws/debug-<id>` |
| 71 | + |
| 72 | +**Troubleshooting** |
| 73 | +- Large file snapshot warning (e.g., lockfiles): |
| 74 | + - Workspaces under `ws/` are ignored already; if you still need to raise the limit briefly: `jj --config snapshot.max-new-file-size=<bytes> st` or per-repo via config. |
| 75 | +- Stale workspace after rebases: `jj workspace update-stale` |
| 76 | +- Git locking/partial clone errors: |
| 77 | + - Ensure this repo is a full Git clone (jj doesn’t support Git partial clones). |
| 78 | + - Avoid running concurrent processes that hold `.git/packed-refs` or `.git/objects` locks. |
| 79 | + |
| 80 | +**Conventions Recap** |
| 81 | +- Workspaces live under `ws/` (ignored by Git). |
| 82 | +- One `jj new` per task; keep changes small and focused. |
| 83 | +- Use sparse to speed up monorepo workflows. |
| 84 | +- Use `jj git push` only on request; otherwise keep work jj-local. |
| 85 | + |
0 commit comments