learn-capture
Skill1 starsChanged 3 months agoMITView on GitHub
The direct/lean interactive-session learnings PRODUCER (/foundry:learn-capture). Opt-in since v1.18 (FOUNDRY_SESSION_LEARNINGS=on) — when enabled, a once-per-session Stop hook injects a reflection turn that distills the session and emits records via the capture CLI into the .foundry/session-learnings partition /foundry:learn-distill consumes. This skill documents that mechanism + the manual capture escape hatch. Trigger to capture the current session's learnings on demand, or to understand the Stop-reflection producer.
3 other projects use a version of this.
Adopted by
Most recently taken up by
- OrionArchitekton/orion-skillstheir own version, first seen Nov 2, 2026
- EvolutionAPI/evo-nexustheir own version, first seen Oct 8, 2026
- evolution-foundation/evo-nexustheir own version, first seen Apr 20, 2026
Other versions3 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 3
- EvolutionAPI/evo-nexus★ 545same name
- evolution-foundation/evo-nexus★ 535same name
- OrionArchitekton/orion-skills★ 2same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository71 other files it gives its agents.
- AGENTS.mdAGENTS.md
- llms.txtllms.txt
- amendSkill
- auditSkill
- authorize-releaseSkill
- authorizeSkill
- certify-localSkill
- certify-stagingSkill
- coherence-checkSkill
- command-deckSkill
- contextSkill
- cut-releaseSkill
- dashboards-as-codeSkill
- data-tier-cutoverSkill
- decommission-gateSkill
- deploy-statusSkill
- dispatchSkill
- doctorSkill
- drift-sweepSkill
- env-hygieneSkill
- extract-specSkill
- fleetSkill
- grounding-conformanceSkill
- id-applySkill
- id-architectSkill
- id-baselineSkill
- id-discoverSkill
- id-documentSkill
- id-driftSkill
- id-impactSkill
- id-implementSkill
- id-importSkill
- id-planSkill
- id-promoteSkill
- id-reviewSkill
- id-rollbackSkill
- id-simulateSkill
- id-syncSkill
- id-testSkill
- id-validateSkill
- id-verifySkill
- indexSkill
- infra-sandboxed-applySkill
- initSkill
- intakeSkill
- learn-distillSkill
- merge-when-greenSkill
- mode-autonomousSkill
- mode-interactiveSkill
- modeSkill
- post-upgradeSkill
- releaseSkill
- relockSkill
- report-citation-graphSkill
- reposSkill
- research-captureSkill
- research-firstSkill
- revertSkill
- sd-debugSkill
- sd-discoverSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
3 rules. 0 are common, 1 is distinctive, and 2 are very specific to this project.
0
Common
Most of the 3 edited versions we read keep these.
1
Distinctive
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 18
When enabled, a Stop hook (hooks/foundry-session-learnings.sh stop, wired in hooks.json) fires when the session goes idle and — once per …
- Very specific: line 95
Default mode is append — it writes records and does not touch the once-per-session reflection marker (so a mid-session append can never …
- Distinctive: line 106
Run the capture CLI yourself to record a learning on demand (same partition/format):
“Common” is measured: kept by at least 6 in 10 of the 3 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
/foundry:learn-capture
The third learnings PRODUCER (feat-foundry-session-learnings-capture) — for the plain operator-driven
direct/lean session that returns no value, spawns no worker, and leaves no worktree. Siblings: the
worker structured-return + worktree-sidecar producers (foundry-harvest-learnings.sh). Consumer:
/foundry:learn-distill (unchanged; the schema authority).
How it works (opt-in: FOUNDRY_SESSION_LEARNINGS=on)
- Off by default since v1.18 (operator decision 2026-09-25): the Stop-time block interrupted
ordinary sessions, so it now fires only when
FOUNDRY_SESSION_LEARNINGSisonorfull(see the knob below). Unset, it exits 0 and never blocks;/foundry:learn-capturestill works on demand. - When enabled, a
Stophook (hooks/foundry-session-learnings.sh stop, wired inhooks.json) fires when the session goes idle and — once per session, re-entrancy-guarded bystop_hook_active+ a per-session marker, interactive sessions only, and only for a substantive session (see the substance gate below) — injects a single reflection turn. - What you see, and why it says "error". The reflection arrives as a blocked
Stophook, and Claude Code captions every blockedStophook as an error — including this one, which is working exactly as designed. That caption is upstream's (anthropics/claude-code#12667, #34600, #62139) and Foundry cannot change it. What Foundry does control is the contents: the operator-facingreasonis two short lines that say so plainly, while the model-facing runbook rides inhookSpecificOutput.additionalContextwhere it costs you no screen space (AC-RUX-1). Nothing is wrong when you see it. - The model distills the session into learning records (JSONL) and emits them via the bare PATH
command
foundry-learn-capture(added to the Bash tool PATH while the plugin is enabled — no version in the path, no$CLAUDE_PLUGIN_ROOT), with an absolute-path fallback for the post-update window:
(records on stdin, never on argv). Zero records is fine for a low-value session.if command -v foundry-learn-capture >/dev/null 2>&1; then \ cat <records.jsonl> | foundry-learn-capture --final --session-id <id> --project-dir "$CLAUDE_PROJECT_DIR"; \ else \ cat <records.jsonl> | "${CLAUDE_PLUGIN_ROOT}"/hooks/foundry-session-learnings.sh capture --session-id <id>; \ fi - CLI-only write path (AC-LBC-3). Emit records ONLY through this capture CLI (which validates each
line and partitions the write) — never write a file directly under .foundry/session-learnings/. A
hand-written file the distiller cannot read (wrong shape, or in the buffer root instead of a
YYYY-MM-DD/partition) is silently lost (the doctorbuffer-driftsignal this line originally named was retired with the drop-in registry — check the partition by hand); it counts as any residual. A non-object/unparseable line piped to the CLI is rejected + counted (content-free), not written. - The shared writer lands them content-addressed + idempotent in
.foundry/session-learnings/<date>/<sid>__session__<hash>.jsonl(channelsession), through a mechanical secret-scrub (best-effort defense-in-depth — see AC-SLEARN-7), fail-open, with a reconciliation row in.harvest-log.jsonl(the per-channel doctor surfacing this line originally named was retired with the drop-in registry).
Cadence + the opt-in switch (FOUNDRY_SESSION_LEARNINGS)
The substance gate (AC-RUX-2). A session that provably did nothing worth reflecting on never
reflects. The hook reads the harness-supplied transcript and treats the session as substantive if
any of: a mutation tool call (Edit / Write / MultiEdit / NotebookEdit); a delegation
(Agent / Task / Workflow); or at least FOUNDRY_SESSION_LEARNINGS_MIN_TURNS genuine user
turns (default 3). A one-shot read-only probe — /foundry:doctor and friends — is therefore
silent. Bash is deliberately not a substantiveness signal (classifying it would mean parsing
arbitrary shell); a real Bash session qualifies on turn count instead.
The gate is conservative in exactly one direction: an absent, unreadable, or unparseable transcript counts as substantive. It can only ever suppress on positive proof of insubstantiality — a read failure can never silently switch capture off.
The knob (AC-RUX-3). Claude Code has no per-hook disable — only disableAllHooks (which would
also disable the git-discipline and cwd-enforce hooks) or uninstalling the plugin. So Foundry ships its
own; reach for this, not disableAllHooks:
FOUNDRY_SESSION_LEARNINGS | Behavior |
unset / off / anything else | Default (since v1.18). Never reflect, never block. Silent no-op; no marker written, so opting in mid-session loses nothing. An unrecognized value degrades to this, never to an error. |
on | Reflect once per session when the classic guards pass and the substance gate applies. |
full | Always reflect when the classic guards pass — bypasses the substance gate (pre-v0.27 cadence). |
Set it per-session in your shell, or persistently via the env block in .claude/settings.json.
Public programmatic entrypoint — foundry-learn-capture
A consumer skill body (model-invoked Bash, NOT a hook) that wants to append one learning
record the moment an insight is filed uses the PATH-installed public command
foundry-learn-capture (bin/foundry-learn-capture, auto-added to the Bash tool PATH while the
plugin is enabled). It reads records as JSONL on STDIN only (never argv) and self-resolves its
shared library relative to its own location (no $CLAUDE_PLUGIN_ROOT, no version path).
Consumer-binding contract (REQUIRED). Because a skill-body Bash call does NOT reliably export
CLAUDE_SESSION_ID / CLAUDE_PROJECT_DIR, a consumer skill body MUST pass --session-id and
--project-dir (supplied via skill/command-file inline ${…} substitution, not the Bash env):
printf '%s\n' '{"lesson":"…","context":"…"}' \
| foundry-learn-capture --session-id "<sid>" --project-dir "<workspace-root>"- Default mode is
append— it writes records and does not touch the once-per-session reflection marker (so a mid-session append can never suppress the session's ownStopreflection). --finalis the explicit closer (theStopreflection turn) — it writes records then CASes the markerrequested→done(and refuses to manufacture adonefrom an absent marker).- An unresolved
--project-dir(and no$CLAUDE_PROJECT_DIR) fails closed (a content-free stderr loss signal, nothing written) rather than writing into the wrong repo; an unresolved--session-idfails closed in--final(records still written) and warns inappend. --strictmakes a reject/loss/fail-closed-root exit non-zero (default is fail-open exit 0).
Manual capture (escape hatch)
Run the capture CLI yourself to record a learning on demand (same partition/format):
printf '%s\n' '{"lesson":"…","context":"…"}' \
| "${CLAUDE_PLUGIN_ROOT}"/hooks/foundry-session-learnings.sh capture --session-id "$CLAUDE_SESSION_ID"Notes / anti-patterns
- Do not put secrets in records. The producer scrub is best-effort; the authoritative control is
operator review at the public boundary (
/foundry:upstream-submit). Distill lessons, not raw spans. - Not per-turn, but re-armed per manual
/compact. Reflection fires at the first qualifying idle and is then re-armed at each MANUAL compaction boundary by thePreCompacthook (foundry-session-learnings.sh precompact), which resets the per-session marker torearmedso the next idle re-injects — once per compaction SEGMENT rather than once per whole session (the operator's real episode boundary). Auto-compaction does NOT re-arm (no system-triggered amplification). Seeits authorizing spec. - A session that dies before its first idle (or before its next idle after a
/compact) loses that segment's learnings — the accepted bounded residual of the inline-only design (the post-hoc fallback was dropped after the deep spec audit; matches inline-only systems), now strictly smaller thanks to the per-compaction re-arm. - Self-test the producer:
hooks/foundry-session-learnings.sh --selftest.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

