Do epic

From thermiteau/maverick · View interactive version

Do epic is an AI agent skill from the GitHub repository thermiteau/maverick. Work on a multi-story GitHub epic end-to-end. Builds a DAG from the child stories, groups them into waves, runs waves in parallel via per-story worktrees, ejects PRs that fail agent-code-review for human handling, and propagates blocks to downstream stories. Requires git worktrees.

How to use this skill

Skill file

Work on GitHub Epic (Autonomous, DAG-scheduled)

Work on epic issue $ARGUMENTS end-to-end. Builds a dependency DAG

from the epic's child stories, schedules them into waves, runs each wave

in parallel via per-story worktrees, and drives every story through agent

code review with binary PASS/FAIL verdicts.

Preflight (mandatory)

Run this first. If it exits non-zero, halt and report the stderr output to the user verbatim. Do not claim, do not branch, do not start any worktree.

uv run maverick preflight do-epic

The check verifies: the project is initialised, the Maverick GitHub

App is configured (maverick gh-app status reports configured: true),

git worktrees are usable, and required tools (gh, git, uv) are on

PATH. PR code review runs locally inside each story's worktree as the

agent-code-reviewer subagent (delegated from

do-issue-solo Phase 9). For epics that fan out across

many parallel workers, consider opting into the CI-side re-run

described in mav-bp-remote-code-review so the merge is

gated by an independent check even if a worker's local review fails to

fire — that workflow is optional and not enforced by preflight.

Before You Begin

$ARGUMENTS must be the GitHub issue number of a Maverick epic

— an issue whose body contains a task table of child stories. If it is

a single story, dispatch do-issue-solo instead.

Phase 0: Coordination

  1. Resolve repo: gh repo view --json nameWithOwner.
  2. Cold-start hydrate per mav-durability-on-gh:

propagation first** before continuing.

  1. Decide claim scope:

you were asked about.

  1. Claim: uv run maverick coord claim <repo> $ARGUMENTS --scope <csv-of-issues>.

On ClaimRejected, abort and report per

mav-multi-instance-coordination.

  1. Start heartbeat daemons for every issue in the claim scope. Each

daemon exits on its own when the matching claim is released; check

liveness anytime with coord heartbeat-status:

```bash

for issue in <epic> <story1> <story2> …; do

uv run maverick coord heartbeat-loop <repo> $issue --daemonize

done

```

Never background the foreground loop with & — a process backgrounded

from a tool shell dies with the shell or leaks unobservably.

  1. Release on exit is automatic. The plugin's SessionEnd hook runs

coord release-all, releasing every claim this instance recorded —

the matching heartbeat-loop processes detect the cleared labels and

exit on their own; lease expiry covers machine death. Your only

explicit releases are the per-story ones at workflow boundaries

(merged / ejected). Do not attempt trap-on-exit wrappers — each Bash

call is a fresh shell, so a trap cannot survive to session end.

Phase 1: Design + task decomposition (if needed)

If the epic does not yet have a solution design:

  1. Dispatch agent-issue-analyst with the epic issue.
  2. Dispatch agent-github-issue-planner — the planner will

create child stories as sub-issues (per the ≥ 5-tasks threshold in

mav-create-tasks).

  1. Extend the claim to cover every newly-created child story:

uv run maverick coord claim <repo> <child-issue> for each.

If the epic already has stories, skip to Phase 2.

Phase 2: DAG analysis

Build a machine-readable DAG of child stories.

  1. For each child story, read its issue body. Look for:
  1. Construct the DAG payload per the schema in

docs/conventions/github-markers.md:

```json

{

"epic": $ARGUMENTS,

"stories": {

"140": {"deps": [], "files": ["app/src/boot.ts"]},

"142": {"deps": ["140"], "files": ["app/src/admin/guard.ts"]}

}

}

```

  1. Persist the DAG to GitHub — this is durable for any instance to

