Loading...
Loading...
Dispatch a swain artifact to a GitHub Actions runner for autonomous implementation via Claude Code Action. Creates a GitHub Issue with the artifact content and triggers the workflow for background execution. Use when the user says 'dispatch', 'send to background agent', 'run this autonomously', 'GitHub Actions', or wants to hand off a SPEC for autonomous implementation.
npx skill4agent add cristoslc/swain swain-dispatchanthropics/claude-code-action@v1.github/workflows/claude.ymlagent-dispatch.ymlclaude-code-actionANTHROPIC_API_KEY# 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)Dispatch setup required. No workflow file found.Create:.github/workflows/claude.ymlyamlname: 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.
Missingrepo secret.ANTHROPIC_API_KEYSet 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.
SPEC-025SPIKE-007ARTIFACT_ID="SPEC-025" # from user input
ARTIFACT_PATH="$(find docs/ -path "*${ARTIFACT_ID}*" -name "*.md" -print -quit)"swain.settings.jsonjq -r '.dispatch // {}' swain.settings.json 2>/dev/nullmodelclaude-sonnet-4-6maxTurns15labels["agent-dispatch", "swain"]autoTriggertruegh 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"autoTriggerOWNER_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}"Dispatched ${ARTIFACT_ID} to background agent. Issue: ${ISSUE_URL} Workflow will run on the next available runner. Monitor progress in the issue comments.
autoTriggerIssue created: ${ISSUE_URL} To trigger the agent, commenton the issue.@claude
gh issue list --label agent-dispatch --state open --json number,title,updatedAt@claude| Mention location | Event | When it fires |
|---|---|---|
| Issue body at creation | | Immediately when issue is created |
| Comment on existing issue | | When the comment is posted |
issues.opened@claudeissue_comment.createdrepository_dispatch@claudeissues.openedissue_comment.created