From m2ai-skills-pack
Run an After-Action Review on an agent dispatch run, build execution, or multi-step orchestrated operation. Gathers forensics across the orchestrator DB, A2A endpoints, pm2 logs, git history, and queue files; classifies failure modes; captures benchmarks; produces a structured AAR. Use when the user says "aar", "after action review", "let's review what happened", "review this run", or after any dispatch that produced mixed results worth learning from.
How this skill is triggered — by the user, by Claude, or both
Slash command
/m2ai-skills-pack:aarThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Structured review for agent dispatch runs, build executions, or any multi-step operation that produced data worth learning from. Not a generic post-mortem — this is tuned to orchestrated agent systems with a mission/task DB, A2A endpoints, and a queue file.
Structured review for agent dispatch runs, build executions, or any multi-step operation that produced data worth learning from. Not a generic post-mortem — this is tuned to orchestrated agent systems with a mission/task DB, A2A endpoints, and a queue file.
One of:
Ask once which one, default to "this session" if unclear.
Run these in parallel where possible. Never skip a source — missing data is the most common cause of a shallow AAR.
Query the orchestrator's task DB (path in $ORCHESTRATOR_DB). Example with better-sqlite3:
node -e "
const Database = require('better-sqlite3');
const db = new Database(process.env.ORCHESTRATOR_DB, {readonly: true});
// status, result, error, runtime, claimed_at
// Use WHERE created_at > <unix_ts> OR parent id
"
Capture: status, error, result (first 500 chars), runtime (completed_at - claimed_at), agent_id, title.
For each task still queryable in the A2A task store:
curl -s "http://localhost:<agent_port>/task/<task_id>" | python3 -m json.tool
Agent ports are whatever your orchestrator exposes. Logs often expire after task completion — if empty, move on, don't block.
pm2 logs <orchestrator-process> --lines 80 --nostream
pm2 logs <agent-process> --lines 40 --nostream
Grep for the task id or the failure window timestamps. Watch for dispatcher events.
git -C <repo> log --oneline -20
git -C <repo> status --short -b
Flag any WIP: auto-snapshot commits in the window — if you run a periodic auto-snapshot cron, these often indicate interrupted agent work. Check if they're pushed (ahead 0 = pushed, ahead N = local-only).
If you maintain a queue file (path in $OPEN_ITEMS_JSON):
python3 -c "import json, os; d=json.load(open(os.environ['OPEN_ITEMS_JSON'])); ..."
Cross-reference: did the tasks map back to queue items? Are statuses consistent (pending/dispatched/in_progress)?
pgrep -af "claude --dangerously"
Subprocess gone but status=running in DB = stuck executor, diagnose A2A state machine.
Use these dispatch-specific failure modes, in order of specificity:
| Mode | Signature |
|---|---|
max_turns | error contains "Reached max turns". Turn cap too low for task scope. |
timeout | runtime > 0.9 * agent timeout (usually 900s). Task wall-clock exceeded. |
subprocess_crash | Non-zero exit code, error mentions signal/SIGTERM/OOM. |
wip_snapshot_collision | A WIP: auto-snapshot commit lands during the task window, mixing multiple agents' edits. |
node_modules_corruption | npm install exited mid-run inside agent subprocess. Missing binaries in .bin/. |
race_condition | Multiple agents wrote the same file within seconds of each other. Git blame shows interleaved authorship. |
scope_mismatch | Task scope (multi-day subsystem) too large for the dispatched agent's turn/time budget. |
skipped_step | Agent's result text shows steps it didn't actually execute (check by inspecting side effects). |
dispatch_layer_ok_exec_layer_failed | Planner/coordinator succeeded but downstream executors failed. Separates "dispatch machinery" health from "execution machinery" health. |
Every failure should map to at least one mode. Multiple can apply.
Every AAR produces durable benchmark data. Record:
If you maintain per-agent feedback memory files (e.g. feedback_<agent>_task_sizing.md), update the existing one — don't create duplicates.
Structure (stick to this — don't invent new sections):
source: aar-<date>$VAULT_DIR/projects/<project-or-topic>-aar-YYYY-MM-DD.md (or $VAULT_DIR/daily/YYYY-MM-DD-aar-<topic>.md if no clear project). If $VAULT_DIR is unset, save to ./aar-YYYY-MM-DD.md.$OPEN_ITEMS_JSON) with source: aar-YYYY-MM-DD. Never add them without asking — AARs sometimes produce speculative items that shouldn't queue immediately.This skill assumes an orchestrated agent system. Set these env vars (or inline the paths at invocation time):
| Variable | Purpose | Example |
|---|---|---|
$ORCHESTRATOR_DB | SQLite DB holding mission/task state | ~/projects/your-orchestrator/store/tasks.db |
$OPEN_ITEMS_JSON | Optional queue file for action-item append | ~/projects/your-queue/open_items.json |
$VAULT_DIR | Where AAR markdown gets saved | ~/vault |
The feedback-memory write step (Phase 5 step 2) assumes you maintain a feedback_*.md memory convention. If you don't, skip it and keep the lessons in the AAR doc itself.
User: "Let's AAR this dispatch run." → Ask: "Which scope — the parent task id, a time window, or this session?" → Gather forensics for that scope (all five sources above) → Classify every failed task by mode → Capture benchmarks (don't skip even if numbers feel obvious) → Write the AAR using the 8-section structure → Save to the configured vault, write feedback memories if applicable → Report: file path of the saved AAR, count of feedback memories written, count of action items (if the user asked to queue them)
Guides creation, editing, and verification of skills for AI coding agents using test-driven development with subagent scenarios. Use when authoring or debugging skills.
npx claudepluginhub m2ai-mcp-servers/claude-skills --plugin m2ai-skills-pack