一键导入
learn
Extract reusable patterns from recent work into instincts. Run after completing features, fixing bugs, or at session end to capture what the project learned.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Extract reusable patterns from recent work into instincts. Run after completing features, fixing bugs, or at session end to capture what the project learned.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Inspect live routes and manage optional user-local OpenAI-compatible/LiteLLM extra routes through the kbrouter CLI.
Single user-facing KB completion command. Takes a feature, plan, or manifest from its current state through planning, work, post-work finalization, and configured delivery: local completion, pushed PR, or explicitly configured direct integration and sync.
Configure optional portable per-project lower-tier-attempt and delivery policy.
Large-initiative coordinator for KB workflows. Use for app migrations, framework rewrites, major architecture changes, multi-subsystem initiatives, multiple brainstorms/manifests, long backlogs, or queued execution across related workstreams.
Internal post-work quality and learning phase. Runs kb-review -> resolution gate -> follow-up resolution -> proof/demo evidence -> compound -> learn -> evolve -> memory refresh/compact -> cleanup after kb-work finishes all slices. Normally invoked by kb-work or kb-complete; not the primary user-facing completion command.
Deprecated compatibility alias for kb-complete. Use when an older prompt or workflow says 'kb finish'; delegate the same input to kb-complete and report the kb-complete result.
| name | learn |
| description | Extract reusable patterns from recent work into instincts. Run after completing features, fixing bugs, or at session end to capture what the project learned. |
| argument-hint | [recent work summary or blank for session observations] |
Analyze recent work (observations, git history, solutions) and extract reusable "instincts" — small learned behaviors with confidence scoring.
Run these in parallel to collect data:
git log --oneline -20 for recent commitsgit diff HEAD~5..HEAD --stat for what changed.kb/observations.jsonl for tool use patterns from hooks (optional; learning works without this feed)docs/context/kb/instincts/project.yaml and, if a narrower scope is active, docs/context/kb/instincts/scoped/<scope-path>.yaml (create if missing)docs/solutions/ for documented patternsLive Steering ledger section or
docs/context/operations/steering/<slug>.mdLook for recurring patterns across the evidence:
Code style patterns:
Workflow patterns:
Architecture patterns:
Tool usage patterns (from observations.jsonl):
Steering feedback patterns (from curated steering memory):
Do not learn from raw transcripts, unclassified PR comments, or one-off instructions. If feedback only applied to the current PR, leave it out of project instincts.
Before creating or updating instincts, apply time-based decay to all existing entries:
For each instinct in the active scope file (docs/context/kb/instincts/scoped/<scope-path>.yaml or docs/context/kb/instincts/project.yaml):
last_seennew_confidence = confidence × 0.5^(days_since_last_seen / 90)Archive stale instincts:
docs/context/kb/instincts/archive/YYYY-MM-DD-archived.yamlarchived_reason: confidence decayed below 0.3 (last seen: <date>)Write updated confidence values back to the scope file before proceeding to Step 3.
Half-life rationale: 90 days balances stability (project conventions rarely change weekly) with freshness (patterns unused for 6+ months are likely obsolete). At 90 days, an unobserved instinct at 0.85 decays to:
For each new pattern discovered, create an instinct entry. For patterns that match existing instincts, increase confidence and observation count.
Before creating or updating an instinct from feedback, classify it:
| Route | Use When | Durable Output |
|---|---|---|
current-only | Feedback only changes the active PR/session | manifest or PR note only |
steering-memory | Feedback should steer future target selection but is not yet a broad instinct | goal ledger or docs/context/operations/steering/<slug>.md |
observation | Feedback is an evidence point for later pattern extraction | .kb/observations.jsonl |
scoped-instinct | Ordinary lesson owned by one scope (DEFAULT) | docs/context/kb/instincts/scoped/<scope-path>.yaml |
landmine-candidate | Verified repo-specific trap — instant one-shot fast-path at owning scope | docs/context/landmines.md + owning scope file |
instinct-evidence | Pattern proven across sibling scopes via promotion-on-recurrence only | ancestor scope file or docs/context/kb/instincts/project.yaml |
Ordinary lessons default to scoped-instinct at the narrowest owning scope. instinct-evidence (a higher tier) is reached only via promotion-on-recurrence. One verified high-severity trap may become a landmine candidate, but ordinary
preferences need repeated evidence before becoming instincts. Steering memory is
the middle layer: it changes future loop behavior without pretending the pattern
is ready to become a reusable skill.
Measured learning changes that claim a better agent behavior must pass the adoption gate before they can be promoted beyond local/scoped use:
go run ./cmd/kbcheck learning-adoption --result-path <results.json>
The results must include at least 20 samples, no right-to-wrong regressions, no holdout string leakage, and either a two-case net gain or a 10 percentage point gain. Rejected candidates may still be recorded as scoped/experimental evidence, but they must not become shared/project/global rules.
A skill determines its active scope in this priority order:
scope: argument passed to /learnaudio pipeline imply scope: audio)scope: project only when no narrower scope is identifiable — never fall back to globalWhen working in scope S, load the active scope file + all ancestors (up to project, then global). Never load sibling scopes. Example:
working in audio/voice-eval → load: audio/voice-eval, audio, project, global
never: image, video, motion, image/comparer
The only path for a lesson to climb to a higher scope tier: when the same trigger+behavior pattern independently recurs across ≥ 2 sibling scopes, write a generalized instinct to their nearest common ancestor (not straight to global), citing the originating scopes as evidence.
| Recurs in | Promotes to |
|---|---|
audio/tts and audio/sfx | audio |
audio and image | project |
| domain-neutral, recurs across projects | global |
No lesson reaches global by any other path.
Instinct format (stored in docs/context/kb/instincts/scoped/<scope-path>.yaml for workflow/component scopes, or docs/context/kb/instincts/project.yaml for scope: project / scope: global):
instincts:
- id: kebab-case-unique-id
scope: audio/voice-eval # narrowest owning scope; default is NOT project
trigger: "when [specific situation]"
behavior: "do [specific action]"
confidence: 0.5
domain: code-style|testing|architecture|error-handling|workflow|tooling
observations: 1
first_seen: YYYY-MM-DD
last_seen: YYYY-MM-DD
evidence:
- "commit abc123: wrapped all errors with fmt.Errorf"
- "observed 3 times in observations.jsonl"
Confidence rules:
A landmine is not a generic lesson. It is a verified repo-specific trap the model is likely to miss without an explicit warning.
Only create a landmine candidate when the evidence shows at least one of:
Landmine candidates must include:
landmine:
severity: low|medium|high|critical
owner_surface: "<skill, script, doc, generator, fixture, or workflow>"
failure_mode: "<specific mistake likely without the warning>"
evidence:
- "<file, command, review finding, failing test, or observed mistake>"
fix_condition: "<what change retires the landmine>"
verification: "<command, eval, test, or review check proving the fix>"
Reject candidates that only say to test, read the code, keep things simple, or follow normal engineering practice. Those are not landmines.
High-severity landmines may be recorded from one verified observation, but skill
promotion still belongs to /evolve and requires its promotion gate.
Important constraints:
docs/context/kb/instincts/scoped/<scope-path>.yaml for workflow/component scopes, or docs/context/kb/instincts/project.yaml for project/global tier)docs/context/kb/instincts/ directory (and scoped/ subdirectory if needed) existsShow a summary:
Learning complete!
New instincts:
+ always-wrap-errors (0.5) — wrap errors with fmt.Errorf using %w
+ table-driven-tests (0.5) — use table-driven test pattern for Go tests
Updated instincts:
↑ prefer-early-returns (0.6 → 0.7) — 1 new observation
↑ run-tests-before-commit (0.7 → 0.8) — 2 new observations
Ready to evolve (confidence > 0.8):
★ run-tests-before-commit — consider /evolve to generate a skill
Total: X instincts (Y new, Z updated)
Instinct file: docs/context/kb/instincts/scoped/<scope-path>.yaml (or project.yaml for project-tier)
/instincts to see all learned patterns/evolve when instincts reach high confidence to generate full skills.github/hooks/copilot-hooks.json can capture tool use data when a consuming repo installs them; this portable bundle does not ship that hook file