resume from. Pipe the payload JSON on stdin and let the CLI compose

and upsert the fenced marker (never hand-compose marker comments, and

never stage the payload in a fixed /tmp path — concurrent runs share

it, #159):

```bash

uv run maverick gh-state write <repo> $ARGUMENTS maverick-dag --payload-file - <<'EOF'

<DAG payload JSON>

EOF

```

Phase 3: Wave grouping

uv run maverick dag waves <repo> $ARGUMENTS

The output is a list of lists — each inner list is a set of stories with

no un-satisfied deps on later waves. Record the waves in the epic's

human-readable task-table comment as well, so a human skimming the epic

can see execution order.

Phase 4: Initialise epic state

  1. For each child story, seed maverick-state with initial status:
  1. Persist:

```bash

uv run maverick state set <repo> $ARGUMENTS <story> <status>

```

Each call mirrors the local cache to the maverick-state marker on

the epic.

Phase 5: Wave loop

Repeat until every story is terminal (merged or ejected) or every

remaining wave is fully blocked.

Phase 5a: Select the next wave

  1. Read waves: uv run maverick dag waves <repo> $ARGUMENTS.
  2. Read current state: uv run maverick state show <repo> $ARGUMENTS.
  3. Pick the first wave whose every member is not yet merged.
  4. Exclude stories carrying blocked-by:#N — re-read the labels at

selection time so human-resolved ejections automatically unblock.

  1. If every remaining story in every remaining wave is blocked, halt

the epic cleanly:

Phase 5b: Create worktrees

Resolve the story base branch from config:

STORY_BASE=$(uv run maverick git-workflow story-base)

For each unblocked story in the wave, decide its base branch:

unmerged, stack per mav-stacked-prs.

Create the worktree:

uv run maverick worktree create <branch> [--base <sibling-branch>]

Phase 5c: Parallel-or-serial decision

Decide based on:

session; if unsure, default to serial.)

If parallel: dispatch one subagent per worktree, running

do-issue-solo for that story inside that worktree. Track

the subagents and aggregate results. Every story prompt must:

maverick-issue: <story> in every agent it dispatches and every inner

skill it invokes.

This session holds the epic's claim plus one per in-flight story, so

the plugin hooks can only attribute a dispatch to the right story's

report through that marker (or the story branch checked out in the

working directory). Without it, story reports show no dispatches.

If serial: iterate worktrees one at a time, running

do-issue-solo in each.

Phase 5d: Per-story flow

For each story being worked on (whether as subagent or serially):

  1. Re-verify the claim: uv run maverick coord heartbeat <repo> <story>

— if the story now carries blocked-by:#N, abort without pushing.

  1. Run the story through do-issue-solo's per-story phases

(Phase 4 onward — branch is already created).

  1. On FAIL from agent-code-reviewer (eject) — FAIL means the

MAVERICK_VERDICT: FAIL marker parsed in do-issue-solo

Phase 9; a missing or ambiguous marker counts as FAIL:

uv run maverick state set <repo> $ARGUMENTS <story> ejected.

  1. On PASS + auto-merge:

Draft until the story's agent reports done. Every story PR is

opened as a draft (do-issue-solo Phase 8), and only that

story's own run marks it ready, at its Phase 10 step 3 or on eject.

The coordinator treats a draft story PR as unfinished, and never marks

one ready or merges it on a story's behalf. If the coordinator itself

changes a story branch — a conflict resolution, a base merge, a

regenerated migration — it first runs

uv run maverick pr ready <repo> <pr> --undo, and the story goes back

through do-issue-solo Phase 8 step 5 onward. A project

that merges story PRs through its own queue instead of auto-merge runs

uv run maverick pr ready <repo> <pr> --expect-head <sha> immediately

before gh pr merge, so a head that moved since the gates ran is never

merged.

Phase 5e: Wave completion

