swain-dispatch
Agent Dispatch (DEPRECATED)
This skill is deprecated. It requires an
ANTHROPIC_API_KEYwith per-token API billing, which is not compatible with Max/Pro subscriptions. Use parallel agents in-session or manual spike execution instead.
Dispatches swain-design artifacts to background agents via GitHub Issues. The agent runs autonomously using anthropics/claude-code-action@v1 on a GitHub Actions runner.
Note: In projects using the trunk+release branch model (ADR-013), dispatched work targets
trunk(the development branch), notrelease(the distribution branch).
Prerequisites
Three things must be in place before dispatch works:
- Claude GitHub App — installed on the repo from https://github.com/apps/claude (grants Contents, Issues, Pull Requests read/write)
- Workflow file —
.github/workflows/claude.yml(oragent-dispatch.yml) with theclaude-code-actionstep ANTHROPIC_API_KEYrepo secret — API key (not Max/Pro subscription; per-token billing required)
Step 0 — Preflight check
Run this before every dispatch. If any check fails, stop and show the setup instructions.
# 1. Check gh auth
gh auth status 2>/dev/null || { echo "FAIL: gh not authenticated"; exit 1; }
# 2. Check workflow file
WORKFLOW_FILE=""
for f in .github/workflows/claude.yml .github/workflows/agent-dispatch.yml; do
[[ -f "$f" ]] && WORKFLOW_FILE="$f" && break
done
# 3. Check API key secret
OWNER_REPO="$(gh repo view --json nameWithOwner -q .nameWithOwner)"
HAS_KEY=$(gh api "repos/${OWNER_REPO}/actions/secrets" --jq '.secrets[].name' 2>/dev/null | grep -c ANTHROPIC_API_KEY || true)
If workflow file is missing, show:
Dispatch setup required. No workflow file found.
Create
.github/workflows/claude.yml:name: Claude Code on: repository_dispatch: types: [agent-dispatch] issue_comment: types: [created] pull_request_review_comment: types: [created] issues: types: [opened, assigned] jobs: claude: if: | (github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) || (github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) || (github.event_name == 'issues' && contains(github.event.issue.body, '@claude')) runs-on: ubuntu-latest permissions: contents: write issues: write pull-requests: write id-token: write steps: - uses: actions/checkout@v4 - uses: anthropics/claude-code-action@v1 with: anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}Then commit and push before retrying dispatch.
If API key secret is missing, show:
Missing
ANTHROPIC_API_KEYrepo secret.Set it with:
gh secret set ANTHROPIC_API_KEY --repo {owner}/{repo}Note: This must be an API key (per-token billing), not a Max/Pro subscription token.
Dispatch workflow
Step 1 — Resolve the artifact
Parse the user's request to identify the artifact ID (e.g., SPEC-025, SPIKE-007).
ARTIFACT_ID="SPEC-025" # from user input
ARTIFACT_PATH="$(find docs/ -path "*${ARTIFACT_ID}*" -name "*.md" -print -quit)"
If not found, report the error and stop.
Step 2 — Read the artifact
Read the full artifact content. This becomes the issue body.
Step 3 — Read dispatch settings
Check swain.settings.json for dispatch configuration:
jq -r '.dispatch // {}' swain.settings.json 2>/dev/null
Defaults:
model:claude-sonnet-4-6maxTurns:15labels:["agent-dispatch", "swain"]autoTrigger:true
Step 4 — Create the GitHub Issue
gh issue create \
--title "[dispatch] ${ARTIFACT_TITLE}" \
--body "$(cat <<EOF
## Dispatched Artifact: ${ARTIFACT_ID}
This issue was created by `swain-dispatch` for background agent execution.
### Instructions
Implement the artifact below. Follow the acceptance criteria. Create a PR when done.
---
${ARTIFACT_CONTENT}
EOF
)" \
--label "agent-dispatch" --label "swain"
Capture the issue number from the output.
Step 5 — Trigger the workflow
If autoTrigger is true (default):
OWNER_REPO="$(gh repo view --json nameWithOwner -q .nameWithOwner)"
gh api "repos/${OWNER_REPO}/dispatches" \
-f event_type="agent-dispatch" \
-f client_payload[artifact]="${ARTIFACT_ID}" \
-f client_payload[issue_number]="${ISSUE_NUMBER}" \
-f client_payload[model]="${MODEL}" \
-f client_payload[max_turns]="${MAX_TURNS}"
Step 6 — Report
Tell the user:
Dispatched ${ARTIFACT_ID} to background agent. Issue: ${ISSUE_URL} Workflow will run on the next available runner. Monitor progress in the issue comments.
Manual dispatch
If the user prefers manual dispatch (or autoTrigger is false), skip Step 5 and tell them:
Issue created: ${ISSUE_URL} To trigger the agent, comment
@claudeon the issue.
Checking dispatch status
When the user asks about dispatch status:
gh issue list --label agent-dispatch --state open --json number,title,updatedAt
Show open dispatch issues with their last update time.
Trigger timing
The Claude Code Action workflow fires on different GitHub events depending on how @claude is mentioned:
| Mention location | Event | When it fires |
|---|---|---|
| Issue body at creation | issues.opened |
Immediately when issue is created |
| Comment on existing issue | issue_comment.created |
When the comment is posted |
Gotcha: If the workflow file didn't exist when the issue was created, the issues.opened event was missed. In that case, add a follow-up comment containing @claude to trigger via issue_comment.created instead.
The default dispatch workflow (Step 4 + Step 5) uses repository_dispatch which is independent of @claude mentions. The timing gotcha only applies when:
- Using manual dispatch (Step 5 skipped)
- The workflow relies on
issues.openedorissue_comment.createdevents
More from cristoslc/swain
swain-do
Task tracking and implementation execution for swain projects. Invoke whenever a SPEC needs an implementation plan, the user asks what to work on next, wants to check or update task status, claim or close tasks, manage dependencies, abandon work, bookmark context, or record a decision. Also invoked by swain-design after creating a SPEC that's ready for implementation. Tracks SPECs and SPIKEs — not EPICs, VISIONs, or JOURNEYs directly (those get decomposed into SPECs first). Triggers also on: 'bookmark', 'remember where I am', 'record decision'.
124swain-update
Update swain skills to the latest version. Use when the user says 'update swain', 'upgrade swain', 'pull latest swain', 'reinstall swain', 'refresh skills', or wants to update their swain skills installation. Uses npx to pull the latest swain release from GitHub, with a git-clone fallback, then invokes swain-doctor to reconcile governance and validate project health.
121swain-release
Cut a release — detect versioning context, generate a changelog from conventional commits, bump versions, create a git tag, and optionally squash-merge to a release branch. Use when the user says "release", "cut a release", "tag a release", "bump the version", "create a changelog", "ship a version", "publish", or any variation of shipping/publishing a version. This skill is intentionally generic and works across any repo — it infers context from git history and project structure rather than assuming a specific setup. Supports the trunk+release branch model (ADR-013) when a `release` branch exists.
121swain-design
Create, validate, and transition documentation artifacts (Vision, Initiative, Epic, Spec, Spike, ADR, Persona, Runbook, Design, Journey) through lifecycle phases. Handles spec writing, feature planning, epic creation, initiative creation, ADR drafting, research spikes, persona definition, runbook creation, design capture, architecture docs, phase transitions, implementation planning, cross-reference validation, and audits. Also invoke to update frontmatter fields, re-parent an artifact under a different epic or initiative, or set priority on a Vision or Initiative. Chains into swain-do for implementation tracking on SPEC; decomposes EPIC/VISION/INITIATIVE/JOURNEY into children first.
121swain
Meta-router for swain skills. Invoke when the user explicitly asks swain to do something — not merely when they mention the project by name. Routes to the matching swain-* sub-skill — only load the one that matches. If the user's intent matches multiple rows, pick the most specific match. Sub-skills that are not installed will gracefully no-op.
118swain-search
Trove collection and normalization for swain-design artifacts. Collects sources from the web, local files, and media (video/audio), normalizes them to markdown, and caches them in reusable troves. Use when researching a topic for a spike, ADR, vision, or any artifact that needs structured research. Also use to refresh stale troves or extend existing ones with new sources. Triggers on: 'research X', 'gather sources for', 'compile research on', 'search for sources about', 'refresh the trove', 'find existing research on X', or when swain-design needs research inputs for a spike or ADR.
112