/soleur:compoundfrom soleur
Coordinates parallel subagents to document recently solved problems with structured YAML frontmatter in knowledge-base/project/learnings/. Invoke after solving a problem to capture context while fresh.
Ships in soleur. 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; scripts run unread.
Cloud Mode (Devin): before pipeline work run bash "${CLAUDE_PLUGIN_ROOT}/scripts/cloud-detect.sh". If CLAUDE_PLUGIN_ROOT is unset (cloud exec shells do not export it), resolve the root by IDENTITY, never by script basename: for d in "$HOME/.local/share/devin/cli/plugins/cache" and /opt/.devin/plugins, skip unless [ -d "$d" ], then MANIFEST="$(find "$d" -path '*/.claude-plugin/plugin.json' -exec grep -l '"name"[[:space:]]*:[[:space:]]*"soleur"' {} + 2>/dev/null | head -1)", ROOT="${MANIFEST%/.claude-plugin/plugin.json}" — one resolution, two consumers: $ROOT/scripts/cloud-detect.sh and $ROOT/scripts/precommit-guard.sh. (Shape check, not authentication: a planted {"name":"soleur"} dir passes — ADR-179 A11.) local or not-local:no-devin-env proceeds normally; any other not-local:<reason> applies <plugin-root>/devin/INSTRUCTIONS.md §Cloud Mode: emit the --banner, fan out sequentially with Reviewed-Coverage: sequential-fallback disclosure (never claim an independent review ran), message_user ack before any secrets read or production mutation, and run precommit-guard.sh before any git commit — hooks do not fire in cloud.
Grok Build (plugins/soleur/lib/harness.ts invokeSkill()): Read this SKILL.md in this process and run it to completion. A one-segment soleur:<name> in this document names a SKILL — on Grok Build, Read plugins/soleur/skills/<name>/SKILL.md in this process; it is not a nested tool_use. A multi-segment id such as soleur:<domain>:<name> names an AGENT: spawn it, never Read it, and on Grok Build spawn_subagent takes the id with its colons replaced by hyphens (agentIdToGrokSubagentType). Claude Code: Skill tool for a skill (soleur:<name>), Task tool with subagent_type for an agent. Forbidden is executing a subset, not the Read.
Lifecycle handoff (standalone soleur:compound before ship): When compound runs as the pre-ship step in the implementation tail, invoke soleur:ship next — artifacts archived here are a checkpoint, not completion. Parent orchestrators (work, one-shot) own progression when active.
Coordinate multiple subagents working in parallel to document a recently solved problem.
Captures problem solutions while context is fresh, creating structured documentation in knowledge-base/project/learnings/ with YAML frontmatter for searchability and future reference. Uses parallel subagents for maximum efficiency.
Why "compound"? Each documented solution compounds your team's knowledge. The first time you solve a problem takes research. Document it, and the next occurrence takes minutes. Knowledge compounds.
Claude: Skill tool. Grok: Read this SKILL.md in this process (soleur:compound); slash names the skill.
skill: soleur:compound # Claude — document the most recent fix
skill: soleur:compound [brief context]
skill: soleur:compound --headless
soleur:compound # Grok slash (then Read this SKILL.md)
soleur:compound --headless
If $ARGUMENTS contains --headless, set HEADLESS_MODE=true. Strip --headless from $ARGUMENTS before processing remaining args.
Branch safety check (defense-in-depth): Run git branch --show-current. If the result is main or master, abort immediately with: "Error: compound cannot run on main/master. Checkout a feature branch first." This check fires in all modes (headless and interactive) as defense-in-depth alongside PreToolUse hooks -- it fires even if hooks are unavailable (e.g., in CI).
When HEADLESS_MODE=true, forward --headless to the compound-capture invocation (e.g., skill: soleur:compound-capture --headless).
Load project conventions:
# Load project conventions
if [[ -f "CLAUDE.md" ]]; then
cat CLAUDE.md
fi
Read CLAUDE.md if it exists - apply project conventions during documentation.
HARD RULE: Before writing any learning, enumerate ALL errors encountered in this session. Output a numbered list to the user. This step cannot be skipped even if the session felt clean.
Check for session-state.md: Run git branch --show-current. If on a feat-* branch, check if knowledge-base/project/specs/feat-<name>/session-state.md exists. If it does, read it and include any forwarded errors from ### Errors in the inventory. These errors occurred in preceding pipeline phases (e.g., plan+deepen subagent) whose context was compacted.
Include:
Errors forwarded from session-state.md (if present)
Skill or command not found errors (e.g., wrong plugin namespace)
Wrong file paths, directories, or branch confusion
Failed bash commands or unexpected exit codes
API errors or unexpected responses
Wrong assumptions that required backtracking
Tools or agents that returned errors
Permission denials or hook rejections
A framing INHERITED from a sibling artifact, pasted into a context whose premise you never re-checked. We already re-derive inherited numbers; inherited sentences get no such treatment, and they are the ones that read as established — because they were established, somewhere else. The shape recurs when a new entry joins an existing set (a fourth scanned directory, a third vendor row, a second host) and the justification is copied from a sibling entry: the words survive the move, the evidence does not. Gate: for every causal or universal claim the diff's prose ADDS, name the command that would falsify it and run it. Why: #7310 — the PR extending the ADR-166 lint (which forbids naming a cause the job did not measure) wrote "operator-facing shell gates that no lint read" into that lint's own header, reusing ADR-166's true-of-.github/actions/ framing for a directory lint-trap-tempfile-ownership.py walks in full; and asserted a message "spent a production-recovery window" when the issue predated it by six hours. Both refuted in ~15s by gh pr view --json mergedAt and one grep. See knowledge-base/project/learnings/2026-08-06-i-shipped-two-unmeasured-causal-claims-inside-the-lint-that-forbids-them.md.
Blanket search-replace sweeps (ADR renumbers, identifier renames) that rewrote files outside your own diff — scope every sweep to git diff --name-only origin/main...HEAD and assert the SENTENCE, because a residual-zero count (grep -c '<old>' == 0) is structurally blind to a new string written where it does not belong, including inside the very note explaining the rename. Why: #7162 — a sed guarded by a negative lookahead on the sibling ADR's filename rewrote 10 files of other work's bare ADR-159 citations, and an earlier sweep turned "ADR-155 was claimed by a sibling plan" into a false sentence that the count read as green. Ordinals collided three times on one branch, each surfaced by a fetch or rebase and never by a gate — treat a branch-picked ordinal as provisional and re-check against freshly-fetched origin/main immediately before merge. See knowledge-base/project/learnings/workflow-issues/2026-08-03-blanket-renumber-rewrote-other-work-and-a-count-certified-it.md.
A CORRECTION sweep keyed on the claim's PHRASING rather than its SUBJECT. The sibling bullets above cover sweeps that rewrite too MUCH; this is the inverse — a remediation that rewrites too LITTLE, and whose residual-zero count certifies the miss. Grep the noun the claim is ABOUT (the resource, the anchor comment, the count's referent), read every hit, and decide each one; then replace with derived-set language so the site cannot go stale again. A residual-zero count is evidence about a string, never about a claim. Why: #7539 — having measured a fabricated "six lines beneath" as an actual gap of 138 lines, the sweep for beneath came back clean while tasks.md:51 said "six lines BELOW". Indexing by remembered wording is the same defect one level up from the fabrication it was correcting. See knowledge-base/project/learnings/2026-08-17-i-corrected-a-fabricated-claim-by-grepping-its-phrasing-and-missed-a-site.md.
A sweep bounded by the DIFF'S OWN FILE LIST when the PR retires a mechanism or moves a count. The two bullets above cover sweeps keyed on the wrong string; this one is keyed on the wrong corpus. git diff --name-only structurally cannot show a twin in a file you never opened — and opening a file to fix one occurrence buys nothing for a second one in a different section of it. Grep the claim's SUBJECT repo-wide (the resource name, the count's referent), read every hit, decide each. Why: #7826 — a pass correcting the count "27 sentry_alert + 2 sentry_issue_alert" to "+ 3" fixed three carriers and left seven, TWO of them in files that same pass had just rewritten (a tripwire header eight lines above the string it fixed; a workflow header three paragraphs from ones it replaced). See knowledge-base/project/learnings/2026-09-07-my-instruments-reported-green-while-measuring-nothing.md.
A deletion round that swept the CODE and left the records. When a PR removes a mechanism, grep the deleted names across §Verification sections and ticked - [x] checkboxes first — those two surfaces assert delivery rather than intent, so a stale line there is read as a fact, and they are the least likely to be swept because the deletion did not touch the file they live in. Why: #8323 — NINE of seventeen code-quality findings were one of those two, including an ADR §Verification citing a deleted canary's "four driven arms" as evidence eleven lines above the amendment recording its deletion, and a tasks.md box ticking an AP-020 widening that git diff origin/main shows was reverted. See knowledge-base/project/learnings/2026-09-18-every-defect-was-in-my-verification-not-the-feature.md.
If genuinely no errors occurred (including no forwarded errors), output: "Session error inventory: none detected."
This list feeds directly into the Session Errors section of the learning document. Every item on this list MUST appear in the final output unless the user explicitly excludes it.
FAILURE MODE THIS PREVENTS: Compound runs in pipeline mode, the model judges the session as "clean," and silently drops errors that happened earlier in the conversation (e.g., a skill-not-found error from one-shot Step 1 gets omitted because compound focuses only on the main implementation task).
HARD RULE: Immediately after the Session Error Inventory, classify EVERY inventory item (plus any non-error friction the session hit — a flaky gate, a slow manual workaround, a surprising tool behavior) as recurring or one-off. Do not skip this even when the inventory is short. The operator should never have to ask "are there any of these we could fix now to avoid stumbling on them again?" — this step answers it by default, separating genuine recurring tech debt from one-offs.
For each item, decide:
review/SKILL.md §5; the subsystem clause is the scope-discipline overlay — a different-subsystem defect is file-tracked, never inlined here.)deferred-scope-out GitHub issue via the review/SKILL.md §5 mechanics (cost-of-filing + net-issue-flow: consolidate sibling follow-ups into one tracker; do not net-grow the backlog for trivia). A discovered defect in a DIFFERENT subsystem MUST stay its own issue and PR — never bundle it into an unrelated feature branch (scope discipline).Output a short triage table (item | recurring? | disposition) to the user before writing the learning. fix-now-inline items feed the Error-to-Workflow Feedback step below; file-tracked items file directly via the review §5 mechanics above; and any recurring item that is a missing workflow rule (not a subsystem bug) additionally feeds Constitution Promotion / Route-to-Definition. Why: a flaky blocking gate left untriaged re-flakes for every future PR in that path — surfacing the recurring-vs-one-off split by default (instead of on request) turns each session's friction into a fix rather than shelf-ware.
After the learning file is written (by compound-capture Step 6), read it back and verify:
## Session Errors section with at least as many items as the inventory.**Prevention:** line proposing how to avoid it in future sessions.This gate closes the gap where errors were enumerated in conversation but never made it into the persisted document.
After verifying session errors are in the learning, determine if any error warrants a workflow change. For each session error, ask: "Could a rule, hook, or skill instruction have prevented this?"
soleur:kb-glossary and record the settled sense in knowledge-base/project/glossary.md as a pointer to the file that defines it.This ensures session errors don't just get documented — they feed back into the rules and definitions that govern future sessions. The goal is a closed loop: error happens → gets documented → workflow changes → error cannot recur.
This command launches multiple specialized subagents IN PARALLEL to maximize efficiency:
knowledge-base/project/learnings/ for related documentationknowledge-base/project/learnings/ categoryBased on problem type detected, automatically invoke applicable agents:
soleur:engineering:review:performance-oraclesoleur:engineering:review:security-sentinelsoleur:engineering:review:data-integrity-guardiansoleur:engineering:review:kieran-rails-reviewer + soleur:engineering:review:code-simplicity-reviewerAfter all parallel subagents complete and before Constitution Promotion, scan the session for workflow deviations against hard rules. This phase runs sequentially (not as a parallel subagent) to respect the max-5 parallel subagent limit.
Close the gap between "we learned X" and "X is now enforced." The project has proven that hooks beat documentation — all existing PreToolUse hooks were added after prose rules failed. This phase detects deviations and proposes the strongest viable enforcement.
Gather rules. Read AGENTS.md and extract only ## Hard Rules and ## Workflow Gates items (Always/Never). Skip Prefer rules — they are advisory and flagging them adds noise.
Gather session evidence. Two sources:
knowledge-base/project/specs/feat-<name>/session-state.md for forwarded errors from preceding pipeline phases (pre-compaction deviations)Detect deviations. For each hard rule, check if session evidence shows a violation. Common examples:
git stash in a worktreebrowser_navigate call on a Playwright MCP registration (the plugin's mcp__plugin_soleur_playwright__* or any other mcp__<server>__ playwright server) for that task. This catches laziness in handoff text that hooks cannot detect.3.5. Ingest recent hook incidents. Read .claude/.rule-incidents.jsonl if present (gitignored single-file log written by .claude/hooks/lib/incidents.sh). Filter to events emitted since the session started (use the earliest timestamp in the session log, or the last 30 minutes if no anchor is available). Filter to event_type ∈ {deny, bypass} OR kind == "hook_self_fault", AND ignore lines where error is set — the latter are telemetry-drop sentinels (issue #3509), not deviation evidence. Treat each recent deny and bypass as evidence for the Deviation Analyst — denies confirm a hook caught a violation; bypasses signal a rule the user actively skipped. A hook_self_fault row (issue #7164, ADR-157) is the third class and is admitted explicitly because it carries event_type: "warn", which the {deny, bypass} filter excludes by construction: it records a PreToolUse hook that could not parse its own stdin and therefore ran that tool call with its guards disarmed. That is deviation evidence of the strongest kind — not a rule the user skipped, but a rule that silently did not run — so it must never be filtered out as advisory noise. Per plan ADR-1, this step does NOT mutate any learning's frontmatter — counter aggregation lives exclusively in knowledge-base/project/rule-metrics.json (written by the local compound aggregation in Phase 1.5 step 8 — ADR-091). If the file is absent or empty, note "no recent incidents" and continue.
3.6. Null-guardrail check. For each Phase 0.5 item triaged recurring that is a code or config defect a repo check (lint, typecheck, test, format) could catch; skip if none qualifies. Hard-rule deviations stay with step 4.
package.json scripts, Makefile/Justfile targets and pre-commit config (lefthook.yml, .husky/, .pre-commit-config.yaml). Then Grep the CI config and .claude/hooks/ for each name as a fixed string; read only matching files and follow one wrapper level.Rule violated: none (null guardrail), Existing enforcement: unwired: <check> or none. Never auto-apply a step-3.6 finding; under HEADLESS_MODE=true only append it to the item's ## Session Errors Prevention: line.Propose enforcement. For each detected deviation, first check if an existing PreToolUse hook already covers it by scanning .claude/hooks/*.sh comment headers. If a hook already enforces the rule, note "already hook-enforced" and skip the proposal. If no hook covers it, propose enforcement following the hierarchy:
Format output. For each deviation, produce:
### Deviation: [short description]
- **Rule violated:** [exact text from AGENTS.md or constitution.md]
- **Evidence:** [what happened in the session]
- **Existing enforcement:** [hook name if already covered, or "none"]
- **Proposed enforcement:** [hook/skill_instruction/prose_rule]
For hook proposals, include an inline draft script following .claude/hooks/ conventions:
#!/usr/bin/env bash
# PreToolUse hook: [what it blocks]
# Source rule: [AGENTS.md or constitution.md reference]
set -euo pipefail
INPUT=$(cat)
# [detection logic]
# If violation detected:
# jq -n '{ hookSpecificOutput: { permissionDecision: "deny", permissionDecisionReason: "BLOCKED: [reason]" } }'
Feed into learning document. For each detected deviation, add it to the learning file's ## Session Errors section (if not already present from Phase 0.5). Format: **[description]** — Recovery: [what fixed it] — Prevention: [proposed enforcement]. This ensures workflow violations are documented in the learning, not just proposed as hooks.
Feed into Constitution Promotion. Present each deviation and each step-3.6 finding to the user via the existing Accept/Skip/Edit gate in the Constitution Promotion section below. Accepted hook proposals should be manually copied to .claude/hooks/ after testing — never auto-install.
Rule budget count. After deviation analysis, get the always-loaded verdict from the linter, then measure the registry statistics the linter does not compute.
lint-agents-rule-budget.py is the authority and the pre-commit reject. This step does NOT restate its thresholds — it runs it and quotes the verdict. Restating the numbers here is exactly how they went stale (issue #6461: this rubric claimed a reject value the linter had not used for months, and the wrong measurement method besides). If a threshold matters, read it from the linter. Agreement across every restatement site is enforced by lint-agents-compound-sync.sh.
Emit rule-application telemetry (records that the byte-cap / why-single-line policy ran — see AGENTS.md cq-agents-md-why-single-line):
echo 'SOLEUR_RULE_APPLIED rule=cq-agents-md-why-single-line note=AGENTS.md rules cap at ~600 bytes; `**Why:**` is o'
Always-loaded verdict — run the linter and capture its exit code:
cd "$(git rev-parse --show-toplevel)" && \
python3 scripts/lint-agents-rule-budget.py \
AGENTS.md AGENTS.rules.md 2>&1
echo "linter exit=$?"
Two things about this invocation are load-bearing:
2>&1 is not cosmetic. [WARN] and [REJECT] print to stderr; only [OK] goes to stdout. The repo routinely sits in the WARN tier, where stdout is empty and the exit code is 0 — so without the redirect you capture nothing and report "no signal" when there is one.wc -c sum overstates the payload by the frontmatter size and misreports headroom in precisely the near-cap regime where the number decides whether a rule can land.Read the result off both the exit code and the output — the exit code is the source of truth for "is the commit blocked", the verdict line only reports the always-loaded tier:
| Exit | Output | Report |
|---|---|---|
| 0 | an [OK] / [WARN] verdict line | quote that line verbatim into the template's always-loaded: slot |
| non-zero | a verdict line is present ([OK] / [WARN] / [REJECT]) | the commit is blocked. Quote the verdict line and every ERROR: line. A [REJECT] B_ALWAYS>… means the payload is over budget → apply the shrink ladder below. An ERROR: rule body exceeds … alongside an [OK] verdict means the always-loaded payload is fine but one rule body is too large → the fix is trimming that one named rule, not the payload. Do not quote the [OK] alone and call it healthy — the non-zero exit means something is blocking the commit. |
| non-zero | no verdict line at all | the linter errored before emitting a verdict — a missing always-loaded file (exit 2) or malformed frontmatter (exit 1). Report always-loaded: linter errored — <first ERROR: line>; never infer a tier from silence. |
Consumer-repo degrade. This skill is distributed and also runs against repos that have no rule-budget linter. Pre-check before invoking:
| Condition | Detect | Report |
|---|---|---|
| Linter not present | [ -f scripts/lint-agents-rule-budget.py ] false | always-loaded: not measured (no rule-budget linter in this repo) |
python3 not on PATH | command -v python3 empty | always-loaded: not measured (python3 unavailable) |
Registry statistics the linter does not compute:
B_TOTAL=$(cat AGENTS.md AGENTS.rules.md 2>/dev/null | wc -c) — full registry (informational; since ADR-151 B_TOTAL == B_ALWAYS)A=$(grep -hE '^- .*\[id: ' AGENTS.rules.md 2>/dev/null | wc -l) — corpus BODIES only; an AGENTS*.md glob also matches the index (one pointer per body) and doubles the count (#7008)L=$(grep -h '^- ' AGENTS.rules.md 2>/dev/null | awk '{print length}' | sort -n | tail -1) (chars; the linter measures BYTES — it is the authority for the per-rule cap)C=$(grep -c '^- ' knowledge-base/project/constitution.md 2>/dev/null) (tracked separately; counts every bullet, NOT just rules — a ceiling, not a rule count)Output:
Rule budget:
always-loaded: <the linter's verdict line, verbatim>
registry total: B_TOTAL bytes / A rules (longest rule: L bytes)
constitution.md: C rules
Append warnings:
[WARN] — the payload is approaching the ceiling, and this is the tier where remediation still has room to work, so act on it now rather than waiting for the reject:
wg-every-session-error-must-produce-either) before adding any new rule. Already-enforced and domain-scoped insights MUST route to a skill/agent, NOT AGENTS.rules.md.git grep -l <id> first — a hit from code, infra, runbooks or ADRs is a bind site — then do the full removal plus a registry row per cq-agents-md-tier-gate (the PR #8034 shape; the checklist is in the header of migrated-rule-ids.txt), in a dedicated reviewed PR. Precedents: #8034, #8175.**Why:** lines to fit, preserve per-issue mechanism labels (the text after each #N); strip redundant prose only. Correct: **Why:** #2618 per-command-ack; #2880 non-interactive exec. Over-trimmed: **Why:** #2618; #2880. (loses the per-issue mechanism distinction downstream readers use to map a rule to its triggering incident class).rules_unused_over_8w is not retirement evidence — it counts enforcement events only, so an obeyed rule emits nothing (81/100 on 2026-09-14, #8030). (ADR-151 removed the demote-to-a-conditional-sidecar rung: there is no sidecar to demote into.)[REJECT] B_ALWAYS>… verdict means the always-loaded payload is over budget → shrink is mandatory before anything else lands; apply the same remediation ladder above, and do not attempt to add a rule first. Only Trim lands in the blocked commit; Migrate and Retire are separate reviewed PRs.ERROR: rule body exceeds … (which can appear alongside an [OK] always-loaded verdict) means one rule body is over the per-rule cap → trim that single named rule by moving its context to a learning file; the payload-shrink ladder does not address it.L > 600: "[WARNING] longest rule is L bytes — cap per-rule length at ~600 (see cq-agents-md-why-single-line) by moving context to learning files."A > 115: "[ADVISORY] rule count (A/115) — bytes-first policy per cq-agents-md-why-single-line; count is informational." C > 300: "[WARNING] constitution.md is large (C/300) — consider migrating narrow rules to skill/agent instructions."B_TOTAL is informational only — the per-turn cost is AGENTS.md, the per-session-first-turn cost is the always-loaded payload the linter reports. Since ADR-151 there are no conditional sidecars, so B_TOTAL == B_ALWAYS and every rule is a first-turn cost on every session.
Additionally, if the repo has a rule-metrics aggregator at ./scripts/rule-metrics-aggregate.sh, run it for real — compound is the authoritative local producer of knowledge-base/project/rule-metrics.json (ADR-091): it runs on the operator's machine where .claude/.rule-incidents.jsonl actually exists, so it, not a fresh-checkout CI cron, generates the metric. Nothing is staged. The aggregate is an untracked cache since #8377 / ADR-235 — committing it was self-defeating, because a file rewritten by whichever worktree last ran the aggregator conflicts with every other open branch, and the committed copy was never more than one machine's snapshot anyway. Run it for the local file and the hint, then parse summary.rules_unused_over_8w. Readers build it themselves: rule-prune.sh runs the aggregator ahead of its own read. Only the redaction-safe aggregate (rule_id + counts + a 50-char public prefix) is ever written — never the raw command_snippet log. On zero rule-carrying lines the aggregator no-ops (issue #6042), leaving the existing file untouched. Do not fail the phase if the aggregator is missing or errors, but do NOT silently swallow a crash — a stderr line tells the reader why the write/hint is absent:
if [[ -x ./scripts/rule-metrics-aggregate.sh ]]; then
OUT=knowledge-base/project/rule-metrics.json
if bash ./scripts/rule-metrics-aggregate.sh >/dev/null 2>&1; then
# NOT staged: $OUT is gitignored (ADR-235). It is a local cache read by
# scripts/rule-prune.sh, which regenerates it itself before reading.
unused=$(jq -r '.summary.rules_unused_over_8w // "unknown"' "$OUT" 2>/dev/null || echo unknown)
if [[ -n "$unused" && "$unused" != "0" && "$unused" != "unknown" ]]; then
echo "[INFO] $unused rules recorded no ENFORCEMENT event (warn/deny/bypass/applied) in 8 weeks. NOT a retirement shortlist — not retirement evidence: an obeyed rule emits nothing, so this count nominates the best-obeyed rules first. Headroom comes from editorial trims or from migrating domain-scoped rules to their enforcing skill (cq-agents-md-tier-gate; checklist in the header of scripts/migrated-rule-ids.txt)."
fi
else
# The aggregator's orphan gate exits AFTER writing (CI forensic context),
# so a failed run may have left a partial/orphan-flagged rule-metrics.json
# on disk. REMOVE it rather than reverting: `git checkout -- "$OUT"` cannot
# restore an untracked file (it exits non-zero with "did not match any
# file"), so the partial would have survived. Deleting it makes the next
# reader rebuild from scratch, which is the only correct recovery for a
# cache with no committed copy to fall back to.
rm -f "$OUT"
echo "[WARN] rule-metrics-aggregate.sh failed; removed any partial write (the aggregate is an untracked cache, so there is no committed copy to revert to), skipped the unused-rules hint." >&2
fi
fi
If step 3 finds no deviations and step 3.6 has no finding, output: "Deviation Analyst: no violations found." followed by the rule budget count from step 8, then proceed to Phase 1.6.
Run the cost-efficiency report (bare anchor — ADR-179):
bash "${CLAUDE_PLUGIN_ROOT}/skills/compound/scripts/token-efficiency-report.sh"
Prints top-3 cost table; emits te-* warn to .claude/.rule-incidents.jsonl on outliers (rolled up into knowledge-base/project/rule-metrics.json by the local compound aggregation in Phase 1.5 step 8 — ADR-091). Proposals route through Phase 1.5 step 7's gate.
wc -c AGENTS.md × 25 turns..skill-invocations.jsonl (session_id).total_tokens from .session-tokens.jsonl (R6 self-exclusion).git diff --shortstat. Skip <50.te-subagent-overshoot; payload >200k → te-skill-payload-floor; ratio >2k/line → te-agents-md-turn-cost (gated, #3497).Advisory. Only large outliers (subagent >100k OR payload >200k) warrant follow-up. Activation lag: PostToolUse hook fires on next session restart post-merge.
If knowledge-base/ directory exists, compound saves learnings there and offers constitution promotion:
A weekly cron (.github/workflows/scheduled-compound-promote.yml) consumes accumulated learnings and proposes skill or AGENTS.rules.md edits via draft PR when N=5 learnings cluster around the same root cause. Default OFF; opt in via knowledge-base/project/promotion-config.yml. See knowledge-base/engineering/operations/runbooks/compound-promote-runbook.md. Issue: #2720.
If knowledge-base/ directory exists, save the learning file to knowledge-base/project/learnings/YYYY-MM-DD-<topic>.md (using today's date). Otherwise, fall back to knowledge-base/project/learnings/<category>/<topic>.md.
Learning format for knowledge-base/project/learnings/:
# Learning: [topic]
## Problem
[What we encountered]
## Solution
[How we solved it]
## Key Insight
[The generalizable lesson]
## Tags
category: [category]
module: [module]
HARD RULE: This phase MUST run even when compound is invoked inside an automated pipeline (one-shot, ship). The model has historically rationalized skipping this as "pipeline mode optimization" -- that is a protocol violation. Constitution promotion and route-to-definition are the phases that prevent repeated mistakes across sessions. If the pipeline is time-constrained, present proposals with a 5-second timeout per item, but never skip entirely.
Headless mode: If HEADLESS_MODE=true, auto-promote using LLM judgment. Review recent learnings, determine if any warrant constitution promotion, select the domain and category using LLM judgment, generate the principle text, and check for duplicates via substring match against existing rules in constitution.md. Skip any principle that is already covered. Append non-duplicate principles and commit. Do not prompt the user. For deviation analyst proposals, auto-accept hook proposals that have clear rule-to-hook mappings and skip ambiguous ones. Never auto-accept a step-3.6 finding (none (null guardrail), unwired or none).
Interactive mode: After saving the learning, present two categories of proposals:
1. Deviation Analyst proposals (if any): If Phase 1.5 produced deviations or step-3.6 findings, present each one with Accept/Skip/Edit. For accepted hook proposals, display the draft script and instruct the user to manually copy it to .claude/hooks/ after testing. For accepted skill instruction or prose rule proposals, apply the edit to the target file.
2. Constitution promotion: Prompt the user:
Question: "Promote anything to constitution?"
If user says yes:
knowledge-base/project/learnings/)knowledge-base/project/constitution.md under the correct sectiongit commit -m "constitution: add <domain> <category> principle"If user says no: Continue to next step
HARD RULE: This phase MUST run even in automated pipelines. See constitution promotion rule above.
After constitution promotion, compound routes the captured learning to the skill, agent, or command definition that was active in the session. This feeds insights back into the instructions that directly govern behavior, preventing repeated mistakes.
AGENTS.md placement gate (mandatory). Before proposing any edit that targets AGENTS.md, classify each insight. These placement classes are distinct from rule-audit.sh's enforcement tiers (hooks/AGENTS.md/constitution/agents/skills) — they govern where a new rule lives, not the enforcement layer count.
<id> — migrated out of AGENTS.rules.md on (PR #N) (as a blockquote), register the id in migrated-rule-ids.txt, add the retired-rule-ids.txt exemption row and the DELETED ack, and delete the corpus line and its AGENTS.md pointer (the PR #8034 shape; lint-migrated-rule-ids.sh checks the placement). Never as a side edit of a compound run: record it as a migration candidate and walk the checklist in the header of migrated-rule-ids.txt in a dedicated reviewed PR.Routing mechanics:
Detect which skills, agents, or commands were invoked in this conversation. Also check session-state.md ### Components Invoked for components from preceding pipeline phases.
Route two categories of insights:
plan-sharp-edges.md — the catalogue lives in references/ since #8302, not in SKILL.md) saying "Verify relative paths by tracing each ../ step before prescribing them."Default action (interactive and headless): Apply the edit directly to the
target skill/agent/AGENTS.md file. Always use worktree-absolute paths
(<worktree-root>/plugins/soleur/skills/<skill>/SKILL.md) for Edit/Write
calls — never ../../plugins/... relatives from inside a worktree, which
escape the worktree and resolve to the bare repo root where tracked files
exist as stale synced copies. Verify after the edit with git status --short in the worktree: if the expected file is not listed as modified,
the edit landed outside the working tree and must be re-applied. Commit
with skill: route <basename> <summary>. Sanitize <basename> and
<summary> before interpolation —
BASENAME=$(basename "$TARGET" | tr -cd '[:alnum:]._-') — or pass the
message via a heredoc (git commit -m "$(cat <<EOF\nskill: route ...\nEOF\n)")
so backticks or $(...) in a learning-file-derived basename cannot
command-substitute. The edit surface is BOUNDED per file: each
affected file gets a single bullet-point append, a single Sharp Edges
entry, or a ≤3-line instruction clarification. Multi-file edits are
allowed when the insight is convergent — one rule with parallel
per-skill bullets (e.g., "when an enum-gate exists, plan must enumerate
AND review must verify"). Each file's surface still has to satisfy the
bounded-surface budget on its own. Edits that change existing bullet
semantics or modify AGENTS.md rule wording remain OUT OF SCOPE for
direct edit — file an issue instead.
File-issue exception: File a GitHub issue when the edit meets one of:
contested-design (competing valid approaches), agents-md-semantic-change
(modifies existing rule text), tier-ambiguous (insight straddles Tier 2
and Tier 3 and a reviewer's judgment is load-bearing), divergent
multi-file (two or more unrelated edits across skills that don't share
a single insight — these warrant separate scrutiny), or any single file's
edit exceeds the bounded-surface budget (>1 bullet, >1 Sharp Edges entry,
or >3 instruction lines). "Cross-skill" alone is NOT a trigger — a
convergent insight with parallel per-skill bullets applies inline.
Title: compound: route-to-definition proposal for <target-basename>.
Body: proposed edit text + target path + source learning path + ## Scope-Out Justification naming the criterion. Flags: --label deferred-scope-out --milestone "Post-MVP / Later".
Interactive confirmation for direct edits: If HEADLESS_MODE is unset, show the proposed diff and ask Accept/Skip/Edit-then-Accept before committing. In headless mode, apply directly without prompting — the bounded surface (single bullet append) is safe without per-edit approval.
See compound-capture Step 8 for the full flow.
Graceful degradation: Skips if plugins/soleur/ does not exist or no components detected in the session.
Update an existing learning:
Read the file in knowledge-base/project/learnings/, apply changes, and commit with git commit -m "learning: update <topic>".
Archive an outdated learning:
Move it to knowledge-base/project/learnings/archive/: mkdir -p knowledge-base/project/learnings/archive && git add knowledge-base/project/learnings/<category>/<file>.md && git mv knowledge-base/project/learnings/<category>/<file>.md knowledge-base/project/learnings/archive/. The git add ensures the file is tracked before git mv.Commit with git commit -m "learning: archive <topic>".
Delete a learning:
Only with user confirmation. git rm knowledge-base/project/learnings/<category>/<file>.md and commit.
Edit a rule: Read knowledge-base/project/constitution.md, find the rule, modify it, commit with git commit -m "constitution: update <domain> <category> rule".
Remove a rule: Read knowledge-base/project/constitution.md, remove the bullet point, commit with git commit -m "constitution: remove <domain> <category> rule".
On feature branches (feat-*, feat/*, fix-*, or fix/*), consolidation runs automatically after the learning is documented and before the decision menu. This ensures artifacts are always cleaned up as part of the standard compound flow, rather than relying on a manual menu choice.
The automatic consolidation:
archive-kb.sh is unreadable, then unions three axes: the slug match (globs knowledge-base/project/{brainstorms,plans}/*<slug>* and knowledge-base/project/specs/feat-<slug>/, excluding */archive/), the branch diff (branch adds/modifies there, spec files collapsing to their dir on A rows), and untracked ?? paths there (a branch diff cannot see uncommitted files — untracked spec dirs collapse; stray files in tracked dirs do not)constitution.md, component docs, and project README.mdbash "${CLAUDE_PLUGIN_ROOT}/skills/archive-kb/scripts/archive-kb.sh" to move all discovered artifacts to archive/ subdirectories via git mv with YYYYMMDD-HHMMSS timestamp prefix. Headless mode: auto-confirm archival without promptinggit revertIf no artifacts are found for the feature slug, consolidation is skipped silently. See the compound-capture skill for full implementation details.
Archival renames need no secret-scan-allow-rename label. archive-kb.sh git mvs plans/specs into their own archive/ subdirectory, so BOTH sides of the rename match the gitleaks path allowlist. rename-guard exempts allowlist -> allowlist renames by construction (laundering requires the source to be OUTSIDE the allowlist), and the exemption is per rename pair, so a genuine laundering rename in the same PR is still caught. Do not pre-apply the label to silence it — that would disarm the guard for the whole PR. Rationale: secret-scanning.md.
Do not skip this consolidation when driving compound's phases by hand. The mechanism that durably archives is archive-kb.sh (git mv + a commit); this consolidation is its automatic invoker. cleanup-merged is NOT one — ship/SKILL.md Phase 7 Step 4 explains why. A deferred archival is not stranded: ship Phase 6.45 archives after its last live read, same PR. The failure mode is specific: an agent invoking soleur:compound and then executing the phases itself gets everything except Auto-Consolidation Step E. In headless mode that step has no prompt to surface it (interactively it does ask). If you ran the phases manually, run archival explicitly (bash "${CLAUDE_PLUGIN_ROOT}/skills/archive-kb/scripts/archive-kb.sh") before handing off to soleur:ship.
archive-kb.sh MOVES artefacts and takes no signal from merge state — so it will archive the spec of a branch that is still in flight, and every reference to the live path goes stale in the same stroke. Two checks before Step E, both cheap: (1) grep the branch's plan and spec for archival-deferral language — a plan that says "archival of this spec dir must be deferred until after soleur:ship Phase 6" means Step E runs AFTER ship, not before it, because soleur:ship Phase 6 step 2.5 reads decision-challenges.md out of that very directory; (2) after the move, grep the tree for the live spec path and repoint every hit. A script whose whole job is to relocate a file is the one place a reference sweep is mandatory. The rename is staged, so the recovery is git mv back — the index needs no re-run, being regenerated on read since ADR-235 — but only if you notice. Why: #7490 — Step E archived the in-flight spec of the PR whose own subject was a probe broken by an archive move, orphaning four references in that PR's plan, against the plan's explicit line forbidding exactly this ordering. See knowledge-base/project/learnings/2026-09-18-every-instrument-i-built-to-check-the-guards-needed-checking.md.
Verify rather than assume when it reports "No artifacts found" — the slug axis alone misses topic-named plans and non-feat-* spec dirs; the branch-diff axis now covers both, so silence after the union means genuinely absent or a path outside the three roots. If artifacts are visibly live anyway, archive by hand with git mv.
Headless mode: If HEADLESS_MODE=true, skip worktree cleanup entirely (cleanup-merged handles this post-merge).
Interactive mode: At the end, if on a feature branch:
Question: "Feature complete? Clean up worktree?"
If user says yes:
git worktree remove .worktrees/feat-<name>
If user says no: Done
Organized documentation:
knowledge-base/project/learnings/[category]/[filename].mdCategories auto-detected from problem:
✓ Parallel documentation generation complete
Primary Subagent Results:
✓ Context Analyzer: Identified performance_issue in brief_system
✓ Solution Extractor: Extracted 3 code fixes
✓ Related Docs Finder: Found 2 related issues
✓ Prevention Strategist: Generated test cases
✓ Documentation Writer: Classified to performance-issues/, created complete markdown
Specialized Agent Reviews (Auto-Triggered):
✓ soleur:engineering:review:performance-oracle: Validated query optimization approach
✓ soleur:engineering:review:kieran-rails-reviewer: Code examples meet Rails standards
✓ soleur:engineering:review:code-simplicity-reviewer: Solution is appropriately minimal
✓ every-style-editor: Documentation style verified
File created:
- knowledge-base/project/learnings/performance-issues/n-plus-one-brief-generation.md
This documentation will be searchable for future reference when similar
issues occur in the Email Processing or Brief System modules.
What's next? (Headless mode: auto-selects "Continue workflow")
1. Continue workflow (recommended)
2. Add to Required Reading
3. Link related documentation
4. Update other references
5. View documentation
6. Other
This creates a compounding knowledge system:
The feedback loop:
Build → Test → Find Issue → Research → Improve → Document → Validate → Deploy
↑ ↓
└──────────────────────────────────────────────────────────────────────┘
Each unit of engineering work should make subsequent units of work easier—not harder.
<auto_invoke> <trigger_phrases> - "that worked" - "it's fixed" - "working now" - "problem solved" </trigger_phrases>
<manual_override> Use skill: soleur:compound [context] to document immediately without waiting for auto-detection. </manual_override> </auto_invoke>
compound-capture skill
Based on problem type, these agents can enhance documentation:
soleur:compound completes for deeper review/research [topic] - Deep investigation (searches knowledge-base/project/learnings/ for patterns)soleur:plan skill - Planning workflow (references documented solutions)What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub jikig-ai/soleur --plugin soleur108 skills in this plugin
/admin-ip-refreshThis skill should be used to refresh the prod SSH allowlist (Doppler ADMIN_IPS) after operator IP rotation. Detects drift, mutates Doppler with explicit ack./agent-browserThis skill should be used when automating browser interactions via Vercel's agent-browser CLI. It handles web page navigation, form filling, screenshots, and data scraping using ref-based element selection./agent-native-architectureThis skill should be used when designing agent-native applications where agents are first-class citizens: architecting autonomous agents, creating MCP tools, building apps where features are agent-driven outcomes.Other plugins' skills for the same job