You are a coordinator launching parallel agents to work on independent features autonomously.
Context
.projd/agent.json:
!./.projd/scripts/skill-context.sh agent-json
Features:
!./.projd/scripts/skill-context.sh features
Current branch: !./.projd/scripts/skill-context.sh branch
CLAUDE.md overview:
!./.projd/scripts/skill-context.sh claude-md
Arguments
$ARGUMENTS
Instructions
1. Read dispatch config
Read .projd/agent.json and extract the dispatch settings:
dispatch.max_agents: maximum concurrent agents (default 20 if missing)dispatch.auto_review: whether to auto-review and merge PRs (default false if missing)
Also read the git settings for branch prefix and push permissions.
2. Identify parallelizable features
From the feature summary above:
- Filter:
status == "pending" - Filter:
blocked_byis empty, OR every ID inblocked_byhasstatus: "complete" - Group into parallelizable sets: features that have no mutual
blocked_byrelationships can run simultaneously
3. Dry run check
If $ARGUMENTS contains --dry-run:
- Present the dispatch plan as a table: feature id, name, priority, will be dispatched in parallel?
- Show dispatch config: max_agents, auto_review
- Note how many waves are needed if eligible features exceed max_agents
- Do NOT spawn any agents. Stop here.
4. Read full feature files
For each feature to dispatch, read the full .projd/progress/{id}.json to get acceptance criteria and description.
5. Spawn worker agents
For each feature (up to max_agents concurrent):
Spawn an Agent with:
isolation: "worktree"-- gives each agent its own git working directoryrun_in_background: true-- agents work in parallel
Determine the base branch from the "Current branch" in the Context section above. This is the branch all feature branches will be created from and all PRs will target.
Each agent prompt must include:
- The feature ID, name, and full description
- All acceptance criteria
- The branch prefix from .projd/agent.json (agent must create branch
{prefix}{feature-id}) - The base branch (so the agent knows what to target for PRs)
- Instructions to:
- Create the feature branch:
git checkout -b {prefix}{feature-id} - Update
.projd/progress/{feature-id}.jsonwithstatus: "in_progress",branch, and"base_branch": "{base_branch}" - Implement all acceptance criteria
- Run
./.projd/scripts/smoke.shto verify - Commit all changes with descriptive messages
- If smoke passes and all criteria met: set
status: "complete", push branch, create PR viagh pr create --base {base_branch}. Include a Test plan section in the PR body: run every test you can (smoke, unit tests, lint, syntax checks) and mark results with[x]/[ ]. Only leave unchecked items that require manual testing. - If incomplete: set notes with progress, write .projd/HANDOFF.md
- Create the feature branch:
- Key conventions from CLAUDE.md (code style, test patterns)
If more eligible features than max_agents, dispatch in waves -- wait for the current batch to finish before starting the next.
6. Collect worker results
Wait for all worker agents to complete. For each:
- Check if the feature was marked complete
- Note any failures or partial completions
- Collect PR URLs if created
7. Auto-review (conditional)
Skip this step entirely if auto_review is false.
For each worker that completed successfully and created a PR, spawn a review agent:
isolation: "worktree"-- isolated working directoryrun_in_background: true-- reviewers work in parallel
Each review agent prompt must include:
The PR number and URL
The feature ID, feature branch name, and all acceptance criteria
The main repo path (absolute path to the main clone -- the agent's own working dir is a review worktree, so it must
cdto this path for anygh pr mergeor cleanup work)Instructions to:
Step A -- Checkout and verify:
- Check out the PR:
gh pr checkout <number> - Run
./.projd/scripts/smoke.sh - Review the diff (
gh pr diff <number>) against each acceptance criterion - Determine: PASS (all criteria met, smoke passes) or FAIL (with specific issues)
Step B -- If PASS:
cd <main-repo-path>(in its own Bash call, so the session CWD updates --gh pr mergefails when run from inside a worktree, and chainedcd && ghin one call does not update the session CWD that the git-policy hook sees)- Merge the PR:
gh pr merge <number> --squash --delete-branch - Pull the latest base branch and update
.projd/progress/{feature-id}.json: set"status": "complete"; commit this update to the base branch - Clean up the feature worktree and branch:
./.projd/scripts/cleanup-agent.sh <feature-branch> - Report: merged successfully
Step C -- If FAIL:
- Assess each issue: is the fix trivial (1 line change) or non-trivial?
- Trivial fix (1 LOC): fix it directly, commit with a descriptive message, push to the PR branch
- Non-trivial fix: spawn a subagent (with
isolation: "worktree") that receives:- The PR branch name
- The specific issues found
- The acceptance criteria
- Instructions to: check out the branch, fix the issues, run smoke, commit, and push
- After fixes (direct or via subagent): re-run
./.projd/scripts/smoke.sh - If smoke passes now:
a.
cd <main-repo-path>(separate Bash call -- see Step B.1) b. Merge the PR viagh pr merge <number> --squash --delete-branchc. Pull the latest base branch and update.projd/progress/{feature-id}.json: set"status": "complete"; commit this update to the base branch d. Clean up:./.projd/scripts/cleanup-agent.sh <feature-branch> - If still failing: leave a review comment on the PR (
gh pr review <number> --comment --body "<issues>") and report as needs-attention
- Check out the PR:
8. Collect review results
Wait for all review agents to complete. For each:
- Record whether the PR was merged, fixed-and-merged, or flagged for attention
- Collect any review comments or fix descriptions
9. Report
Present a summary table:
| Feature | Worker | Review | PR | Notes |
|---|---|---|---|---|
| feature-id | complete/partial/failed | merged/fixed/needs-attention/skipped | URL | ... |
Guardrails
- Respect
max_agentsfrom.projd/agent.jsondispatch config. Default to 20 if not set. - Do NOT retry failed worker agents automatically. Report failures for the operator to decide.
- Each agent gets a focused, single-feature prompt. Do not include unrelated features or exploration instructions.
- Review agents must not modify code unrelated to the issues they found.
- If
allow_pushisfalsein .projd/agent.json, skip both pushing and auto-review (there are no PRs to review).
Output
End with:
Dispatched [N] agents. [M] completed, [K] merged, [J] need attention.