No slash command · from rust-plugin
Shares one CARGO_TARGET_DIR across parallel git-worktree agents so Rust dependencies compile once instead of N times. Use when worktrees run cargo concurrently, rebuild deps repeatedly, or fill disk with N target/ copies.
Ships in rust-plugin. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
When you fan out parallel agents into separate git worktrees of a Rust repo
(one per issue/feature), each worktree builds into its own target/ by
default. For a project with hundreds of dependency crates that means every
worktree pays the full cold dependency build (minutes each) and writes its own
multi-GB target/ — so N worktrees cost ≈ N× time and N× disk for dependency
artifacts that are byte-identical across them.
Point every worktree at one shared, pre-warmed CARGO_TARGET_DIR instead.
Dependencies compile once and are reused; cargo's build lock serializes the
concurrent builds (which also caps CPU/I/O thrash); disk stays ≈ 1× not N×.
| Use this skill when... | Use X instead when... |
|---|---|
| Dispatching parallel agents into multiple git worktrees of one Rust repo | A single working tree — the default target/ is already optimal |
cargo/clippy/test is rebuilding the same deps in each worktree | Caching deps in CI — use Swatinem/rust-cache@v2 (see cargo-llvm-cov) |
N worktrees are filling the disk with N copies of target/ | Speeding up a single build — use a faster linker / cargo check |
| Coordinating a multi-worktree wave (see agent-patterns-plugin) | Cross-machine sharing — use sccache, not a shared dir |
find . -maxdepth 1 -name 'Cargo.toml'echo "${CARGO_TARGET_DIR:-<unset — each worktree uses its own ./target>}"git worktree listPick a path outside any worktree (so removing a worktree never deletes the cache) and on the same disk as the checkouts (so cargo can hardlink):
export SHARED_TARGET="$HOME/.cache/<repo>-target"
mkdir -p "$SHARED_TARGET"
A cold shared dir means the first agent to build compiles every dependency crate while the others block on cargo's build lock. Pre-warming from the orchestrator removes that serialized stall from the critical path:
CARGO_TARGET_DIR="$SHARED_TARGET" cargo fetch
CARGO_TARGET_DIR="$SHARED_TARGET" cargo build # compiles all deps once
Prefix every cargo/just invocation in every worktree agent with it:
CARGO_TARGET_DIR="$SHARED_TARGET" just check # fmt + clippy + test
CARGO_TARGET_DIR="$SHARED_TARGET" cargo test
Brief each agent to use this exact prefix. Dependency artifacts are now shared; only each worktree's own crate is recompiled per build.
target/ for all worktrees instead of N.Because builds serialize on the shared lock, an agent can read a stale rlib
that a concurrent agent built from its own branch, surfacing as a compile error
like no method named X found or a file-lock message, even though this
worktree's code is correct.
When every branch changes only leaf crates, the error is transient. Force a rebuild and re-run:
touch src/lib.rs # or any source file in scope
CARGO_TARGET_DIR="$SHARED_TARGET" just check
When the branches change a non-leaf workspace crate (one that other crates depend on), it is not transient: the collision recurs each time a peer rebuilds that crate, so a re-run does not reliably clear it. The same swap can also go the other way, letting a gate compile and pass against a peer's version of the crate (a false green; inferred from the mechanism, not yet observed). Stop sharing for gate runs, per When Not to Share.
A dispatch brief that tells agents to share a target dir must carry the stale-rlib gotcha: an isolated "method not found" right after a peer build is the shared target, not a code bug.
If the parallel branches modify any workspace crate that other crates depend
on, not just leaf crates, give each worktree its own CARGO_TARGET_DIR for gate
runs (clippy, tests, anything whose verdict you report). Keep dependency builds
shared through sccache (RUSTC_WRAPPER=sccache) instead of the target dir:
CARGO_TARGET_DIR="$HOME/.cache/<repo>-target-<worktree>" RUSTC_WRAPPER=sccache just check
Evidence (shore-recon, 2026-10-31): three worktree agents shared one target dir while two branches changed
crates/coredifferently. One worktree's clippy failed withE0599: no method named 'env'although its source had the method; with a privateCARGO_TARGET_DIRthe same tree passed clippy and 250 tests. The orchestrator's brief had left out the stale-rlib gotcha.
| Context | Command |
|---|---|
| Define the shared dir | export SHARED_TARGET="$HOME/.cache/<repo>-target"; mkdir -p "$SHARED_TARGET" |
| Pre-warm before fan-out | CARGO_TARGET_DIR="$SHARED_TARGET" cargo build |
| Per-worktree gate | CARGO_TARGET_DIR="$SHARED_TARGET" just check |
| Recover from a stale-rlib error (leaf-only branches) | touch src/<file>.rs && CARGO_TARGET_DIR="$SHARED_TARGET" cargo test |
| Gate when branches change a non-leaf crate | CARGO_TARGET_DIR="$HOME/.cache/<repo>-target-<worktree>" RUSTC_WRAPPER=sccache just check |
| Inspect cache size | du -sh "$SHARED_TARGET" |
| Knob | Effect |
|---|---|
CARGO_TARGET_DIR (env) | Redirects all build output to a shared path; the lever this skill uses |
build.target-dir in .cargo/config.toml | Per-repo equivalent — but commits the path; prefer the env var for ephemeral worktrees |
| cargo build lock | Serializes concurrent builds against the shared dir (the safety + throttle) |
| Same-disk placement | Lets cargo hardlink instead of copy; cross-disk forces copies |
This is the Rust-specific build-isolation companion to the worktree fan-out
patterns in agent-patterns-plugin (parallel-agent-dispatch,
wave-based-dispatch): those cover git/branch isolation and orchestrator-owned
shared files; this covers the build cache so N worktrees don't each pay the
full dependency compile. Pre-warm in the orchestrator, then hand every agent the
CARGO_TARGET_DIR=… prefix.
Evidence: a 5-agent worktree wave on a ~320-crate
ratatui/tokioTUI (gh-board) pre-warmed one$HOME/.cache/gh-board-targetand ran every agent'sjust checkagainst it — deps compiled once, the lock serialized the concurrent builds, and the only friction was the transient stale-rlib above, resolved bytouch+ re-run.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub laurigates/claude-plugins --plugin rust-plugin10 skills in this plugin
/cargo-distcargo-dist (dist) release binaries for a Rust CLI. Use when setting up dist-workspace.toml, pairing dist with release-please, or publishing a Homebrew formula./cargo-generatecargo-generate: scaffold a project from a git template repo. Use when bootstrapping a Rust or Bevy project from a template, or authoring one./cargo-llvm-covcargo-llvm-cov: Rust code coverage with LLVM instrumentation. Use when measuring coverage, enforcing thresholds, generating reports, or integrating codecov/coveralls.Other plugins' skills for the same job