Source profileQuality 91/100

laurigates/claude-plugins/rust-plugin/skills/cargo-worktree-builds/SKILL.md

cargo-worktree-builds

Share one CARGO_TARGET_DIR across parallel git-worktree agents so Rust deps compile once. Use when running cargo/clippy/test in several worktrees concurrently, when parallel agent builds rebuild dependencies N times, or when N worktrees blow up disk with N copies of target/.

Source repository stars
53
Declared platforms
0
Static risk flags
0
Last source update
2026-08-24
Source checked
2026-08-25

Decision brief

What it does: where it fits

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…

Best for

  • Use when running cargo/clippy/test in several worktrees concurrently, when parallel agent builds rebuild dependencies N times, or when N worktrees blow up disk with N copies of target/.

Not for

  • Tasks that require unconfirmed production actions or broad system permissions.
  • Environments where the pinned source and install steps cannot be inspected.

Compatibility matrix

Platform support, with evidence labels

PlatformStatusEvidenceWhat to check
CodexNot declaredNo explicit evidencePortability before use
Claude CodeNot declaredNo explicit evidencePortability before use
CursorNot declaredNo explicit evidencePortability before use
Gemini CLINot declaredNo explicit evidencePortability before use
Open the compatibility checker

Installation

Inspect first. Install second.

The source command is displayed only when detected. A safe inspection prompt is always available so your agent can explain every action before execution.

Source-detected install commandSource
npx skills add https://github.com/laurigates/claude-plugins --skill "rust-plugin/skills/cargo-worktree-builds"
Safe inspection promptEditorial

Inspect the Agent Skill "cargo-worktree-builds" from https://github.com/laurigates/claude-plugins/blob/5de06622d8def8c36f7f39d980300aaa15af4357/rust-plugin/skills/cargo-worktree-builds/SKILL.md at commit 5de06622d8def8c36f7f39d980300aaa15af4357. List every install step, command, network request, credential, file read/write, external action, and rollback step. Explain whether it fits my task. Do not install or execute anything until I approve.

Workflow

What the source asks the agent to do

  1. 01

    Step 1: Choose one persistent shared target dir

    Pick 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):

    Pick 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):
  2. 02

    Step 2: Pre-warm it ONCE before dispatching agents

    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:

    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:
  3. 03

    Step 3: Every worktree command exports the same dir

    Prefix every cargo/just invocation in every worktree agent with it:

    Prefix every cargo/just invocation in every worktree agent with it:Brief each agent to use this exact prefix. Dependency artifacts are now shared; only each worktree's own crate is recompiled per build.
  4. 04

    When to Use This Skill

    Review the “When to Use This Skill” section in the pinned source before continuing.

    Review and apply the “When to Use This Skill” source section.
  5. 05

    Context

    Cargo.toml present: !find . -maxdepth 1 -name 'Cargo.toml'

    Cargo.toml present: !find . -maxdepth 1 -name 'Cargo.toml'CARGOTARGETDIR currently set: !echo "${CARGOTARGETDIR:-}"Active git worktrees: !git worktree list

Permission review

Static risk signals and limitations

No configured static risk pattern was detected

This is not proof of safety. Runtime behavior, indirect dependencies, and hidden external systems are outside the static scan.

Evidence record

Why each signal appears

EvidenceSourceComputedTestedEditorial
SignalValueEvidence typeMeaning
Quality score91/100ComputedDocumentation, specificity, maintenance, and trust rules
Repository stars53SourceRepository attention, not individual Skill quality
Compatibility0 platformsSourceDeclared in the catalog source record
Usage guideautomated source guideEditorialGenerated or reviewed according to the visible evidence level

Pinned source

Provenance and original SKILL.md

Repository
laurigates/claude-plugins
Skill path
rust-plugin/skills/cargo-worktree-builds/SKILL.md
Commit
5de06622d8def8c36f7f39d980300aaa15af4357
License
MIT
Collected
2026-08-25
Default branch
main
View the original SKILL.md

cargo-worktree-builds - Shared Target Dir for Parallel Worktree Agents

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

When to Use This Skill

Use this skill when...Use X instead when...
Dispatching parallel agents into multiple git worktrees of one Rust repoA single working tree — the default target/ is already optimal
cargo/clippy/test is rebuilding the same deps in each worktreeCaching 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

Context

  • Cargo.toml present: !find . -maxdepth 1 -name 'Cargo.toml'
  • CARGO_TARGET_DIR currently set: !echo "${CARGO_TARGET_DIR:-<unset — each worktree uses its own ./target>}"
  • Active git worktrees: !git worktree list

The Pattern

Step 1: Choose one persistent shared target dir

Pick 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"

Step 2: Pre-warm it ONCE before dispatching agents

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

Step 3: Every worktree command exports the same dir

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.

