/dpf-platform:dpf-worktree-per-sessionfrom dpf-platform
Manages concurrent DPF coding sessions by creating isolated git worktrees with one session per branch. Handles worktree creation, entry, auditing, and cleanup.
Ships in dpf-platform. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description, though model invocation is off: only you can start it.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Concurrent DPF coding sessions DO NOT share a working tree. One session = one branch + one git worktree. Branches alone are insufficient — the index, HEAD, and untracked files all live in the working tree, so two sessions in the same tree collide on commits, file sweeps, and stale buffer state. This skill walks the canonical worktree-creation flow with the MCP-seed step + COMPOSE_PROJECT_NAME isolation that makes the worktree usable end-to-end.
A thread worktree is source-control isolation: its own branch, index, HEAD, untracked-file space. It is not a second DPF runtime. The MCP seed and COMPOSE_PROJECT_NAME set in the steps below are collision-avoidance, not an instruction to spin up a parallel runtime for every task.
For normal feature/fix work: commit from the worktree, then route runtime-bound verification through the shared local-CI convergence sandbox by claiming a lease (claim_nonprod_environment_lease(environmentKey="local-integration-ci")). The sandbox is one shared runtime that every worktree uses sequentially — making each individual worktree runnable doesn't scale past tens of concurrent worktrees, let alone the 1,000–10,000 DPF expects. See AGENTS.md §4 worktree bullet and worktree-is-source-control-not-runtime. The rare exception (destructive compose experiment where a disposable runtime IS the deliverable) is a dedicated platform task, not incidental scope on a feature/fix thread.
mcp__ccd_session__spawn_task chip click).| Source | Path | What to extract |
|---|---|---|
| Worktree doctrine | AGENTS.md §4 | Branch naming, --no-checkout/-b flags, root-clone-as-merge-worktree rule |
| Seed script | scripts/seed-worktree-mcp.ps1 (Windows) or .sh (macOS / Linux) | What the MCP-config seed step copies and where |
| Bulk sync script | scripts/sync-mcp-worktrees.ps1 / .sh | Repair or refresh MCP config, Compose isolation, and readiness markers across many worktrees |
| Compose isolation rule | AGENTS.md §4 (Compose project isolation) | Why COMPOSE_PROJECT_NAME matters and what breaks without it |
| WSL mirrored mode trap | project_wsl_mirrored_docker_incompat (user memory) | First-check when "portal won't start" in a fresh worktree |
kernel/principles/worktree-per-session — this skill IS the principle, operationalized.kernel/principles/propose-acknowledge-reassign — worktree boundaries are how the PAR discipline survives concurrency.kernel/principles/worktree-base-origin-main — branch from origin/main so the worktree doesn't inherit unpushed local main commits.kernel/principles/keep-root-clone-as-merge-worktree — root clone stays read-only for active feature work.kernel/principles/worktree-is-source-control-not-runtime — local worktree gates are distinct from canonical-runtime evidence.Pick a topic slug. Short, hyphenated, descriptive: skill-pack-formalize not work or fix-stuff. The slug becomes both the worktree directory suffix and the branch name suffix.
Base the new branch on origin/main. Per worktree-base-origin-main:
git fetch origin main
git worktree add D:/DPF-worktrees/<slug> -b <prefix>/<slug> origin/main
feat/<slug>, fix/<slug>, chore/<slug>, doc/<slug>, clean/<slug>.D:/DPF-worktrees/<slug> on Windows, ~/dpf-worktrees/<slug> on macOS/Linux. Do NOT use Claude Code's default .claude/worktrees/<random> nesting inside the root clone, and do NOT use the older D:/DPF-<slug> alongside-the-clone form — one base, both surfaces. The dedicated base keeps worktrees out of the root clone's tree and gives the janitor one place to reap. → spec 2026-06-05-unified-delivery-surfaces-execution-alignment-design.md §4.1 + decision #1.main — local main may carry unpushed commits that sweep into your PR and fail DCO.Seed the worktree + agent toolchain. Claude Code's dpf connector is the dpf-platform plugin's URL-only descriptor, so every worktree already has it; no project .mcp.json is copied (a second dpf entry would load beside the plugin's — BI-5201141C). .vscode/mcp.json (VS Code's MCP config) is gitignored, so git worktree add does not carry it. Run the bootstrap from inside the new worktree:
pwsh scripts/dpf-bootstrap-agent-toolchain.ps1bash scripts/dpf-bootstrap-agent-toolchain.shThe bootstrap copies .vscode/mcp.json from the root clone when it has one, sets COMPOSE_PROJECT_NAME=dpf-<slug> in .env, converges the Claude Code + Codex client profiles to the DPF-scoped baseline (DPF MCP only + dpf-platform only; generic plugins/MCP servers disabled; the canonical worktree base + this worktree trusted in Codex), and writes the explicit ?tier=full endpoint required by those lazy-host registries. It seeds kernel memory, runs probes, and prints a readiness banner that flags residual drift. The legacy scripts/seed-worktree-mcp.{ps1,sh} shim still works for one release cycle.
Restart your agent in the worktree. Claude Code / Codex need a fresh session started in the worktree — /mcp should then list exactly one dpf server, from the plugin. A second dpf entry means a leftover project .mcp.json; see the MCP authorization runbook, "One dpf connector per client".
If the connector is healthy but a named DPF tool is absent from the attached set, use load_tools with an exact names entry or natural-language query. Notification-aware/generic clients then honor notifications/tools/list_changed or re-fetch tools/list. Codex must receive the full authorized catalogue at initial connection through its bootstrapped ?tier=full URL because its HTTP requests do not reliably identify the client and its top-level registry does not refresh mid-turn: inspect ALL_TOOLS inside functions.exec and invoke a present governed call through tools.mcp__dpf__<tool_name>(arguments). If a fresh task still omits the tool, confirm the configured URL contains tier=full and re-run bootstrap/restart the client before classifying it. If load_tools succeeds but the qualified tool remains absent from ALL_TOOLS, stop and diagnose the Codex connector/session snapshot; do not claim it is callable, install another plugin, use raw JSON-RPC, or bypass MCP authority.
Claim the BI once, with the complete identity. After the fresh session sees the DPF connector, call mcp__dpf__claim_backlog_item_for_work exactly once with the BI id, repository, topic branch, dedicated worktree path, provider, session reference, and explicit workIntent (design, review, plan, or implementation). The branch and worktree are the durable coordination key; do not omit sessionRef or intent and then retry with a different shape. A successful claim is a coordination signal, not proof of readiness. If the server returns branch_occupied, insufficient_token_scope, or another refusal, preserve that exact response and stop or request a governed handoff—never claim the same BI from a second worktree or churn session identities. Pass workShape as one of the five delivery shapes ([email protected], [email protected], [email protected], [email protected], [email protected]) when you know the size and what the work owes. If you omit it, the claim derives the shape from the item's effortSize and work type only when the classification rules agree; an implementation claim that cannot derive one is refused with work_shape_required and a pickList (each shape with its definition, appetite and the gates it owes). Put that list to the user and re-claim with their answer. Never guess a shape. delivery-xlarge never enters implementation: decompose it and claim the children.
Verify compose isolation. Before running any docker compose command in the worktree:
grep COMPOSE_PROJECT_NAME .env
The output should be COMPOSE_PROJECT_NAME=dpf-<slug>, NOT dpf. Compose commands from a worktree without isolation will collide with the root dpf stack — at best wasting cycles, at worst stomping on the root install's containers and volumes.
Confirm worktree health.
git status --short --branch
git rev-parse --abbrev-ref HEAD # should show your topic branch
git log origin/main..HEAD --oneline # should be empty (no commits yet)
Classify verification readiness. Run the probe — do not hand-check with test -d node_modules:
node scripts/lib/bootstrap-worktree-deps.mjs . --classify-only
A structural presence test is what let an empty apps/web/node_modules read as provisioned (BI-1C1483C6, 2026-08-04); the probe checks dependency resolution, @dpf/* workspace-link locality, and each named compile artifact for emptiness as well as absence.
compile-ready: dependencies resolve and every compile artifact is populated. Cheap source-local gates may run here.source-only: Git/MCP/Compose isolation is present, but local compile/test gates are not proven. Do code work here, but get verification from the shared local-CI convergence sandbox or canonical install. The missing array names each gap and what it forbids — apps/web/node_modules forbids pnpm --filter web typecheck (it fails as 'next' is not recognized); packages/db/generated forbids Prisma-touching tests (they fail as Cannot find module '../generated/client/client'). Those messages look exactly like real breakage; in a source-only worktree they are not.ignoredBuilds before compile-ready. If it returns dependencyPolicyReviewKeys, reuse those exact keys as backlog intake origins; they deliberately coalesce identical base-SHA + package/version + policy-reason findings across worktrees while keeping distinct dependency events separate.worktree-readiness-banner.mjs) prints this automatically. Its silence means compile-ready.node scripts/lib/bootstrap-worktree-deps.mjs . — never a bare pnpm install in a worktree. A worktree's node_modules is normally a junction to the root clone, so a bare install writes through it into the root clone (which it has previously gutted); root-clone-guard.mjs now denies that shape. If bootstrap is unavailable or would distract from the task, stay source-only and do not claim local gate passes.Before editing or reviewing from an existing worktree:
git status --short --branch and git rev-parse --abbrev-ref HEAD. Abort serious implementation on main or detached HEAD unless the user explicitly asked for inspection only..env has a non-root COMPOSE_PROJECT_NAME. If it is missing or dpf, run scripts/seed-worktree-mcp.{ps1,sh} before any Compose command.node scripts/lib/bootstrap-worktree-deps.mjs . --classify-only. .dpf-worktree-readiness.json is a cached marker, not the authority — a worktree created by the WorktreeCreate hook has no marker at all (that hook only PLACES the worktree; provisioning is deliberately opt-in per BI-3047C122). Treat the worktree as source-only until the probe says otherwise, and run scripts/seed-worktree-mcp.{ps1,sh} if the marker is missing and you want one written.source-only, you may edit and commit, but final answers and PR/evidence notes must say local worktree gates were not run and must point to canonical-runtime/local-CI evidence for any verification claim.With many sibling worktrees holding the same file paths, a command can succeed against the wrong copy and look entirely normal. The shell's working directory persists between tool calls: one cd into a sibling worktree silently retargets every later command that relies on a relative path.
RUN v<version> <root> — if that root is not your worktree, the results are another branch's. Pin it explicitly: node <abs>/node_modules/vitest/vitest.mjs run --root <ABSOLUTE pkg dir> <files>.grep -c ' it(' <file> against the reported test total. A passing run whose count doesn't match your file did not execute your file. The same logic applies to any "N passed" summary — reconcile N against something you can count in your own tree.git reset --hard origin/main, re-confirm git log --oneline -1; never assume the base you started from.This is a false green, not a flake: nothing errors, and the pass is real — for someone else's code.
**Worktree created.**
- Topic: <slug>
- Path: <D:\DPF-worktrees\slug | ~/dpf-worktrees/slug>
- Branch: <prefix>/<slug> (based on origin/main, 0 ahead)
- Seed: done (.vscode/mcp.json copied if present; COMPOSE_PROJECT_NAME=dpf-<slug> set in .env; dpf connector from the plugin)
- Verification readiness: <compile-ready | source-only> (<reason from .dpf-worktree-readiness.json>)
- Next step: restart Claude Code / Codex in <path>, then verify `/mcp` shows the dpf connector.
docker compose up/down/rm from a worktree without COMPOSE_PROJECT_NAME set. A docker compose down --volumes against the root dpf project from a worktree is the destructive operation that wiped the volume in the 2026-05-23 incident (project_2026_05_23_volume_wipe_recovery).main. Always origin/main after git fetch..mcp.json and .vscode/mcp.json are gitignored for a reason — a legacy-mode file can carry a bearer token.keep-root-clone-as-merge-worktree; raw git switch, git checkout, git reset, git pull, git merge, and git rebase in that clone are root mutations, not setup.source-only worktree can hold correct code, but its local typecheck/build/test status is unknown until proven in that worktree or in canonical runtime/local-CI.The current session ran in worktree gifted-banzai-3be1fb at D:\DPF\.claude\worktrees\gifted-banzai-3be1fb — created earlier by the harness, branched off origin/main. The MCP config was already seeded (the dpf connector was reachable for mcp__dpf__list_epics, create_backlog_item, etc throughout). Three commits landed on PR #1119 from this isolated worktree:
b930f46b — memo draft27729864 — audit report560a84d8 — principle_decide fixA sibling session running concurrently (the BS test thread the operator mentioned) operates in a separate worktree with its own MCP config and COMPOSE_PROJECT_NAME. Neither session's commits can sweep into the other's tree (per feedback_git_commit_only_for_concurrent_sessions, we also use explicit git add <path> in case both somehow land in the same tree — belt and suspenders).
dpf-worktree-hygiene — reaping, janitor flags, sandbox GC (not create)worktree-per-sessionpropose-acknowledge-reassignscripts/seed-worktree-mcp.ps1, scripts/seed-worktree-mcp.shproject_2026_05_23_volume_wipe_recovery (user memory)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
88 skills in this plugin
/asset-inventory-reconciliationReconcile recorded against observed assets.npx claudepluginhub opendigitalproductfactory/opendigitalproductfactory --plugin dpf-platformOther plugins' skills for the same job