skills/learn/SKILL.md
Knowledge compiler. Extracts patterns, decisions, and anti-patterns from completed campaigns and evolve cycles, then compiles them into structured wiki pages that integrate with existing knowledge rather than appending isolated files. Implements flush→compile→lint pipeline. Auto-triggered by /postmortem and /evolve Phase 6.
npx skillsauth add SethGammon/Citadel learnInstall 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.
Use when: You have a completed campaign or evolve cycle and want to compile its findings into the project's growing knowledge wiki — so future sessions start smarter, not from scratch.
Don't use when: You want a structured incident analysis first (use /postmortem
— run it before /learn); you haven't finished any campaigns (nothing to compile);
you want a context transfer only (use /session-handoff).
Key difference from appending: /learn doesn't create isolated per-campaign
files. It integrates new findings into existing wiki pages — updating evidence
lists, raising confidence where a pattern is confirmed again, and flagging
contradictions. A wiki is a compiler; a log is an interpreter.
/learn — most recently completed campaign
/learn {slug} — specific campaign by slug
/learn {file-path} — specific campaign file path
/learn --from-evolve {target} — compile from /evolve pattern library
/learn --from-evolve {target} --cycle {n} — specific evolve cycle only
/learn --lint — lint-only pass (no new extraction)
/learn --compile — re-compile staging area into wiki (no new extraction)
/learn --memory — compile semantic memory blocks from planning artifacts
/learn --doc-sync — process doc-sync queue into .planning/doc-sync/latest.md
.planning/postmortems/ (optional).planning/telemetry/audit.jsonl filtered to this campaign (optional)--from-evolve: .planning/evolve/{target}/pattern-library.mdIf /learn (no argument):
.planning/campaigns/completed/*.md or .planning/campaigns/*.md
where Status: completedIf /learn {slug}:
.planning/campaigns/ for a file whose name contains {slug}.planning/campaigns/completed/ if not found in activeIf /learn --from-evolve {target}:
.planning/evolve/{target}/pattern-library.md — this is the source--cycle {n}: filter to sections beginning with ## Cycle {n} onlyIf /learn --doc-sync: Run:
node hooks_src/doc-sync.js
Then review .planning/doc-sync/latest.md. Stop after reporting the queue count,
files surfaced, skipped deleted files, and report path. Do not run campaign
extraction unless the user separately asks for it.
If /learn --lint, /learn --compile, or /learn --memory: Skip to Step 4, 5, or 5.5 respectively.
For campaign-based runs only (skip for --from-evolve):
Campaign file (required):
Postmortem (optional):
.planning/postmortems/ for files matching *{slug}*Audit telemetry (optional):
.planning/telemetry/audit.jsonlExtract raw findings and write to staging.
For campaign sources:
Extract four categories:
A. Successful Patterns — approaches that demonstrably worked (phases completed without rework, postmortem positives, no reverts).
Per pattern: name, mechanism (what caused success), evidence (phase/commit/entry), topic (infer from subject matter), applicability.
B. Anti-patterns — what was tried and failed (rework phases, circuit breaker trips, quality gate blocks, reverts).
Per pattern: name, what-was-tried, failure-mode, evidence, topic, avoidance.
C. Key Decisions — from Decision Log or inferred from phase descriptions.
Per decision: what, rationale, outcome (completed or rework).
D. Quality Rule Candidates — only generate if: specific regex, applies to a specific file pattern, occurred more than once or was severe. Per candidate: regex, file pattern, trigger message, confidence (high/medium/low — skip low).
For evolve sources:
Parse the pattern library's sections. For each pattern record:
name: section headingmechanism: "Mechanism:" fielddelta: "Delta:" fieldtopic: infer from "Axis class:" (e.g., orientation_precision → skill-orientation)applies-to: "Applies to:" fieldconfidence: "Confidence:" fieldevidence: source file + cycle numberStaging write:
Create .planning/wiki/_staging/ if it does not exist.
Write staged findings to .planning/wiki/_staging/{source-slug}-{timestamp}.jsonl —
one JSON record per finding (newline-delimited).
If zero findings are extractable: write staging file with a single {"type":"empty","source":"{slug}"} record and note "Campaign may have been too brief."
Integrate staged findings into wiki pages.
Create .planning/wiki/ if it does not exist.
For each staged finding:
.planning/wiki/{topic}.md where topic is the finding's topic field (normalized to kebab-case).## {name}):
**Evidence:** list**Last confirmed:** to today**Conflict:** field — do not silently overwriteWiki page format:
---
topic: {slug}
last-compiled: {ISO date}
sources: {N}
---
# {Topic Title}
## {Pattern Name}
**Mechanism:** {what causes success/failure}
**Evidence:** {source-1 (date)}, {source-2 (date)}, ...
**Confidence:** high/medium/low
**Last confirmed:** {ISO date}
**Applies to:** {scope}
After compiling all findings: update .planning/wiki/index.md —
one line per wiki page: - [{topic}]({topic}.md) — {one-line description}.
Create index.md if it does not exist.
Scan all .planning/wiki/*.md pages (skip index.md).
Contradiction check: For each page, if two sections contain opposing directives
("always X" vs "never X", "prefer X" vs "avoid X"), flag as:
CONFLICT: [{page}] {section-A} contradicts {section-B} — requires human resolution
Staleness check: Sections with **Last confirmed:** older than 60 days are flagged as:
STALE: [{page}] {section} — last confirmed {date}, consider re-testing
Coverage check: Warn if a wiki page has fewer than 2 sections — single-entry pages are fragile.
Lint results are reported in the summary. Lint does not modify wiki pages.
Run a safe deterministic memory compile pass:
node scripts/memory-compile.js compile
This writes compact semantic blocks to .planning/memory/blocks/ and updates
.planning/memory/index.json. Blocks must include id, type, scope,
owner, confidence, last_verified, sources, and body.
For lint-only memory checks, run:
node scripts/memory-compile.js lint
For agent context loading, use scoped listing instead of rereading full histories:
node scripts/memory-compile.js list --scope verification
node scripts/memory-compile.js list --query "Fleet readiness"
Memory block lint must pass before calling the compile successful. Missing source paths, stale blocks, missing required block types, and contradictions are reported as actionable failures.
For each high/medium-confidence rule candidate in the staged findings:
.claude/harness.json (create with {} if missing)qualityRules.custom to [] if absentpattern already exists{ "name": "auto-{slug}-{N}", "pattern": "{regex}", "filePattern": "{glob}", "message": "Learned from {slug}: {message}" }Skip low-confidence rules.
=== /learn: {Source} ===
Mode: {campaign | evolve-{target} | lint-only | compile-only}
Sources: {campaign path | evolve path} | postmortem {path or "not found"} | {N} audit entries
Staged: {N} findings → .planning/wiki/_staging/{file}
Compiled: {N} patterns integrated | {M} new wiki sections | {K} existing sections updated
Wiki pages: .planning/wiki/{topic-1}.md, ...
Lint: {conflicts found | clean} | {stale entries} | {coverage warnings}
Memory blocks: {N} compiled | lint {PASS|FAIL} | .planning/memory/index.json
Rules added to harness.json: {M} ({K} skipped — already exist)
Next: review .planning/wiki/index.md — promote stable patterns to CLAUDE.md for permanent enforcement.
No completed campaigns: Output message and stop.
.planning/ does not exist: Output "Run /do setup first to initialize the harness state directory." Stop.
No Decision Log: Extract decisions from phase descriptions; note "inferred from phase descriptions."
harness.json missing: Create with only the qualityRules section; do not invent other fields.
Duplicate quality rule: Skip silently; count in "skipped — already exist."
Postmortem missing: Proceed without it; note in summary.
Large telemetry file: Read last 200 lines only.
Zero extractable findings: Write staging file noting source was empty. Do not skip wiki/index update.
Wiki page conflict detected at compile time: Add a **Conflict:** field to the section. Never silently overwrite the existing mechanism.
Memory compile has missing sources: Report the missing source paths and keep the existing memory blocks untouched until the source issue is resolved.
Doc-sync queue empty: Output "No doc-sync work is queued." Stop.
Doc-sync queue has only surfaced entries: Output "All doc-sync items are already surfaced." Stop.
evolve pattern-library.md missing: "No evolve pattern library for '{target}'. Run /evolve {target} first to generate patterns." Stop.
Disclosure: "Compiling findings into .planning/wiki/. Modifies wiki pages in-place; creates staging files."
Reversibility: green — all writes are to .planning/wiki/ and .planning/wiki/_staging/; git restore .planning/wiki/ or delete the directory to undo. Quality rule additions to harness.json can be manually removed.
Trust gates:
--memory or the Step 5.5 compile pass/learn --doc-sync must leave no pending or needs-review entries for
processed queue items unless run with --dry-run/learn does not produce a full HANDOFF block (it is a utility, not a campaign). It outputs the summary block in Step 7 and waits for the next command.
tools
Bounded foreground repetition for the current session. Creates a loop contract, runs or coordinates an action plus verifier up to a declared attempt limit, and records evidence under .planning/loops/. Use for repeat-until-pass work that is too small for daemon and not time-based scheduling.
testing
Remove Citadel from a project. Exports valuable state (campaigns, postmortems, research, backlog, discoveries) to docs/citadel/ as human-readable markdown, then removes all harness files and hooks. The archive is detected by /do setup on re-install and offered for restore.
development
Research-driven multi-cycle improvement director. Forms causal hypotheses about why scores are low, validates them with scout agents before attacking, dispatches axis-parallel fleet attacks, extracts transferable patterns, and runs indefinitely within a budget envelope. Accumulates a persistent belief model and pattern library across sessions.
data-ai
Multi-repo campaign coordinator. Same lifecycle as fleet -- scope claims, discovery relay, wave-based execution -- but the unit of work is a repo, not a file. Coordinates campaigns across repositories with shared context.