Why It Works (and the one gotcha)

  • Deps compile once. The dependency graph is identical across worktrees, so the shared dir reuses it; only the leaf crate differs per worktree.
  • Cargo's build lock serializes concurrent builds. Two agents building at once won't corrupt the dir — cargo holds an exclusive lock on the target dir during a build, so the second waits. This also throttles total CPU/I/O, which is usually desirable when many agents run at once.
  • Disk stays ≈ 1×. One target/ for all worktrees instead of N.

Gotcha: transient "method not found" / stale-rlib under contention

Because builds serialize on the shared lock, an agent can occasionally read a stale rlib that a concurrent agent is mid-rebuild on, surfacing as a spurious compile error like no method named X found or a file-lock message — even though the code is correct. It is not a real error.

Fix: force a rebuild and re-run.

touch src/lib.rs                                 # or any source file in scope
CARGO_TARGET_DIR="$SHARED_TARGET" just check

Tell agents up front that an isolated, non-reproducing "method not found" right after a green peer build is the shared-target lock — touch + re-run, don't chase it as a code bug.

Agentic Optimizations

ContextCommand
Define the shared direxport SHARED_TARGET="$HOME/.cache/<repo>-target"; mkdir -p "$SHARED_TARGET"
Pre-warm before fan-outCARGO_TARGET_DIR="$SHARED_TARGET" cargo build
Per-worktree gateCARGO_TARGET_DIR="$SHARED_TARGET" just check
Recover from a stale-rlib errortouch src/<file>.rs && CARGO_TARGET_DIR="$SHARED_TARGET" cargo test
Inspect cache sizedu -sh "$SHARED_TARGET"

Quick Reference

KnobEffect
CARGO_TARGET_DIR (env)Redirects all build output to a shared path; the lever this skill uses
build.target-dir in .cargo/config.tomlPer-repo equivalent — but commits the path; prefer the env var for ephemeral worktrees
cargo build lockSerializes concurrent builds against the shared dir (the safety + throttle)
Same-disk placementLets cargo hardlink instead of copy; cross-disk forces copies

Relationship to Parallel-Agent Dispatch

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/tokio TUI (gh-board) pre-warmed one $HOME/.cache/gh-board-target and ran every agent's just check against it — deps compiled once, the lock serialized the concurrent builds, and the only friction was the transient stale-rlib above, resolved by touch + re-run.

Frequently asked questions

What to verify before installation and use

What does the cargo-worktree-builds source document cover?

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…

How do I install cargo-worktree-builds?

The source record exposes this install command: npx skills add https://github.com/laurigates/claude-plugins --skill "rust-plugin/skills/cargo-worktree-builds". Inspect the command and pinned source before running it.

Alternatives

Compare before choosing

Computed 10045,511

coreyhaines31/marketingskills

ab-testing

When the user wants to plan, design, or implement an A/B test or experiment, or build a growth experimentation program. Also use when the user mentions "A/B test," "split test," "experiment," "test this change," "variant copy," "multivariate test," "hypothesis," "should I test this," "which version is better," "test two versions," "statistical significance," "how long should I run this test," "growth experiments," "experiment velocity," "experiment backlog," "ICE score," "experimentation program

Computed 10029,034

garrytan/gbrain

bulk-ingestion

End-to-end discipline for turning any large data source (audio libraries, email takeouts, document corpora, chat exports, API dumps) into brain pages at scale. The lifecycle spine: SCHEMA → ACCESS → TRIAL → EVALUATE → IMPROVE → CODIFY → TEST → SKILLIFY → BULK → MONITOR. State is tracked in a durable JSON manifest (see MANIFEST-PATTERN.md) so any crash, session boundary, or subagent fan-out resumes from ground truth instead of memory.

Computed 10024,921

alirezarezvani/claude-skills

app-store-optimization

App Store Optimization (ASO) toolkit for researching keywords, analyzing competitor rankings, generating metadata suggestions, and improving app visibility on Apple App Store and Google Play Store. Use when the user asks about ASO, app store rankings, app metadata, app titles and descriptions, app store listings, app visibility, or mobile app marketing on iOS or Android. Supports keyword research and scoring, competitor keyword analysis, metadata optimization, A/B test planning, launch checklist

Computed 1005,241

dotnet/skills

migrate-vstest-to-mtp

Migrates .NET test projects from VSTest to Microsoft.Testing.Platform (MTP). Use when user asks to "migrate to MTP", "switch from VSTest", "enable Microsoft.Testing.Platform", "use MTP runner", set OutputType=Exe only for test projects in Directory.Build.props, or mentions EnableMSTestRunner, EnableNUnitRunner, or UseMicrosoftTestingPlatformRunner. USE FOR: MTP behavioral differences vs VSTest (exit code 8, zero tests discovered, --ignore-exit-code, TESTINGPLATFORM_EXITCODE_IGNORE); centralizing