agentleFS
pigweed-projectpigweed-project/pigweed/.agents/skills/worktree/SKILL.md

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`.

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
  1. Very specific:

    All shared Bazel cache settings (~/.config/pw_ghish/bazelrc.worktrees and the try-import line in ~/.bazelrc) are managed exclusively by …

    line 20
  2. Distinctive:

    When the user instructs you to work on a specific project (e.g., *"Project rpc-fix: investigate the buffer overflow"* or *"Switch to …

    line 26
  3. Very specific:

    Run ./gh wt use <project> --json (or allocate directly from a Buganizer issue via ./gh wt use --issue <id> --json / ./gh issue develop <id> …

    line 29
  4. Very specific:

    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 …

    line 46
  5. Very specific:

    If the branch <project> is already checked out in an unmanaged worktree (e.g., ~/wrk/pw-ghish or ~/wrk/pigweed) or has unmerged local …

    line 47
  6. Very specific:

    If all slots are occupied, ./gh wt use automatically LRU-parks the oldest idle, clean (!DIRTY) project to free a warm slot.

    line 48
  7. Distinctive:

    NEVER: run git worktree add, git worktree remove, git worktree list, or git checkout --detach in other directories to work around branch …

    line 51
  8. Very specific:

    Use the returned symlink_path (/usr/local/google/home/keir/wrk/projects/<project>) as the Cwd for all subsequent run_command and file …

    line 54

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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

  1. Fixed Warm Slots (~/wrk/slots/<slot_prefix>01..N): Physical Git worktrees live at fixed paths (default prefix pw-, configurable via [worktree] slot_prefix in .ghish.toml or derived from the repository name) so their Bazel MD5 output_base hashes never change. Every slot keeps its own warm Bazel JVM server and Skyframe analysis graph (or operates with warmup_driver = "none" in non-Bazel repositories).
  2. 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).
  3. Orthogonal Residency (MOUNTED vs. PARKED):
    • MOUNTED: Occupies a warm slot in ~/wrk/slots/<slot_prefix>XX and appears as an active project in the Jetski left sidebar.
    • PARKED: Shelved in Git (refs/heads/<branch>) and Gerrit (pwrev/XXX or 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.
  4. Never Manually Edit ~/.bazelrc: All shared Bazel cache settings (~/.config/pw_ghish/bazelrc.worktrees and the try-import line 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"):

  1. 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):
    ./gh wt use <project> --json
    # Or from a Buganizer issue ID:
    ./gh wt use --issue 315378787 --json
    Example JSON output:
    {
      "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 use automatically warm-forks to <project>-fork-1 in a free slot to prevent Git index collisions.
    • If the branch <project> is already checked out in an unmanaged worktree (e.g., ~/wrk/pw-ghish or ~/wrk/pigweed) or has unmerged local commits from an earlier session, ./gh wt use automatically creates <project>-wt at origin/main without touching the unmanaged worktree.
    • If all slots are occupied, ./gh wt use automatically LRU-parks the oldest idle, clean (!DIRTY) project to free a warm slot.
  2. Strict One-Shot Rule — NEVER Run Manual git worktree Commands:
    • NEVER run git worktree add, git worktree remove, git worktree list, or git checkout --detach in 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.
  3. Execute All Commands Inside symlink_path: Use the returned symlink_path (/usr/local/google/home/keir/wrk/projects/<project>) as the Cwd for all subsequent run_command and 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_$USER

Download now (ZIP)

Does 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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.