knowledge-loop
Composite skill — query, capture, improve, and persist knowledge in one workflow. Chains recall (RAG query) → sync-memories (write durable note) → rag-curate (improve weak retrievals) → handoff (durable snapshot if session-ending). Use when the work involves "what did we decide", "remember this", "save where we are", or any closing checkpoint.
- License 许可
- MIT
- 最近更新
- 2026-11-14
- Stars
- ★ 1
- Forks
- 1
01 前言 Front Matter
- name
- knowledge-loop
- metadata
- { "tier": "contextual", "owner": "global-agents", "canonical_source": "~/.claude/skills/knowledge-loop" }
- auto-invoke
- end-of-task + recall-questions + checkpoint-requests
- description
- Composite skill — query, capture, improve, and persist knowledge in one workflow. Chains recall (RAG query) → sync-memories (write durable note) → rag-curate (improve weak retrievals) → handoff (durable snapshot if session-ending). Use when the work involves "what did we decide", "remember this", "save where we are", or any closing checkpoint.
- user-invocable
- true
02 资源文件 2
- 参考文档evals.json684 B
- 参考文档manifest.json1.2 KB
03 SKILL.md 正文
Knowledge Loop
Unifies the three knowledge systems (RAG index, claude-mem, handoffs) into one workflow so capture and retrieval stop being separate manual acts.
Auto-invocation triggers
- User asks "what did we decide about X" / "where did we leave Y" / "is there a memory note for Z"
- End of a meaningful task (commit landed, PR merged, decision reached)
- User explicitly says "remember", "save this", "checkpoint", "handoff"
- Session-budget guard signals approaching context limit
Workflow
Phase 1 — Query (always)
Invoke recall (or adt-rag-recall for repo-scoped queries) with the user's question
or the active task topic. If the user is asking a recall question, return the answer
immediately and skip Phase 2/3 unless they also asked to capture something.
Phase 2 — Capture (if new knowledge produced)
Invoke sync-memories with what was learned, decided, or built this session. Skip if
the session was pure read/recall with no durable output.
Phase 3 — Improve (conditional)
If recall returned weak hits (cosine <0.40) for a query that should have hit something,
invoke rag-curate to add the missing doc or rewrite the weak chunk. Skip if recall
was strong.
Phase 4 — Snapshot (if session-ending or context-pressured)
Invoke handoff to write a durable resume packet. Skip if work continues immediately.
Reconciliation
Output a single capture summary:
KNOWLEDGE LOOP — <topic>
Recalled: <n> hits, top cosine <X> (skill: recall)
Captured: <memory file paths> (skill: sync-memories)
Improved: <chunks rewritten / docs added> (skill: rag-curate)
Snapshot: <handoff path> (skill: handoff)
If a phase was skipped, mark it (skipped: <reason>) so the trail is visible.
Outputs / Evidence
- Recall results inline
- Memory files written (paths + one-line preview)
- RAG re-index confirmation (chunk delta)
- Handoff path if Phase 4 ran
Failure / Stop Conditions
- If recall returns nothing AND no new knowledge was produced this session → exit clean, no capture needed
- If
sync-memoriesandrag-curatewould write to the same file → consolidate writes to avoid double-update churn - Never skip Phase 4 if context is >80% — handoff is required for cross-session continuity
Worked example
End of a multi-round token-optimization session that shipped 15 hooks + a /caveman skill + autocompact tuning.
KNOWLEDGE LOOP — token optimization rounds 1-4
Recalled: 3 hits, top cos 0.50 (skill: recall)
Captured: token_opt_round4_2026-05-13.md + token_baseline_2026-05-13.md
(skill: sync-memories — manual write because the work was
still in-flight when the prompt arrived)
Improved: (skipped: RAG hits strong, no curation needed — top cos 0.50
is above the 0.40 weak-hit threshold)
Snapshot: handoffs/latest.md + precompact_snapshot_2026-05-13T23-53-44Z.md
(skill: handoff — auto-written by PreCompact hook 5 min earlier,
so phase 4 was effectively idempotent)
Key points the example demonstrates:
- Each phase output names the underlying skill, even when invoked indirectly (PreCompact hook fired
handofffor me). - A skipped phase says why, not just "skipped" — the threshold (cos 0.40) is the audit trail.
- Capture and Snapshot can land in the same turn without conflict; both write to
memory/.
04 同仓库更多 Skills
token-audit
Audit historical Claude Code token usage from JSONL session files — shows total spend, cache hit rates, top costly sessions, weekly trends, and where tokens are going. Run after heavy sessions or weekly to measure optimization impact. Answers how many tokens a session used, how expensive was that session, session cost, and token usage report.
smart-model-route
Auto-classify prompt complexity via Haiku (with heuristic fallback) and inject model routing hints for Agent tool calls. Wired as a UserPromptSubmit hook — fires on every prompt, routes low tasks to Haiku, standard to Sonnet, complex to Sonnet with thorough reasoning, and critical (security/arch/migrations) to Opus. Handles model selection, for example choose model by task complexity.
smart-commands
Decision guide for when to proactively use Claude Code slash commands — /think, /model, /compact, /clear. Use when choosing whether to invoke a command before or during a task, or when a complexity-classifier hook has flagged a task as high or critical. Pairs with the complexity-classifier UserPromptSubmit hook. Answers when to compact, should I switch models, and whether to use extended thinking. Use to pick the right /model command and switch model.
spec-ship
暂无简介
spec-new
Create a committed per-feature spec under `docs/specs/YYYY-MM-DD-<slug>/{spec,tasks}.md` with frontmatter (status, created, owner, pr, tags). Promotes an ephemeral `.claude/plans/<name>.md` into a persistent, searchable artifact. Use when starting a feature that's larger than a one-shot PR.
roadmap-refresh
Regenerate `docs/roadmap.md` for a repo from all specs under `docs/specs/` + their frontmatter (status, tags, pr). Produces Now/Next/Recently-shipped sections. Run after creating / shipping a spec, or at the start of a new session for orientation.