When every story in the wave is terminal (merged or ejected):

  1. If every remaining wave is fully blocked by ejections, halt

(Phase 5a's block check handles this on the next iteration).

  1. Otherwise, return to Phase 5a for the next wave.

Phase 6: Epic completion

  1. Every child story is either merged or ejected.
  2. Epic-level security audit (mandatory). Each story's security

review only sees its own diff and one or two hops around it. Problems

in code no story touched — a logger without redaction, a handler that

skips a check, a stale database grant — never appear in any diff, so

only a whole-codebase pass finds them. Run it once per epic, against

the merged result:

1. Refresh the story base in the main checkout

(git fetch origin "$STORY_BASE" and fast-forward it) so the

audit sees every merged story.

2. Dispatch agent-security-reviewer with

Mode: full-audit, the epic's title and goal as the spec, and the

line maverick-issue: $ARGUMENTS.

3. For each critical or high finding, look for an open issue that

already covers it

(gh issue list --label security-audit --state open --search "<file path>").

If none does, open one with the Maverick GitHub App identity,

labelled security-audit (plus needs-human for critical),

with the finding's location, description and recommendation and a

Found by the epic #$ARGUMENTS audit. line. Create the label

first if it doesn't exist.

4. If the audit proposes invariant checks (findings a script could

catch every time), open one issue listing them, labelled

security-audit, so they get added to checks.commands.

  1. Epic-level docs sweep (mandatory). Per-story docs reviews see one

diff each and miss drift that builds up across stories.

1. Concatenate the merged stories' diffs into one file in a fresh

temporary directory (gh pr diff <pr> for each merged PR).

2. Dispatch agent-tech-docs-writer in update mode

with that diff, the docs the epic and its stories cite, and the

line maverick-issue: $ARGUMENTS. Instruct it to **report

only** (it is running on the base branch, where nothing may be

committed directly): return each stale doc with what is stale.

3. Group the stale docs by owner (uv run maverick docs owners <path> ...)

and open one follow-up issue per group, labelled with the owner's

label (default docs-drift) and naming the owner. If an owner

has an agent, say so in the issue so whoever picks it up

dispatches that agent.

  1. Post a summary comment on the epic:

issues opened in steps 2–3 (or "none").

  1. Update maverick-state one last time.
  2. Release the epic-level claim:

uv run maverick coord release <repo> $ARGUMENTS (the default

reason; don't pass the bare word as an argument — worktree-isolated

agents have it refused, #160).

  1. The heartbeat-loop background processes self-terminate within one

--interval window once their claims are released — wait for them

if you backgrounded them with PIDs, or just let the parent shell exit.

  1. Close the epic issue only if no stories were ejected AND the

per-project close policy allows it (#52). Per-PR closes for child

stories already ran via do-issue-solo Phase 10, but the epic

itself spans multiple branches/PRs, so the simple close-on-merge

CLI doesn't fit — query the policy and decide:

```bash

policy=$(uv run maverick issue policy)

if [ "$policy" != "manual" ] && [ "$ejected_count" -eq 0 ]; then

gh issue close $ARGUMENTS \

--comment "Epic complete: $merged_count stories merged."

fi

```

If any stories were ejected, leave the epic open for the human to

resolve them and close manually. If the policy is manual, leave

the epic open regardless — the team's promotion workflow handles

final close.

Resumption

At any entry, if another instance was mid-flight:

per mav-block-propagation.

died — decide takeover per mav-multi-instance-coordination.

means those stories are orphaned — reclaim and resume, or mark back to

pending if the worktree was destroyed.

The workflow is idempotent on every entry — you can re-run do-epic on

the same epic any number of times and it will converge to the same final

state.

Rules

agent-code-reviewer. No fix loop.

still gating or changing it. Ready means a person, or the merge, is

next.

safe; the marker-walk-clear protocol handles partial completion.

human.

<!-- maverick-plugin-version: 5.3.1 -->

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.