workflow-retro
Post-run retrospective of the multi-agent SDD pipeline (spec-creator → implementation-planner → implementer / test-writer → architecture-reviewer / plan-verifier, plus nested researcher/Explore agents). Manually invoked after a run to produce TRUE token/tool/duration/parallelism metrics — deep mode parses session + subagent journals from disk because parent-visible usage EXCLUDES subagent tokens — plus insights with concrete optimization actions, a trend row appended to the retro ledger (default docs/retros/ledger.md), and an audit verdict. Trigger terms: workflow retro, retro, ретро, retrospective, pipeline metrics, agent token usage, cache hit, parallelism, як пройшов конвеєр.
- License 许可
- MIT
- 最近更新
- 2026-10-22
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- workflow-retro
- description
- Post-run retrospective of the multi-agent SDD pipeline (spec-creator → implementation-planner → implementer / test-writer → architecture-reviewer / plan-verifier, plus nested researcher/Explore agents). Manually invoked after a run to produce TRUE token/tool/duration/parallelism metrics — deep mode parses session + subagent journals from disk because parent-visible usage EXCLUDES subagent tokens — plus insights with concrete optimization actions, a trend row appended to the retro ledger (default docs/retros/ledger.md), and an audit verdict. Trigger terms: workflow retro, retro, ретро, retrospective, pipeline metrics, agent token usage, cache hit, parallelism, як пройшов конвеєр.
02 资源文件 1
- 脚本scripts/retro_metrics.py13.8 KB
03 SKILL.md 正文
Workflow Retro
Retrospective of how a multi-agent pipeline run ACTUALLY went: metrics → insights → concrete actions → trend ledger → audit verdict. Manual invocation only (no hook).
Output locations are default conventions the caller may override: reports and the
ledger go to docs/retros/ unless the invocation names another retro directory.
Modes
- deep (default) — parse journals from disk with the bundled script. This is the only
accurate source: a parent's
<usage>does NOT include its subagents' tokens, so anything measured in-context undercounts the run (often by 5–10×). - in-context (fallback) — only when journals are unavailable (other machine, cleaned up). Reconstruct what you can from the conversation and label every token figure "lower bound — excludes subagent usage". Never present in-context numbers as totals.
Step 1 — collect metrics (deep)
- Journals live in
~/.claude/projects/<slug>/where<slug>= absolute repo path with every non-alphanumeric char replaced by-. The CURRENT session id is the UUID segment of your scratchpad path. Journals live on the HOST filesystem — run the script with the host machine's Python, not from inside a container/VM shell that cannot see the host home directory. - Run (from the project root; the project journal dir auto-resolves from cwd):
python ${CLAUDE_SKILL_DIR}/scripts/retro_metrics.py --session <uuid-or-prefix>- retro of a past run →
--listfirst (newest first, shows each session's agent types), pick the session whoseagent_typesmatch the pipeline, confirm with the user if ambiguous. - omitted
--session→ latest session that has subagent journals. - Redirect stdout to a scratchpad file and read that; don't dump raw JSON into the chat.
- retro of a past run →
- The JSON gives you per journal (orchestrator + each agent): usage (input / output /
cache-read / cache-creation, deduped by
message.id),cache_hit_pct,api_turns,tool_calls_by_tool,tool_errors,skills_loaded,writes_paths, start/end/duration,parent+spawn_depth(nesting tree); plustotals,parallelism(wall-clock, Σ agent time, parallel factor, max concurrent, timeline) andduplicate_reads(same file Read by several journals — context-duplication leads).
Step 2 — analyze (qualitative)
The script gives leads; verify them by opening journals selectively (Grep/offset reads of
<project-dir>/<session>/subagents/agent-<id>.jsonl) — never read whole journals into context.
duplicate_reads→ files several agents each re-read = context-pack candidates: pre-fetch them into the spawn prompt's shared context pack instead of letting every agent re-read them.tool_errors > 0→ grep that journal foris_errorneighborhoods; classify: environment quirk / brief gap / permission wall / model flailing.- Low
cache_hit_pct(< ~60 %) on a long agent → prompt churn; consider a stable shared prefix. parallel_factor≈ 1 while plan slices were disjoint → orchestrator ran them serially; overlappingwrites_pathsbetween concurrent agents → slices were NOT disjoint.- Stop-and-ask round-trips (implementation-planner pass-1 questions) → could the caller have passed the answers (spec path, execution mode) up front?
- Big
output_tokenson a read-only agent → report bloat; tighten its output contract. - Model/effort mismatch: haiku scouting is cheap; an opus agent doing mechanical Reads is not.
Step 3 — report + ledger
- Write the full retro to
<retro dir>/<YYYY-MM-DD>-<short-slug>.md(defaultdocs/retros/):- TL;DR verdict — went well / went badly, one paragraph each.
- Metrics — table: agent | type (model) | depth→parent | in | out | cache-read | hit % | tool calls | errors | duration; then totals row, orchestrator row, and the parallelism block. Note that orchestrator numbers cover the whole session.
- Insights → actions — every insight MUST end in one concrete action:
refine an agent brief (the project's
.claude/agents/<agent>.mdor the owning plugin's agent definition), pre-fetch a shared file into the spawn-prompt context pack, merge/split agents, change concurrency, or change amodel/effort/skills:frontmatter setting. - Trend note — compare against previous ledger rows (faster/slower, cheaper/dearer, why).
- Append ONE row to the ledger (default
docs/retros/ledger.md; create it with the header below if missing — check-before-create). Tokens =totals.orchestrator_plus_agents; wall/Σ/∥ fromparallelism. - In chat: TL;DR verdict, the metrics table, top-3 actions. Reply in the user's language.
- If a NON-OBVIOUS orchestration finding was confirmed, run the
sdd-engineering:engineering-insightsskill to append it to the host project'sdocs/engineering-insights.md.
Ledger header (first line of a fresh ledger file):
# Pipeline run ledger
> One row per retro'd run; append-only. Tokens include orchestrator + ALL subagents.
| date | session | run | agents | in | out | cache-read | hit% | tools | err | wall | Σ agents | ∥max | factor | top action | report |
|------|---------|-----|--------|----|-----|------------|------|-------|-----|------|----------|------|--------|------------|--------|
Row example: | 2026-07-04 | 9e4e3df5 | spec: PDF export | 3 (spec-creator+2×Explore) | 29.1k | 67.1k | 3.40M | 88% | 115 | 3 | 8m42s | 11m39s | 3 | 1.34 | pre-fetch shared UI files | [retro](2026-07-04-spec-pdf-export.md) |
Journal schema gotchas
- A streamed assistant turn = SEVERAL jsonl lines sharing one
message.idwith CUMULATIVE usage; the script dedupes (per-field max per id). Never sum raw lines yourself. - The parent-side
AgenttoolUseResult records onlyagentId/status/resolvedModel— no token totals. Subagent journals are the only usage source. subagents/agent-<id>.meta.json={agentType, description, name?, toolUseId, spawnDepth}; nested agents (depth ≥ 2) sit FLAT in the same session'ssubagents/, parented by finding which journal contains thetool_useblock with thattoolUseId(the script does this).- Journals are UTF-8; PowerShell
Get-Contentdefault encoding mangles non-ASCII text — use the script or explicit UTF-8 reads. duration_s= first→last journal line. An agent resumed viaSendMessagekeeps ONE journal, so its duration INCLUDES the idle gap between passes (a "146m" implementer was ≈25m of work + ~2h idle) — treatsum_agent_duration_sandparallel_factoras skewed bounds whenever any agent was resumed, and say so in the report.
04 同仓库更多 Skills
sample-skill
Reviews recent changes and reports actionable findings for testing purposes
run-plan
Executes an APPROVED Development Plan through the SDD implementation pipeline: implementer wave(s) → test-writer gap pass → green barrier (tests + typecheck) → architecture-reviewer ∥ plan-verifier → bounded fix loop (max 2 iterations) → final report. HARD GATE: an existing plan file is a required input — no plan, no run. Unlike implementer (ships ONE slice) — this skill orchestrates the WHOLE plan across agents; unlike workflow-retro (measures a PAST run) — this skill performs the run; unlike a pre-publish diff review — this skill implements and verifies, it never publishes. Trigger terms: run-plan, run the plan, execute the plan, run the implementation pipeline, запусти план, запусти конвеєр, виконай план, прожени план через конвеєр.
mermaid-diagram
Create Mermaid diagrams in markdown. Use when the user wants to visualize workflows, architectures, API flows, data models, state machines, or system designs. Covers flowcharts, sequence diagrams, class diagrams, ER diagrams, state diagrams, and more.
engineering-insights
Capture durable engineering insights into the host project's insights file (default docs/engineering-insights.md), and prune that log. Use during any session when a non-obvious discovery is confirmed — a gotcha, a fix's root cause, a why-it's-like-this decision, an antipattern, or a tool/library quirk — and at session wrap-up to sweep for learnings. Also use to review, dedup, or declutter the insights file. Trigger terms: insight, learning, gotcha, engineering insights, lesson learned, wrap-up, retrospective, prune insights.
typescript-expert
TypeScript and JavaScript expert with deep knowledge of type-level programming, performance optimization, monorepo management, migration strategies, and modern tooling.
security
Application-CODE security review based on OWASP Top 10:2025, for a React + Express + MongoDB/Mongoose + JWT stack. Use when reviewing source code for vulnerabilities, implementing or auditing auth/authorization, handling untrusted input, working with file uploads, managing secrets in code, or hardening an API endpoint. Covers A01-A10 for that stack, including supply-chain risk in npm dependencies. Trigger terms: security review, is this code safe, vulnerability, OWASP, injection, XSS, IDOR, broken access control, auth bypass, mass assignment, rate limiting, JWT verification. NOT for infrastructure or network security — VPC and security-group design, firewall rules, which ports to open, public IPs, TLS termination, OS or container hardening, and cloud IAM policy are all out of scope: this skill reads application source code and has nothing to say about them.