Multi-Agent Worktree & Bazel Cache Management
Skill561 starsChanged 16 days agoApache-2.0View on GitHub
Instructions for managing warm Git worktree slots, logical project symlinks (~/wrk/projects/<project>), shared Bazel caches, and Jetski IDE workspace synchronization using `./gh wt`.
In this repository20 other files it gives its agents.
- AGENTS.mdAGENTS.md
- pw_ghish/AGENTS.mdAGENTS.md
- pw_ide/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- BluetoothSkill
- Code ReviewSkill
- crankSkill
- docsSkill
- freshenSkill
- ghishSkill
- manual-cli-testSkill
- oncallSkill
- pw_async2Skill
- Pigweed Kernel TestingSkill
- C++ Pigweed RPC ServicesSkill
- respondSkill
- reviewSkill
- run-presubmit-checksSkill
- saleae-analyzerSkill
- Use Pigweed Toolchain ToolsSkill
The file
We split this skill into the rules it gives an agent
8 rules. About 0 are common, 2 are distinctive, and 6 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 20
All shared Bazel cache settings (~/.config/pw_ghish/bazelrc.worktrees and the try-import line in ~/.bazelrc) are managed exclusively by …
- Distinctive: line 26
When the user instructs you to work on a specific project (e.g., *"Project rpc-fix: investigate the buffer overflow"* or *"Switch to …
- Very specific: line 29
Run ./gh wt use <project> --json (or allocate directly from a Buganizer issue via ./gh wt use --issue <id> --json / ./gh issue develop <id> …
- Very specific: line 46
If another agent holds an active write lease on <project>, ./gh wt use automatically warm-forks to <project>-fork-1 in a free slot to …
- Very specific: line 47
If the branch <project> is already checked out in an unmanaged worktree (e.g., ~/wrk/pw-ghish or ~/wrk/pigweed) or has unmerged local …
- Very specific: line 48
If all slots are occupied, ./gh wt use automatically LRU-parks the oldest idle, clean (!DIRTY) project to free a warm slot.
- Distinctive: line 51
NEVER: run git worktree add, git worktree remove, git worktree list, or git checkout --detach in other directories to work around branch …
- Very specific: line 54
Use the returned symlink_path (/usr/local/google/home/keir/wrk/projects/<project>) as the Cwd for all subsequent run_command and file …
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Multi-Agent Worktree & Bazel Cache Management (./gh wt)
Pigweed developers and AI agents use ./gh wt (pw_ghish/worktree) to juggle multiple concurrent workstreams without Git branch clobbering or cold Bazel rebuilds.
Core Concepts
- Fixed Warm Slots (
~/wrk/slots/<slot_prefix>01..N): Physical Git worktrees live at fixed paths (default prefixpw-, configurable via[worktree] slot_prefixin.ghish.tomlor derived from the repository name) so their Bazel MD5output_basehashes never change. Every slot keeps its own warm Bazel JVM server and Skyframe analysis graph (or operates withwarmup_driver = "none"in non-Bazel repositories). - Logical Project Symlinks (
~/wrk/projects/<project>): Agents and developers work inside~/wrk/projects/<project>, which is a POSIX symlink pointing to the currently mounted slot (e.g.,~/wrk/slots/pw-03). - Orthogonal Residency (
MOUNTEDvs.PARKED):MOUNTED: Occupies a warm slot in~/wrk/slots/<slot_prefix>XXand appears as an active project in the Jetski left sidebar.PARKED: Shelved in Git (refs/heads/<branch>) and Gerrit (pwrev/XXXor configured shortlink), consuming 0 disk slots and archived in the Jetski sidebar. Supports juggling $M$ projects on $N$ slots ($M > N$) via automatic LRU swap-out of clean/unleased slots.
- Never Manually Edit
~/.bazelrc: All shared Bazel cache settings (~/.config/pw_ghish/bazelrc.worktreesand thetry-importline in~/.bazelrc) are managed exclusively by./gh wt init. Agents must NEVER manually edit or delete~/.bazelrc.
Agent Protocol: Responding to "Project <name>: ..."
When the user instructs you to work on a specific project (e.g., "Project rpc-fix: investigate the buffer overflow" or "Switch to project sensor-driver"):
- Allocate or Resume the Project Slot:
Run
./gh wt use <project> --json(or allocate directly from a Buganizer issue via./gh wt use --issue <id> --json/./gh issue develop <id> --worktree):
Example JSON output:./gh wt use <project> --json # Or from a Buganizer issue ID: ./gh wt use --issue 315378787 --json{ "project": "rpc-fix", "slot": "pw-02", "slot_path": "/usr/local/google/home/keir/wrk/slots/pw-02", "symlink_path": "/usr/local/google/home/keir/wrk/projects/rpc-fix", "branch": "rpc-fix", "mode": "write" }- If another agent holds an active write lease on
<project>,./gh wt useautomatically warm-forks to<project>-fork-1in a free slot to prevent Git index collisions. - If the branch
<project>is already checked out in an unmanaged worktree (e.g.,~/wrk/pw-ghishor~/wrk/pigweed) or has unmerged local commits from an earlier session,./gh wt useautomatically creates<project>-wtatorigin/mainwithout touching the unmanaged worktree. - If all slots are occupied,
./gh wt useautomatically LRU-parks the oldest idle, clean (!DIRTY) project to free a warm slot.
- If another agent holds an active write lease on
- Strict One-Shot Rule — NEVER Run Manual
git worktreeCommands:- NEVER run
git worktree add,git worktree remove,git worktree list, orgit checkout --detachin other directories to work around branch collisions../gh wt use <project>is a single one-shot command that handles slot allocation, unmanaged worktree branch collisions, and stale local branches automatically.
- NEVER run
- Execute All Commands Inside
symlink_path: Use the returnedsymlink_path(/usr/local/google/home/keir/wrk/projects/<project>) as theCwdfor all subsequentrun_commandand file editing tool calls.
Common CLI Workflows
./gh wt init --check # Read-only health check of slots, hooks, unmanaged worktrees, Bazel caches, and IDE sync
./gh wt init --slots 10 # Idempotently create/repair slots and configure shared Bazel caches
./gh wt use <project> # One-shot allocate/resume slot, auto-resolving any unmanaged worktree branch collisions
./gh wt list [--json] # Live dashboard with Gerrit review/CI badges (✗ NEEDS_ATTENTION, ✓ READY_TO_LAND; --json: "status": "NEEDS_ATTENTION")
./gh wt next [<project>] # After a CL merges: fetch origin & rebase mounted slot onto origin/main in-place
./gh wt park [<project>] # Shelve clean mounted slot to PARKED (0 disk slots; dirty trees require --force)
./gh wt close <project> # Permanently close a completed workstream
./gh wt gc [--dry-run] # Remove orphaned Bazel output bases in ~/.cache/bazel/_bazel_$USERDoes it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

