/wr-retrospective:analyze-contextfrom wr-retrospective
Performs deep context-usage analysis with per-turn attribution, per-plugin decomposition, suggestion generation, and policy-breach detection. Produces a markdown report for delta comparison. Auto-fires from run-retro Step 2c or user-invokable on demand.
Ships in wr-retrospective. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
On-demand deep analysis of session context-usage — per-turn attribution, per-plugin decomposition, suggestion generation. Produces a committed markdown report at docs/retros/<date>-context-analysis.md whose HTML-comment trailer is the snapshot subsequent runs of run-retro Step 2c (cheap layer) compare against.
This skill is the deep layer of the two-layer design in ADR-043 (Progressive context-usage measurement and reporting for retrospective sessions; P101). The cheap layer lives in packages/retrospective/skills/run-retro/SKILL.md Step 2c and runs every retro at < 5% session budget. This skill runs only on explicit user direction.
/wr-retrospective:analyze-context directly.docs/retros/<TODAY>-context-analysis.md exists). Per ADR-043 Amendment 2026-06-08 (P295 settlement) + Amendment 2026-06-17 (P372 absolute-floor gate on the delta axis).Auto-fires from run-retro Step 2c, silent in interactive and AFK modes. Per ADR-043 Amendment 2026-06-08 + ADR-044 framework-resolution boundary, this skill auto-fires from the cheap layer when the combined trigger condition holds (calendar-elapse OR a delta breach clearing both the 20% and the 10 KB absolute floor, capped at once per day). The skill never invokes AskUserQuestion — it writes a committed docs/retros/<TODAY>-context-analysis.md report and exits. AFK orchestrators read the resulting report on iteration close; the user reviews on return.
Per ADR-026 (Agent output grounding), this skill's prose, suggestions, and findings MUST cite specific surfaces, MUST persist evidence in re-readable form, and MUST mark ungrounded fields with explicit sentinels. Forbidden phrases (Banned per ADR-026 Confirmation line 148): load is negligible, microseconds only, minimal, small change, trim X to reduce bloat (without a comparable prior). Every top-N offender row and every trim suggestion MUST carry a concrete byte count + measurement-method citation. Comparable-prior reclamation suggestions (e.g. P095 reclaimed ~120KB by once-per-session gating) cite the specific prior; when no prior exists, emit not estimated — no prior data per ADR-026 line 90.
When referencing problem IDs, ADR IDs, or JTBD IDs in prose output, include the human-readable title on first mention. Format P101 (wr-retrospective has no context-usage analysis) rather than bare P101.
The deep layer reuses the cheap layer's measurement script as its byte-count baseline. Verify the primitive is available:
test -x packages/retrospective/scripts/measure-context-budget.sh
If the script is missing or not executable, halt with a directive: "measure-context-budget.sh is the cheap-layer measurement primitive (P101 / ADR-043). Verify the wr-retrospective plugin is installed and up to date before running the deep analyzer."
Invoke the script to capture the canonical per-source-bucket byte totals. Identical contract to run-retro Step 2c:
wr-retrospective-measure-context-budget "${CLAUDE_PROJECT_DIR:-.}"
The wr-retrospective-measure-context-budget command is a $PATH-resolved shim shipped in packages/retrospective/bin/ that dispatches the canonical packages/retrospective/scripts/measure-context-budget.sh body. ADR-049 — never invoke the canonical script via repo-relative path; the path does not resolve in adopter trees.
The output is the deep layer's baseline. Parse each BUCKET <name> bytes=<N> row into a structured map; preserve BUCKET <name> not-measured reason=<reason> rows verbatim — the sentinels carry into the report unchanged.
The cheap layer reports hooks and skills as aggregates. The deep layer decomposes each by plugin, citing concrete byte counts per plugin:
wr-retrospective-list-plugin-attribution "${CLAUDE_PROJECT_DIR:-.}"
The wr-retrospective-list-plugin-attribution command is a $PATH-resolved shim shipped in packages/retrospective/bin/ that dispatches the canonical packages/retrospective/scripts/list-plugin-attribution.sh body. ADR-049 — never invoke the canonical script via repo-relative path; the path does not resolve in adopter trees. Equivalent contract to ADR-049's wr-retrospective-measure-context-budget shim.
Output rows (one per plugin, terse machine-readable per ADR-038 ≤150 bytes):
PLUGIN-HOOKS <plugin> bytes=<N>
PLUGIN-SKILLS <plugin> bytes=<N>
PLUGIN-ATTRIBUTION not-measured reason=<reason>
Resolution order (handled by the helper, transparent to this skill):
packages/<plugin>/{hooks,skills} directly.packages/ under ${CLAUDE_PROJECT_DIR}), the helper sniffs $PATH for plugin-cache bin/ entries (*/cache/<owner>/<plugin>/<version>/bin) and back-walks each plugin's root for hooks + skills byte counts.PLUGIN-ATTRIBUTION not-measured reason=no-plugin-source-resolvable sentinel per ADR-026. Treat as ungrounded; do NOT fabricate per-plugin numbers when this row appears.Per-row contract: each PLUGIN-HOOKS / PLUGIN-SKILLS row carries a concrete byte count from the helper's find ... -name '*.sh' / SKILL.md + wc -c measurement chain. The aggregate cheap-layer hooks row equals the sum of all PLUGIN-HOOKS rows (sanity-check the report); skills row equals the sum of all PLUGIN-SKILLS rows.
P153 / ADR-049 — do NOT re-introduce repo-relative packages/*/hooks (or skills / scripts / bin) directory-enumeration glob loops in SKILL.md prose; route every plugin walk through wr-retrospective-list-plugin-attribution (or an equivalent bin-shimmed helper). The grep-as-lint at packages/shared/test/no-repo-relative-script-paths-in-skills.bats fails CI on regression.
When ${CLAUDE_PROJECT_DIR}/.afk-run-state/*.jsonl exists (AFK orchestrator session) OR the user supplies an explicit session-log path, parse the per-turn usage field per ADR-043's deep-layer methodology:
log_paths=( "${CLAUDE_PROJECT_DIR:-.}"/.afk-run-state/*.jsonl )
shopt -s nullglob
log_paths=( "${log_paths[@]}" )
shopt -u nullglob
For each log file:
usage.{input,output,cache_creation,cache_read}_tokens per turn.packages/itil/skills/manage-problem/SKILL.md attributes to skills/itil).per-turn attribution: not measured — no session log accessible per ADR-026.For each non-trivial bucket (top-5 by byte count), generate a trim-candidate suggestion citing:
packages/itil/skills/manage-problem/SKILL.md).P095 reclaimed ~120KB by once-per-session gating; P099 promoted Tier 3 to advisory enforcement; P100 split BRIEFING.md into per-topic files). When no comparable prior exists, emit not estimated — no prior data per ADR-026 line 90.Forbidden suggestion shapes (ADR-026 Confirmation line 148): bare trim X without a citation; consider reducing without a target byte count; optimise this skill without a comparable prior. Every suggestion is auditable end-to-end or it is not emitted.
For surfaces with explicit budgets, check for breach:
UserPromptSubmit hook's terse-reminder branch. Emit a BREACH row per offending hook with citation.wr-retrospective-check-briefing-budgets (ADR-049 PATH shim → packages/retrospective/scripts/check-briefing-budgets.sh) and surface any OVER rows verbatim in the deep report.SKILL.md exceeds 50KB, emit a BREACH row citing the file path + byte count + the P097 ticket as the evolving budget anchor.When a breach is detected, the report includes a ## Policy Breaches section. Each breach cites the specific budget rule + the offending file path + a concrete byte count.
Write the deep-layer report to docs/retros/<TODAY>-context-analysis.md where <TODAY> is the current ISO date.
If docs/retros/ does not exist, create it (mkdir -p docs/retros). If docs/retros/README.md does not exist, scaffold a minimal one-line index pointing at the report directory shape:
# Retro Reports
Per-date context-analysis reports produced by the wr-retrospective deep layer (`/wr-retrospective:analyze-context`). Each report carries an HTML-comment snapshot trailer; see ADR-043 for the schema.
Report shape:
# Context Analysis — YYYY-MM-DD
> Source: `/wr-retrospective:analyze-context` (deep layer per ADR-043).
> Methodology: byte-count-on-disk + per-plugin decomposition + per-turn attribution (when session log available).
> Cheap-layer baseline: `packages/retrospective/scripts/measure-context-budget.sh`.
## Bucket Totals
| Bucket | Bytes | % of measured | Δ vs prior |
|--------|-------|---------------|------------|
| ... | ... | ... | ... |
(Bucket rows ordered by byte count descending. `not-measured` buckets ride a separate row with the reason sentinel.)
## Per-Plugin Decomposition
### Hooks (aggregate from cheap layer: <N> bytes)
| Plugin | Bytes | % of hooks |
|--------|-------|------------|
| ... | ... | ... |
### Skills (aggregate from cheap layer: <N> bytes)
| Plugin | Bytes | % of skills |
|--------|-------|-------------|
| ... | ... | ... |
## Top-N Offenders
| Surface | Bytes | Bucket | Comparable prior |
|---------|-------|--------|------------------|
| ... | ... | ... | ... |
## Per-Turn Attribution
(Populated only when a session log is accessible; otherwise: `per-turn attribution: not measured — no session log accessible`.)
| Turn | Input tokens | Output tokens | Cache creation | Cache read | Notes |
|------|--------------|---------------|----------------|------------|-------|
| ... | ... | ... | ... | ... | ... |
## Suggestions
(Per ADR-026 — each suggestion cites specific surface + comparable prior + concrete byte estimate, or marks `not estimated — no prior data`.)
1. **[Bucket / Surface]** — Suggestion text. Comparable prior: `P<NNN> reclaimed ~<N>KB by <approach>`. Estimated byte saving: `~<N>KB` / `not estimated — no prior data`.
## Policy Breaches
(Populated only when a breach is detected per Step 5; otherwise: `no policy breaches detected`.)
| Budget | Offender | Bytes | Citation |
|--------|----------|-------|----------|
| ... | ... | ... | ... |
<!--
context-snapshot:
total-bytes: <N>
hooks: <N>
skills: <N>
memory: <N>
briefing: <N>
decisions: <N>
problems: <N>
jtbd: <N>
project-claude-md: <N>
framework-injected: not measured
measurement-method: byte-count-on-disk
measured-at: <ISO timestamp>
-->
The HTML-comment trailer is the snapshot subsequent retros (run-retro Step 2c) read for delta-from-prior comparison. Schema mirrors ADR-040's per-entry signal-score block.
Stage and commit per the ADR-014 commit-message convention added by ADR-043:
git add docs/retros/<TODAY>-context-analysis.md plus, if newly created, docs/retros/README.md.wr-risk-scorer:pipeline subagent-type via the Agent tool./wr-risk-scorer:assess-release via the Skill tool. Per ADR-015 it wraps the same pipeline subagent and produces an equivalent bypass marker.git commit -m "docs(retros): context analysis YYYY-MM-DD" per ADR-014's amended Commit Message Convention table.If risk is above appetite per ADR-013 Rule 5 + ADR-042: do NOT commit; report the uncommitted state and let the user resolve. Do NOT call AskUserQuestion as a shortcut out of the auto-apply loop.
After the commit lands, report:
/wr-retrospective:run-retro invocations will read this report's HTML-comment trailer for delta comparison."This skill is auto-invoked from run-retro Step 2c when the combined trigger holds (calendar-elapse >14 days OR delta >20% any bucket, once-per-day guard) per ADR-043 Amendment 2026-06-08 (P295 settlement). The skill is silent (never invokes AskUserQuestion) and produces a committed docs/retros/<TODAY>-context-analysis.md report; identical behaviour in interactive and AFK modes per ADR-044 framework-resolution boundary — auto-invocation is framework-resolved mechanical action, not a user-decided surface.
If invoked in a non-interactive context AND the commit gate flags above-appetite risk: skip the commit, report the uncommitted report path clearly, and let the user resolve on return. The report file itself is still written — it is the evidence the user reviews.
Read
REFERENCE.md§Composition with sibling measurementsfor sibling-skill cross-references (run-retro Step 2c bidirectional contract, P099 briefing-budgets co-citation, P105 signal-vs-noise composition, ADR-040 tier-budget composition).Read
REFERENCE.md§ADRs citedfor the full source-decision provenance index when investigating a behavioural change against this skill's design lineage.
$ARGUMENTS
What SKILL.md sets; muted values are Claude Code's defaults
3 skills in this plugin
/migrate-briefingwr-retrospective:migrate-briefingMigrate a legacy single-file `docs/BRIEFING.md` into the per-topic `docs/briefing/` tree expected by the `wr-retrospective:run-retro` Tier-3 rotation and the SessionStart briefing surface. Idempotent and foreground-synchronous — silently no-ops when the tree is already in place or when no legacy file is present. Implements the migration path P204 left manual./run-retrowr-retrospective:run-retroRun a session retrospective. Updates docs/BRIEFING.md with learnings and creates problem tickets for failures and friction.Other plugins' skills for the same job
npx claudepluginhub windyroad/agent-plugins --plugin wr-retrospective