Update the project's long-term memory after a merge to main. Reads the merged diff and the current memory, then writes Expert shards, discovered invariants, candidate lints, and AGENTS.md pointers — all on a reviewable learn/<sha> PR. Use post-merge (the harness invokes it automatically) or with --rebuild to regenerate memory from scratch. Triggers - learn, expert-update, update memory, update expert, post-merge memory, self-improve (project)
72
88%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
View guide
Passed
No findings from the security scan
The canonical home for this skill is learn in tdg-ninja/context-specs-factory-ai
This is how the project gets better on every merge. When code lands on main,
/learn reconciles the project's long-term memory with the new ground truth: it
updates the Expert (procedural + semantic memory, pulled on demand) and the
AGENTS.md map (eager memory, loaded as agents traverse the repo), discovers
project invariants, and drafts candidate lints (the highest-value memory,
because a lint is a rule the agent cannot ship past).
You run headless, invoked by the memory loop (scripts/learn-tick.sh, driven
by its own /loop … /learn-loop) as the post-merge step — in a dedicated
../<repo>-harness-learn worktree on a learn/<sha> branch off origin/main, never
in the build loop's host worktree. The memory loop runs independently of the
feature/build loop, so a from-scratch Expert bootstrap blocks neither. Your output is
a single reviewable PR — never an auto-merge. Humans steer at merge.
Memory reflects what is committed to
main, never what is planned. PRDs and specs describe intent; code is reality. You are the agent-readable summary of reality — so you only ever write from a merged diff, never from a branch in flight. This is why/learnruns post-merge and nowhere else.
There is one memory write path in this design: you, on merge, via a human-merged PR. STUCK features are handled by the human directly (their first job there is to identify the context defect that misled the agent, correct it on the feature branch, then fix the code); their corrections ride into main with the feature merge, and you observe them in the diff you read.
references/routing-rules.md.references/agents-md-guidance.md.references/consensus.md.references/invariant-discovery.md.learn/<sha>
with a changelog entry citing the merge. Never auto-merge.Read the seam references before acting; they are the hackable contract a project tunes to its taste:
references/routing-rules.md — the four destinations + the five-predicate test
for eager placement + the line-count caps. (Primary hackable seam.)references/expert-shards.md — the shard taxonomy and templates.references/agents-md-guidance.md — map-not-manual; which folders earn a nested
AGENTS.md; the freshness contract.references/invariant-discovery.md — how to surface invariants and draft lints
without overfitting.references/consensus.md — the voting threshold (2/3 default) and how to run it.Determine mode:
.claude/skills/expert/ exists (or --rebuild): create the
Expert from scratch by scanning committed code, seed all shards + the root
AGENTS.md. This is also the recovery path (see --rebuild).Idempotency: if learn/<sha> already exists on origin, another node handled this
merge — exit cleanly. (The memory loop pre-checks this too, via git ls-remote.)
Read: the diff for --since <sha>..--sha <sha>; the current Expert shards
(.claude/skills/expert/references/*.md); the AGENTS.md files the diff touches
(root + any in changed folders); and the PRD(s)/spec(s) for the merged feature if
present (prds/<f>/, specs/<f>/) for the why.
Notice whether the diff itself touches memory files (AGENTS.md, Expert shards, spec sections). If so, you're looking at a human's context correction — see P7; those changes are ground truth.
Spawn 2–3 cheap parallel reviewers (references/consensus.md). Each reads the diff
For each surviving candidate fact, apply references/routing-rules.md: lint /
eager AGENTS.md / lazy Expert shard / nowhere. When in doubt, prefer the Expert
(cheap) over AGENTS.md (eager), and prefer nothing over noise.
core-files.md,
patterns.md, etc.scripts/lints/ and wire it into scripts/local-checks.sh. The drafted lint
MUST pass against the just-merged code before you include it — run it; if it
fails on current main it's wrong (the inverse of /intent's right-reason check).Run scripts/check-agents-md.sh (referenced paths exist, cross-links resolve,
under caps). Re-run any drafted lint against current main (must pass).
Append a changelog.md entry citing the merge sha and listing every surface
touched and the consensus vote. Open the learn/<sha> PR. Done.
claude -p "/learn --since <sha> --sha <sha>",
inside the ../<repo>-harness-learn worktree. The --since is the
refs/harness/last-learned watermark (how far memory has already been digested);
--sha is current origin/main. Also runnable by a human with --rebuild
(regenerate memory from main)..claude/skills/expert/ (shards incl. invariants.md and
changelog.md), scripts/lints/* + scripts/local-checks.sh wiring, and
AGENTS.md files across the repo.learn/<sha> branch + open PR. Idempotent via
git ls-remote origin learn/<sha>. After the PR opens, the memory loop advances
refs/harness/last-learned to <sha> (atomic CAS) and pauses new runs until you
merge or close the PR.signal_learn_review)
attaches this run's headless claude -p session as a PR comment, so the human
evaluating the memory changes can open the trace and troubleshoot why /learn
routed a fact as it did. No action needed in this skill — the loop posts it.3a7a725
Canonical home
since Aug 20, 2026
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.