lukasrepublic/agentic-foundry/dispatch
Claude Code and agent skill by lukasrepublic/agentic-foundry
- community
Checking that the SKILL.md file is still in the repository.
Dispatch one authorized atom's implementation to a worker via the NATIVE Agent tool (/foundry:dispatch). The lean replacement for the bespoke dispatch-queue + dispatch-agent stack — no queue/flock/manifest for SINGLE-REPO adopters. A MULTI-REPO adopter (workspace ⟷ product-clone) adds a minimal target_repo manifest + WorktreeCreate redirect + foundry-wt. Trigger to implement an AUTHORIZED atom in an isolated worktree, or point at workflows/release-wave.js for single-repo multi-atom fan-out.
Install
npx vskill@latest install lukasrepublic/agentic-foundry/dispatchSKILL.md
The same SKILL.md was published earlier as lukasrepublic/agentic-foundry/dispatch.
/foundry:dispatch
The lean dispatch path — a native-primitive REPLACEMENT for the bespoke dispatch stack. Worker spawn = the native `Agent` tool (isolation: "worktree", structured return); multi-atom fan-out = the native `Workflow` tool (workflows/release-wave.js). For a single-repo adopter this REPLACES the bespoke dispatch-agent + .claude/dispatch-queue/ machinery (queue manifests, flock, wt claim, WorktreeCreate prereqs, result.json polling, fan-out hygiene) — native primitives subsume it.
Single-repo only. Nativeisolation:worktreeworktrees the session repo (theworkspace). It CANNOT reach a separate gitignored product clone, so a multi-repoadopter (workspace ⟷ product-repo, e.g. acme-app, or self-hostingagentic-foundry/)still needs a re-extracted minimum: an explicit `target_repo` (a frozen+authorizedcontract field), a per-spawn dispatch manifest, the `WorktreeCreate` hook(foundry-worktree-create.sh) that redirects the worktree to the named product repo via`foundry-wt`, and worktree-time binding of the worker to that named repo (so its PR can onlyland there). See Multi-repo dispatch below. This is NOT the heavyweight bespoke queue — it isthe one fact native isolation cannot provide (which repo to worktree).
Native default vs. the deprecated bespoke fallback (feat-foundry-dispatch-on-native-workflow, AC-DNW-1..4)
Native is the default, unconditionally, for both a single atom and a wave — a single atom dispatches via the native Agent tool (below); a multi-atom wave dispatches via the native Workflow tool (workflows/release-wave.js, see Multi-atom fan-out). Neither routes through the bespoke dispatch-queue/process-spawn machinery by default.
The bespoke process-spawn path (foundry-fanout / foundry-spawn-worker + the FOUNDRY_DISPATCH=bespoke opt-in switch) went through deprecate-then-remove and was REMOVED — neither script ships and nothing consumes the switch. Native Agent/Workflow dispatch is the only path (workflows/release-wave.js for single-repo multi-atom fan-out).
When to trigger
- "implement
<atom>", "/foundry:dispatch<atom>", "dispatch the worker for<atom>". - For a release WAVE (N atoms): use
workflows/release-wave.jsvia theWorkflowtool, not N serial dispatches.
Preconditions (fail-closed)
- AUTHORIZED. The atom's
acceptance-contract.yamlmust be stateAUTHORIZED
(foundry_authz.spec_state). An un-authorized atom is never dispatched — front authorization is the gate. Refuse otherwise: "atom <x> is not AUTHORIZED; run /foundry:authorize first."
- Spawn context. The
Agenttool's worktree-isolated worker must run from a
context whose worker writes are not hook-blocked (a real dispatcher session, NOT a plain operator claude -n session — there, worker-cwd-enforcement fail-closes a non-null-agent_id subagent that has no assignment.json; do the work inline instead).
- Context-diet lint (advisory). Before spawning, run the assembled prompt through
python3 scripts/foundry_dispatch_lint.py <prompt-file-or-stdin> — it flags an inlined spec/contract body or a per-artifact block over the inline cap, naming the offending span. Advisory / fail-open at dispatch time (never blocks a spawn); add --strict to make a non-empty finding list a hard gate (e.g. in a CI preflight).
Procedure (single atom)
- Resolve the atom spec + its frozen
acceptance-contract.yaml; confirm AUTHORIZED. - Invoke the native `Agent` tool — no queue, no manifest:
subagent_type: the engineer agent (foundry:app-engineer/foundry:infra-engineer/foundry:framework-engineerper the atom's surface).isolation: "worktree"— native worktree (auto-cleaned if unchanged). The
foundry-cwd-enforce write-jail composes on top.
schema: the structured result (below) — REPLACES reading.agent/result.json.prompt: the worker contract — a claim check (AC-WCD-1), not an inline payload:
> Implement AUTHORIZED atom whose spec + frozen acceptance-contract.yaml are BY PATH > under $CLAUDE_PROJECT_DIR/specs/features/… — resolve and Read them in your own > context; do not expect either inlined here beyond a per-artifact cap of <N> chars > ($CLAUDE_PROJECT_DIR/.foundry/dispatch-inline-cap, default 2048 — a short quoted > checkpoint is fine, the whole normative region or the whole contract is not). Any > code-repo evidence artifact you produce (walk-evidence, test/build logs) resolves > relative to your OWN worktree root — never $CLAUDE_PROJECT_DIR. Do NOT weaken any > frozen acceptance-contract checkpoint. Run the live-seam walk (real boot + Chrome > MCP / real seam) against each frozen checkpoint's locator. Follow > context/branch-discipline.md — build on atom/<id> cut from the release's integration > branch, one push only after your local suite (and doctor) is green, and target the PR at > release/<version> (never main) whenever the release manifest names one. Cut the PR via > gh pr create; the merge floor (branch protection / required CI checks, plus > hooks/foundry-git-discipline.sh within sessions) decides the merge. Return the structured result per the > worker return contract below (pointers only), INCLUDING your learning records > (friction, successes, distill candidates) in learnings[] — the durable > worker-emission channel; do NOT rely on files left in the worktree, which is > auto-cleaned.
- Consume the structured return (native) —
{branch, pr_url, files_touched, seam_verdict, summary, learnings}. Noresult.jsonpolling; theAgenttool returns it directly. The worker'slearnings[]are captured automatically — aPostToolUse(Agent|Workflow)hook (foundry-harvest-learnings.sh posttooluse) writes them into.foundry/session-learnings/<date>/<sid>__<task>.jsonl(the/foundry:learn-distillpartition) when the tool call completes. Do not runcapture-returnby hand for anAgent/Workflowdispatch — the hook already did it (a manual run would double-capture).capture-returnis only for a direct caller that bypasses theAgenttool. The PreToolUse(Bash) sidecar harvest is defense-in-depth for any explicitgit worktree remove. - The merge floor. The PR is admitted by the native merge floor — branch protection / required
CI checks (docs/merge-floor.md), plus hooks/foundry-git-discipline.sh for any merge attempted from inside a session. Merge per the atom's merge_autonomy_mode (Regular → operator/diff-review; Lean → pr-reviewer pass + merge-on-green (reviewer advisory, never the merge approval)).
Run-duration capture is retired; scripts/foundry-autonomy-instrument.py (report-only, six ratios mined from transcripts + the authorization corpus) is the standing successor (feat-yield-and-silent-yield-instrument, autonomy-continuation R1).
Worker return contract (claim-check) — AC-WCD-2
RETURN POINTERS ONLY: a status enum, evidence PATHS, and learnings[] — NEVER return a full file body.
This rule is stated VERBATIM in every dispatch template (this skill's step-2 worker contract above) so a compliant worker never round-trips an artifact it could reference by path instead: a spec, a contract, a diff, a log — the worker Reads it directly in its own context and returns only the PATH to it (plus the structured fields below), never its body.
Result schema (replaces result.json)
status is a closed enum (ready|failed); evidence and files_touched are PATHS, never inlined bodies (the claim-check rule above). The learnings[] records are the durable worker-emission channel: the dispatcher captures them from the return into the session-learnings buffer (step 3), so they survive the worktree auto-clean by construction — no teardown race, no dependence on reading the ephemeral worktree. Records are forwarded UNVALIDATED; /foundry:learn-distill is the schema authority.
Multi-atom fan-out
Run workflows/release-wave.js through the Workflow tool with args = the list of authorized atom spec paths. It pipelines each atom implement → verify independently (native concurrency cap + journaling + resumeFromRunId), replacing the bespoke fan-out-hygiene checklist + the durable queue for the in-session case.
Per-worker ephemeral env isolation + the conductor mutex (feat-foundry-per-worker-ephemeral-env-and-conductor-mutex, AC-PWE-1..4)
Concurrent fan-out (up to the native Workflow concurrency cap) means N workers may each bring up an ephemeral dev/test environment at once — a recorded design gap (a design-partner): identical fixed-port compose services collided and forced live-seam walks to serialize, and a duplicate-conductor race let two sessions drive the SAME release onto shared worktrees concurrently. scripts/foundry_env_isolation.py fixes both:
- Non-colliding port/namespace per worker (AC-PWE-1). Each worker's ephemeral env claims
its port via allocate_ephemeral_port() — OS-assigned dynamic (ephemeral) ports (socket.bind((host, 0))). The kernel's atomic bind(2) IS the coordination: concurrently STARTING workers cannot be handed the same port (no unsynchronized read-then-bind). Hand-off caveat: that atomicity holds only while the socket is HELD OPEN — the close() → real-service-bind() hand-off is its own TOCTOU window, so a worker should keep the foundry socket open until its real service binds (or hand off via SO_REUSEPORT/fd-passing), never close() then assume the port is still reserved.
- Conductor mutex — one driver per release (AC-PWE-2). Before a driver (a
/foundry:dispatch
loop or release-wave.js orchestrator) starts DRIVING a release wave, it acquires acquire_conductor_mutex(release_id, blocking=False) — fcntl.flock(LOCK_EX|LOCK_NB) keyed by the release id's CANONICALIZED form, so differently-spelled invocations of the same release (including a v+whitespace spelling, e.g. "v 0.19.0" — whitespace is collapsed BEFORE the leading-v strip) contend for the SAME lock. FAIL-CLOSED: acquisition failure means the driver MUST NOT proceed. A dead holder's lock is reclaimable without a separate staleness check — the kernel auto-releases a flock at process exit/SIGKILL, so reclaim is the SAME atomic flock() call, never a racy two-step client protocol.
- Reaped on worker death (AC-PWE-3).
hooks/foundry-env-reap.sh(SessionEnd) also reclaims
a worker's port allocation if it died abnormally (crash/SIGKILL) without releasing — preservation anchors on the holder's LIVE START-TIME alone (command is advisory-only: a live worker that exec()s into its real service changes argv but keeps its pid+start-time), and a ps-probe FAILURE is treated as inconclusive and PRESERVES rather than convicting a live worker — so it NEVER reclaims a still-live concurrent worker's allocation, including under a transient probe error.
- Single-worker path is unchanged (AC-PWE-4). A lone dispatch acquires the conductor mutex
without contention and the existing env-hygiene teardown lifecycle is untouched.
Live-seam: python3 -m pytest tests/test_env_isolation.py -q (converted to pytest in the v0.25.0 test-suite realignment).
Worker definition-of-done self-gate (feat-foundry-worker-dod-self-gate, AC-WDG-1..4)
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/dispatch/SKILL.md
Popularity
- Repository stars
- 1
- 7-day trend score
- 3
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/lukasrepublic/agentic-foundry/dispatch)