Loading...
Loading...
This skill should be used when dispatching autonomous development or review tasks from GitHub issues. Covers scanning for new issues with the 'autonomous' label, dispatching dev-new/dev-resume/review processes, dependency checking, retry counting, stale process detection, and concurrency limiting. Use when asked to "run the dispatcher", "scan for pending issues", "dispatch autonomous tasks", "check stale agents", or "set up the dispatch cron".
npx skill4agent add zxkane/autonomous-dev-team autonomous-dispatcherghghscripts/gh-app-token.sh# Source the shared token generator
source "${PROJECT_DIR}/scripts/gh-app-token.sh"
# Generate token for the dispatcher's GitHub App
GH_TOKEN=$(get_gh_app_token "$DISPATCHER_APP_ID" "$DISPATCHER_APP_PEM" "$REPO_OWNER" "$REPO_NAME") || {
echo "FATAL: Failed to generate GitHub App token" >&2
exit 1
}
if [[ -z "$GH_TOKEN" ]]; then
echo "FATAL: GitHub App token is empty" >&2
exit 1
fi
export GH_TOKENDISPATCHER_APP_PEMGH_TOKENghREPOowner/repomyorg/myprojectPROJECT_DIRMAX_CONCURRENT5MAX_RETRIESstalled3PROJECT_IDprojectDISPATCHER_APP_IDDISPATCHER_APP_PEMscripts/dispatch-local.shscripts/nohupscripts/autonomous.conf# PROJECT_DIR is the absolute path to the project root
# For new dev task:
bash "$PROJECT_DIR/scripts/dispatch-local.sh" dev-new ISSUE_NUM
# For review task:
bash "$PROJECT_DIR/scripts/dispatch-local.sh" review ISSUE_NUM
# For resume dev task:
bash "$PROJECT_DIR/scripts/dispatch-local.sh" dev-resume ISSUE_NUM SESSION_IDin-progressreviewingACTIVE=$(gh issue list --repo "$REPO" --state open --limit 100 \
--label "autonomous" --json labels \
-q '[.[] | select(.labels[].name | IN("in-progress","reviewing"))] | length')autonomousgh issue list --repo "$REPO" --state open --limit 100 \
--label "autonomous" --json number,labels,title \
-q '[.[] | select(
[.labels[].name] | (
contains(["in-progress"]) or
contains(["pending-review"]) or
contains(["reviewing"]) or
contains(["pending-dev"]) or
contains(["stalled"]) or
contains(["approved"])
) | not
)]'## Dependencies#N# Extract dependency issue numbers from the issue body
DEPS=$(gh issue view ISSUE_NUM --repo "$REPO" --json body -q '.body' \
| sed -n '/^## Dependencies/,/^## /p' \
| grep -oP '#\K[0-9]+')
# Check if all dependencies are closed
BLOCKED=false
for DEP in $DEPS; do
STATE=$(gh issue view "$DEP" --repo "$REPO" --json state -q '.state')
if [ "$STATE" != "CLOSED" ]; then
BLOCKED=true
break
fi
done
if [ "$BLOCKED" = true ]; then
# Skip this issue — dependency not yet resolved
continue
fiin-progressDispatching autonomous development...bash "$PROJECT_DIR/scripts/dispatch-local.sh" dev-new ISSUE_NUMautonomouspending-reviewreviewinggh issue list --repo "$REPO" --state open --limit 100 \
--label "autonomous,pending-review" --json number,labels \
-q '[.[] | select([.labels[].name] | contains(["reviewing"]) | not)]'pending-reviewreviewingDispatching autonomous review...bash "$PROJECT_DIR/scripts/dispatch-local.sh" review ISSUE_NUMautonomouspending-devgh issue list --repo "$REPO" --state open --limit 100 \
--label "autonomous,pending-dev" --json number,labels,commentsAgent Session Report (Dev)RETRY_COUNT=$(gh issue view ISSUE_NUM --repo "$REPO" --json comments \
-q '[.comments[] | select((.body | test("Agent Session Report \\(Dev\\)")) and (.body | test("Exit code: 0") | not))] | length')
MAX_RETRIES="${MAX_RETRIES:-3}"
if [ "$RETRY_COUNT" -ge "$MAX_RETRIES" ]; then
# Issue has exceeded retry limit — mark as stalled
gh issue edit ISSUE_NUM --repo "$REPO" \
--remove-label "pending-dev" \
--add-label "stalled"
gh issue comment ISSUE_NUM --repo "$REPO" \
--body "Issue has exceeded the maximum retry limit ($MAX_RETRIES failed attempts). Marking as stalled. @${REPO_OWNER} please investigate manually."
continue
fiMAX_RETRIESstalledpending-devDev Session ID:Review Session ID:SESSION_ID=$(gh issue view ISSUE_NUM --repo "$REPO" --json comments \
-q '[.comments[].body | capture("Dev Session ID: `(?P<id>[a-zA-Z0-9_-]+)`"; "g") | .id] | last // empty')pending-devin-progressResuming development (session: SESSION_ID)...bash "$PROJECT_DIR/scripts/dispatch-local.sh" dev-resume ISSUE_NUM SESSION_IDin-progressreviewingin-progress/tmp/agent-${PROJECT_ID}-issue-ISSUE_NUM.pidreviewing/tmp/agent-${PROJECT_ID}-review-ISSUE_NUM.pid# For in-progress issues:
kill -0 $(cat /tmp/agent-${PROJECT_ID}-issue-ISSUE_NUM.pid 2>/dev/null) 2>/dev/null && echo ALIVE || echo DEAD
# For reviewing issues:
kill -0 $(cat /tmp/agent-${PROJECT_ID}-review-ISSUE_NUM.pid 2>/dev/null) 2>/dev/null && echo ALIVE || echo DEADin-progressTask appears to have crashed. Moving to pending-review for assessment.in-progresspending-reviewreviewingReview process appears to have crashed. Moving to pending-dev for retry.reviewingpending-devopenclaw cron add \
--name "Autonomous Dispatcher" \
--cron "*/5 * * * *" \
--session isolated \
--message "Run the autonomous-dispatcher skill. Check GitHub issues and dispatch tasks." \
--announce| Label | Color | Description |
|---|---|---|
| | Issue should be processed by autonomous pipeline |
| | Agent is actively developing |
| | Development complete, awaiting review |
| | Agent is actively reviewing |
| | Review failed, needs more development |
| | Review passed. PR merged (or awaiting manual merge if |
| | Used with |
| | Issue exceeded max retry attempts; requires manual investigation |
| Task | Model | Rationale |
|---|---|---|
Development ( | Opus (default) | Complex coding, architecture decisions |
Review ( | Sonnet ( | Checklist verification, avoids Opus quota contention |