Install
$ agentstack add skill-yongwoon-ywc-agent-toolkit-ywc-docker-isolate ✓ scanned · ✓ verified — works with Claude Code, Cursor, and more.
Security review
✓ PassedNo issues found. Passed automated security review. · v0.1.0 How review works →
- ✓ Prompt-injection patterns
- ✓ Secret / credential exfiltration
- ✓ Dangerous shell & filesystem operations
- ✓ Untrusted network calls
- ✓ Known-malicious package signatures
What it can access
- ✓ Network access No
- ✓ Filesystem access No
- ✓ Shell / process execution No
- ● Environment & secrets Used
- ✓ Dynamic code execution No
From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.
About
ywc-docker-isolate
Announce at start: "I'm using the ywc-docker-isolate skill to isolate this worktree's Docker host ports."
Deterministic, per-worktree Docker host-port isolation for parallel Git worktree development. Each worktree derives a unique port block purely from its task name — no central registry, no runtime coordination — and writes it to a worktree-local env-file plus a .ywc-docker-ports persist file. The committed compose / env-file is never mutated (per-worktree namespacing, not save/restore). The deterministic engine lives in bundled scripts; this skill is the one-line interface to them.
Rationalization Defense
When tempted to skip a step, check this table first:
| Excuse | Reality | |---|---| | "Only one worktree is active right now — isolation is unnecessary" | Isolation is unconditional in the executor hook. A second worktree may start at any time, and the deterministic block is what guarantees they never collide. Run setup for every task worktree. | | "Just edit the compose ports: / committed .env to free the port" | The original compose and committed env-file are immutable (NFR-1). Isolation writes only a worktree-local env-file managed block + .ywc-docker-ports; mutating tracked files pollutes git diff and breaks the other worktrees. | | "ss is enough to check whether a port is free" | ss is Linux-only and absent on macOS. Port checks go through the cross-platform check_port_in_use (ss→lsof→netstat, fail-safe when none exist) — never call ss directly. | | "Re-running setup can just re-compute the hash to get the same ports" | Reproducibility (AC2) comes from reading back .ywc-docker-ports, not from re-hashing. A re-hash would drift if an external process transiently held a port. Always read back the persist file; re-hash only on first allocation. | | "audit returned exit 0, so there are no leftover stacks" | audit exit is always 0 — residual stacks are signalled by non-empty stdout, not the exit code. Parse stdout; never gate on the audit exit code. | | "A leftover stack from a prior run is harmless — proceed" | A stale ywc-_* stack occupies the same deterministic port the next run derives, so resume is guaranteed to collide. Pre-flight audit must fail-loud (or --prune) before setup. |
Modes
The deterministic logic is in scripts/ — invoke it with a single line per mode. The CLI contract (arguments, writes, exit codes) is authoritative and is what ywc-parallel-executor integrates against.
setup — allocate and apply the port block
bash claude-code/skills/ywc-docker-isolate/scripts/setup-docker-ports.sh \
--task-name --worktree-path [--compose-file ] [--port-vars VAR1,VAR2]
- Writes a worktree-local env-file managed block (
COMPOSE_PROJECT_NAME=ywc-+ each*_PORT) and the.ywc-docker-portspersist file. - Stdout: the resolved port map (
COMPOSE_PROJECT_NAME+VAR=portlines). - Exit 0 = isolation applied, or no-op (no compose → "no docker — skipping isolation"). Exit 1 = ports hardcoded (cannot isolate) / salt chain exhausted / corrupt persist / squatter live-check / sanitize-empty.
- Re-run on the same worktree reads back
.ywc-docker-ports(deterministic, AC2) and live-checks every port before returning — a squatted port fails loud (AC13).
teardown — remove only this worktree's stack
bash claude-code/skills/ywc-docker-isolate/scripts/teardown-docker.sh \
(--task-name | --project-name ) --worktree-path [--keep-volumes]
- Runs
docker compose -p down --volumes(default;--keep-volumespreserves data), idempotent (exit 0 even with no running stack), deletes.ywc-docker-portson success. - Exit 0 = teardown verified / nothing to do. Exit 1 =
compose downfailed (LEAKED_DOCKER_STACKmarker, wave non-blocking) or sanitize/malformed project (SANITIZE_ERRORmarker, wave blocking). Both markers are written to stderr — distinguish the two by the marker string, not the exit code.
audit — report leftover stacks for expected tasks
bash claude-code/skills/ywc-docker-isolate/scripts/audit-docker-stacks.sh \
--expect [--prune]
- Detects residual
ywc-stacks. Stdout non-empty = residual present (each lineRESIDUAL_DOCKER_STACK: ( container(s))); exit is always 0. --prunetears residual stacks down (down --volumes) and confirms each on stdout (pruned residual stack:). Without--prune, the caller (parallel-executor Pre-flight) must fail-loud and abort the run on any residual. Gate on stdout non-empty only when--pruneis not passed — the prune confirmation lines would otherwise read as residuals.
Integration (ywc-parallel-executor)
One-line pointers only (no inline prose in the executor body):
- Pre-flight (after worktree audit):
audit --expect— non-empty stdout → abort run with the printed stacks +--pruneremediation. - Step 4a (after 4a-verify, per task):
setup --task-name --worktree-path— exit 1 → task BLOCKED + worktree preserved, wave continues. - Step 4g (before
cleanup-worktree.sh, inside the 4e-DONE loop):teardown --task-name --worktree-path— preserved (BLOCKED) worktrees skip 4g, so teardown is skipped automatically.
Common Mistakes
- Calling
ssdirectly instead of the cross-platform helper — breaks on macOS. - Gating on the
auditexit code instead of stdout non-empty — misses every residual stack. - Re-hashing on re-run instead of reading back
.ywc-docker-ports— breaks AC2 determinism under transient external port use. - Placing the teardown pointer outside the 4e-DONE loop — would tear down BLOCKED-preserved worktrees.
- Writing isolation values into the committed compose/env-file instead of the worktree-local env-file managed block — pollutes
git diff(NFR-1).
Validation
bash -nclean on allscripts/*.sh.setuptwice with the same--task-nameyields an identical port map (AC2).- Three distinct task names yield three distinct port blocks and
COMPOSE_PROJECT_NAMEvalues (AC1). validate_ywc_skills.pyPASS; README locale set (.md/.en.md/.ja.md/.ko.md) present.
References
> Action required: Read [references/port-allocation.md](references/port-allocation.md) for the hash formula, var_index sort rule, salt chain, modulo bias, and the AC2 determinism guarantee.
> Action required: Read [references/preconditions.md](references/preconditions.md) for compose detection, env-var mapping limits (short vs long syntax), the YAML parser priority, the platform port-check tool table, and the env-file vs shell-export precedence.
Source & license
This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.
- Author: yongwoon
- Source: yongwoon/ywc-agent-toolkit
- License: MIT
Install and usage instructions live in the source repository linked above.
Reviews
No reviews yet — be the first.
Write a review
Versions
- v0.1.0 Imported from the upstream source.