/ai-devkit:cmk:local-stackfrom ai-devkit
Sets up worktree-isolated local development stacks with deterministic identity, port conflict avoidance, and coherence validation. Supports human dev, headless agents, and CI.
Ships in ai-devkit. 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.
Read when SKILL.md points to them.
Set up or improve a worktree-isolated local stack: a system where multiple git worktrees of the same repo run local service topologies simultaneously, on the same machine, without port collisions, stale config, or cross-worktree contamination. Serves three audiences: human developers, AI agents running headless, and CI.
Init (default) — derive the worktree identity, install the coherence guard, and stand up the first stack config with both runner modes.
Update — add a stack, config, instance, or runner mode as needs grow; never touch another worktree's or instance's state.
Verify — report-only audit against the checks under ## Verify;
never mutates.
Two independent axes compose to make this work.
Every worktree derives a deterministic identity from its own state: a normalized branch label, a normalized worktree label (the primary checkout gets a fixed label; others derive from directory name), and a short hash of the absolute repo path. That identity feeds everything else — the compose project name, the base of every port range, env-file naming, and the root of all state directories — so two worktrees on the same machine never land on the same values.
A coherence guard runs before anything starts: it recomputes the identity
fresh, compares it against what was last written to disk, and checks that
every env file's recorded ports and paths match the freshly computed ones. On
any mismatch it fails loudly and says exactly what's wrong and how to fix it
(normally: re-run init) — it never silently "fixes" a stale file itself. Read
references/identity-and-coherence.md for the derivation recipe, what it
feeds, the guard's checks, and the init-script shape.
A single worktree may run several stacks, and any one stack may run several
parallel materializations. A config is owned by whichever package needs a
stack (an e2e test group, a benchmark harness, day-to-day dev) and declares its
topology. An instance is one running materialization of that config, with
an explicit state/home root at .local/<stack>/<config>/<instance>/ and ports
assigned by a broker rather than hand-carved arithmetic. Consumers join a
shared instance by default; an invoking coordination layer — never the config
or the instance mechanism itself — decides when to select distinct instances
instead (parallel e2e shards, a disposable test instance beside a persistent
dev one, comparing two topologies). Read references/instance-primitive.md
for ownership, layout, broker responsibilities, and lifecycle.
A repo may own several purpose-specific local stacks side by side — different topologies for different jobs (a lightweight dev stack, a heavier e2e stack, a production-mirroring benchmark stack). Each is its own package: it owns its config, its runner entry point, and its tests. There is no single blessed "the local stack" every job must fit.
Every stack manages some mix of: compose-managed infra (database, cache, object store), application processes, and heavyweight components (e.g. a local chain node or similar out-of-process runtime). Two runner modes cover both audiences:
stack start|status|logs [service]|stop):
idempotent, no-TTY, for agents and CI. Logs and PIDs live under .local/.Read references/runners.md for the contract each mode must satisfy, log
hygiene, and when to reach for which.
.local/ conventionThe single git-ignored per-worktree root for all ephemeral state and scratch, shared by humans and every agent vendor:
.local/
├── tmp/ # scratch (instead of /tmp or ad-hoc tmp/)
├── logs/ # service + stack logs
├── pids/
├── <stack>/ # per-stack state and instances
└── env files # worktree-derived env, ports
No home-directory state (~/.<tool> singletons), no global processes, no
fixed ports. Never source another worktree's env files. Never wipe a stack
other than the one explicitly selected instance — no global prune, no deleting
.local/<stack> wholesale.
Whoever starts a stack owns stopping it: an agent or CI job stops what it brought up when its task ends — a dangling stack silently starves the next run's ports, memory, and CPU. Only a deliberately persistent instance other sessions are meant to join outlives its starter, through its own explicit lifecycle — never by accident, and never blanket-killed by another session.
Cooperative stop reaches only what this worktree's .local/ records still
account for, and .local/ dies with a deleted worktree — so reclamation
rests on the identity stamped on each started resource (compose
project/labels, process command paths, state roots), never on process
ancestry: one agent session spans many worktrees. Reclaim only this worktree
or identities whose worktree directory is gone; report, never kill, the
unattributable — no global prune. references/runners.md owns the contract.
Test groups join a shared instance by default. Select distinct instances to isolate parallel shards or to avoid one group's teardown affecting another's fixtures. Declare Docker-backed tests as such so CI can gate on the daemon being present.
Remote environments and IaC are cmk:infra's; CI composition is cmk:cicd's; an attested boundary is cmk:enclave's.
Local materializes the same package without TEE evidence, never a raw-env fork. Local is a profile of the same production-quality path, not a second product —
it may be the debug or rollout host when those scripts run here. Stay
worktree-safe regardless of what the stack mirrors.
Report-only — never mutate:
.gitignore covers .local/..local/, not elsewhere.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
Generated from the plugin's indexed repository (commandosslabs/ai-devkit) — no native marketplace selected
npx claudepluginhub p/commandosslabs-ai-devkit36 skills in this plugin
/cmk:adrUse when the user asks to "record this decision", "we decided to use X over Y", "document why we chose this approach", "record an ADR", "update ADR-0003", or needs to create or update architecture decision records for system-level technical choices like choosing a database, communication protocol, or infrastructure pattern./cmk:agent-instructionsUse when the user asks to "set up CLAUDE.md", "set up AGENTS.md", "agent instructions", "add engineering rules", "make the instructions thinner", or needs to establish or maintain a thin, multi-vendor root instruction file backed by on-demand engineering rules under docs/rules/./cmk:agent-vendorsUse when the user asks to "vendor the kit's skills into this repo", "set up agent adapters", "add a coding-agent vendor", "wire skills for Claude Code / Codex / OpenCode / Grok Build / Cursor", or whenever a repo needs one canonical skill set discoverable by multiple coding agents.