plugins/dev/skills/compound-estimate/SKILL.md
Closing ritual for the AI-native estimation feedback loop. **ALWAYS use when** a ticket's PR has just merged (runs automatically per ticket: merge-pr step 12b / phase-monitor-merge, CTL-189/CTL-831), or when the user says 'compound-estimate', 'close the estimation loop', 'record actuals', 'compound-log', or wants to log post-merge actuals for a shipped Linear ticket. Writes a structured entry (linear.key, pr_number, merged_at, estimate_at_start, estimate_actual, cost_usd, wall_time_hours, what_worked, what_surprised_me) to `thoughts/shared/retros/estimate/YYYY-WW-compound-log.md` — one file per ISO week, appends.
npx skillsauth add coalesce-labs/catalyst compound-estimateInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Write a compound-log entry for a just-shipped ticket. This is the Phase 1 exit gate for AI-native estimation: without this closer, claude-code-otel cost/wall-time signals never feed future estimates and the calibration loop stays open.
The skill delegates all mechanical work to plugins/dev/scripts/compound-log.sh. Your job is to collect the three human-authored inputs (estimate_actual, what_worked, what_surprised_me) and invoke the helper.
/compound-estimate <TICKET-ID>
Inputs:
<TICKET-ID> — required. Linear ticket key (e.g. CTL-159). If omitted, detect from the current branch name (gh pr view --json headRefName → parse ticket prefix).Appends an entry to thoughts/shared/retros/estimate/YYYY-WW-compound-log.md, creating the weekly file with a header if it doesn't exist. Weeks are ISO-8601 and derived from the PR's mergedAt (not today's date).
If the user passed a ticket ID, use it. Otherwise:
BRANCH=$(git branch --show-current)
# Extract ticket prefix from .catalyst/config.json
TICKET_PREFIX=$(jq -r '.catalyst.project.ticketPrefix // "PROJ"' .catalyst/config.json)
TICKET_ID=$(echo "$BRANCH" | grep -oE "${TICKET_PREFIX}-[0-9]+" | head -1)
If no ticket can be resolved, ask the user explicitly. Do not guess.
The helper will fail loud if mergedAt is missing, but give the user a clearer error up front:
PR_JSON=$(gh pr view --json number,state,mergedAt 2>/dev/null)
STATE=$(echo "$PR_JSON" | jq -r '.state')
if [ "$STATE" != "MERGED" ]; then
echo "error: PR on current branch is not merged (state=$STATE). Run /compound-estimate after the PR merges."
exit 1
fi
Prompt the user interactively (one at a time). Keep the prompts short and concrete; the estimate re-scoring is the calibration signal, so do not skip it.
phase-triage writes to Issue.estimate). Ask: "After shipping, what T-shirt would you set this ticket to? (XS/S/M/L/XL or integer 1/3/5/8/13)". Off-scale integers are accepted by the helper but the corpus-refresh override ignores them — stick to the scale.If the user answers with a T-shirt letter, convert to the integer before passing to the helper.
plugins/dev/scripts/compound-log.sh write "$TICKET_ID" \
--estimate-actual "$EST_ACTUAL_INT" \
--what-worked "$WHAT_WORKED" \
--what-surprised-me "$WHAT_SURPRISED"
The helper resolves the rest:
pr_number, merged_at, created_at via gh pr viewestimate_at_start via linearis issues read <ticket> | jq .estimatecost_usd from catalyst-state.sh worker aggregate (orchestrator mode) or catalyst-session.sh history --ticket (local fallback)wall_time_hours computed from PR createdAt → mergedAtOn success, the helper prints the target file and a one-line summary. Show that to the user.
After a successful write, check whether the committed reference-class corpus is stale and offer to refresh it. Best-effort: a refresh failure never fails the ritual.
CORPUS="plugins/pm/scripts/estimate/reference-class-corpus.json"
STALE=$(jq -r '
(.generated_at // "1970-01-01T00:00:00Z")
| sub("\\.[0-9]+"; "")
| (try fromdateiso8601 catch 0)
| (now - .) > 604800
' "$CORPUS" 2>/dev/null || echo "false")
If STALE is true (corpus older than 7 days), tell the user and offer to run the refresh:
plugins/pm/scripts/estimate/refresh-corpus.sh
It re-runs Extract → Collect → Score and merges fresh entries over the committed corpus (your
just-written estimate_actual flows in as the human ground-truth override). The refresh leaves the
corpus change in the working tree — show the user the summary line and let them commit/PR it (or
re-run with --commit). If the user declines or the refresh fails, log and move on.
On failure, surface the helper's error verbatim. The helper fails loud with actionable messages — don't paraphrase them. Common causes and fixes:
| Error fragment | Meaning | Fix |
|---|---|---|
| required: --estimate-actual | You did not collect the re-score | Re-prompt the user |
| PR #N has no mergedAt | PR isn't merged yet | Run after merge |
| could not resolve estimate via linearis | Linear unreachable or ticket has no estimate | Pass --estimate-start <int> |
| no cost data for <ticket> in catalyst-state or session history | No cost telemetry captured for this ticket | Pass --cost-usd <float> explicitly |
| already exists in ...; pass --force to replace | Skill was run twice for same (ticket, pr) | Either skip, or re-run with --force |
plugins/dev/scripts/compound-log.sh write <ticket> [options]
--pr <number> PR number (default: gh pr view on current branch)
--merged-at <iso-ts> override (default: gh pr view mergedAt)
--created-at <iso-ts> override (default: gh pr view createdAt)
--estimate-start <int> override (default: linearis .estimate)
--estimate-actual <int> REQUIRED — post-merge re-score on same scale
--cost-usd <float> override (default: catalyst-state/session aggregate)
--wall-time-hours <float> override (default: computed from PR timestamps)
--what-worked <text> REQUIRED
--what-surprised-me <text> REQUIRED
--thoughts-dir <path> override thoughts root (default: ./thoughts)
--force replace existing (ticket, pr) entry
--dry-run print entry; write nothing
Each entry is a level-3 heading with a fenced YAML block. Machine consumers (CTL-813): read them
back with plugins/dev/scripts/compound-log.sh read (JSON Lines) or … aggregate (per-ticket
latest + calibration stats) — refresh-corpus.sh joins estimate_actual into the reference-class
corpus as the human ground-truth override.
### CTL-159 — #273 — 2026-04-24T18:32:10Z
```yaml
linear_key: CTL-159
pr_number: 273
merged_at: 2026-04-24T18:32:10Z
estimate_at_start: 3 # CTL-746 scale: 3 → S
estimate_actual: 5 # CTL-746 scale: 5 → M
cost_usd: 2.47
wall_time_hours: 3.2
what_worked: "Tests-first TDD kept the helper script testable."
what_surprised_me: "Prometheus integration wasn't plumbed; local state.json sufficed."
## Data source notes
- **Primary cost source** is local: the `catalyst-state.sh` worker-usage aggregate (when orchestrated) or `catalyst-session.sh history` (standalone). This is deliberate — `claude-code-otel` + Prometheus is referenced in the original spec but not yet wired up in this repo.
- **Prometheus overlay** is gated by `CATALYST_PROMETHEUS_URL`. When set, the helper logs a note to stderr; the HTTP client itself is a follow-up ticket.
- **Linear estimate** is read as an integer from `linearis issues read`. The team's estimation config (T-shirt, Fibonacci, linear) is applied client-side when re-scoring in step 3.
## Testing
```bash
bash plugins/dev/scripts/__tests__/compound-log.test.sh
Covers ISO-week derivation, happy-path writes, append-idempotence, dedup + --force, fail-loud paths for each required field, wall-time computation, and mergedAt-based week routing.
thoughts/shared/research/2026-04-24-CTL-159-compound-closing-ritual.mdthoughts/shared/plans/2026-04-24-CTL-159-compound-closing-ritual.mdmerge-pr step 12b; autonomously
(agent-authored re-score) from phase-monitor-merge after the merge landscompound-log.sh read/aggregate → refresh-corpus.sh feeds
estimate_actual into reference-class-corpus.json; /catalyst-dev:ticket-retro reads the
weekly files for the estimation-calibration summarytesting
Phase-agent that fixes a failing verify verdict so the pipeline self-heals instead of stalling to needs-human (CTL-653). Reads `${ORCH_DIR}/workers/<ticket>/verify.json`, fixes the `findings[]` (every severity:"high" plus the regression_risk drivers) directly via Edit/Write, commits the remediation, and emits `phase.remediate.complete.<ticket>`. The scheduler's router then re-dispatches `verify` to re-check (the verify⇄remediate cycle, cap 3). Dispatched as a `claude --bg` job by `phase-agent-dispatch`, which invokes it via slash command — hence `user-invocable: true`.
tools
--- name: phase-triage description: Phase agent that triages a Linear ticket — expands acronyms, classifies (feature/bug/docs/refactor/chore), identifies genuine blockers (a semantic second-pass over the backlog — NOT a prose scrape; CTL-838), estimates scope, writes triage.json, and posts a triage analysis comment to Linear. Triage completion is signaled by that comment plus the local triage.json — there is no `triaged` label. Emits phase.triage.complete.<TICKET> on success and phase.triage.fai
tools
Phase agent for the research step of the 9-phase orchestrator pipeline (CTL-450). Wraps /catalyst-dev:research-codebase and produces thoughts/shared/research/<date>-<ticket>.md, then emits phase.research.complete.<ticket>. Reads triage.json from the worker dir as its prior-phase artifact. Spawned via plugins/dev/scripts/phase-agent-dispatch, which invokes it via slash command — hence `user-invocable: true`.
development
Phase-agent wrapper that opens the pull request after implementation completes (CTL-449 Initiative 1 Phase 3). Delegates to `/catalyst-dev:create-pr` (which already auto-runs `describe-pr` and transitions Linear to `inReview`), then writes the PR number + URL into the phase signal file so the downstream `phase-monitor-merge` agent can read it without re-querying GitHub. Dispatched as a `claude --bg` job by `phase-agent-dispatch`, which invokes it via slash command — hence `user-invocable: true`.