kb-compact
Compacts KB directories — extracts legacy, unifies terminology, splits oversized notes, fixes indexes, reconciles with skill folders. Default: single directory. Use --deep for recursive bottom-up traversal.
- License 许可
- MIT
- 最近更新
- 2026-04-09
- Stars
- ★ 1
- Forks
- 0
01 前言 Front Matter
- name
- kb-compact
- description
- Compacts KB directories — extracts legacy, unifies terminology, splits oversized notes, fixes indexes, reconciles with skill folders. Default: single directory. Use --deep for recursive bottom-up traversal.
- argument-hint
- [--deep] [path/to/directory]
02 资源文件 14
- 参考文档agents/compacter.md5.7 KB
- 资产文件assets/index-note.md411 B
- 参考文档compile-epic-context.md2.9 KB
- 其他customize.toml1.6 KB
- 参考文档reference/deep-compaction.md2.0 KB
- 参考文档reference/folder-structure.md3.8 KB
- 参考文档spec-template.md3.3 KB
- 参考文档step-01-clarify-and-route.md9.5 KB
- 参考文档step-02-plan.md2.9 KB
- 参考文档step-03-implement.md1.8 KB
- 参考文档step-04-review.md4.0 KB
- 参考文档step-05-present.md4.3 KB
- 参考文档step-oneshot.md3.7 KB
- 参考文档sync-sprint-status.md1.4 KB
03 SKILL.md 正文
/kb-compact
1. Configuration
Read KB config from .claude/knowledge-base/config.json (kb_roots array). Single KB: use its path. Multiple: AskUserQuestion which KB. No config: tell user "Run /kb-bootstrap to set up." and stop.
2. Input
Parse $ARGS:
--deep: recursive bottom-up traversal. Without it: single directory only.- path: optional, relative to project root or
<kb_root>. - No path: ask user. Offer "Compact whole KB" (warn: expensive, implies
--deep) or specify subfolder.
3. Folder Structure
All restructuring follows reference/folder-structure.md (canonical for clustering, unification, indexes, naming).
Sibling unification first: child folders grouped by semantically/lexicographically close names, run before other steps. 5+ siblings = medium sign; 8+ = high.
Template: assets/index-note.md
4. Orchestration
- Default: Single compacter agent for target directory.
--deep: Follow reference/deep-compaction.md — tree analysis, level-based parallel compacter agents, bottom-up.
5. Changelog
Every run changing knowledge files MUST prepend to <kb-root>/CHANGELOG.md per ${CLAUDE_SKILL_DIR}/../learn/reference/changelog-workflow.md.
6. User Approval
After all agents complete: present combined summary (files processed/moved/merged/split/created/deleted, terminology, legacy, indexes). AskUserQuestion: "Keep all", "Revert selectively", "Revert all". Selective: per-directory summaries, revert via git checkout -- <paths>.
7. Validation
After completing KB changes, run the validator to catch broken links, frontmatter issues, and structural errors:
uv run ${CLAUDE_SKILL_DIR}/../learn/scripts/validate_kb.py --quiet --json
Fix any reported errors before finishing.
04 同仓库更多 Skills
kb-view
Opens the KB viewer in the browser. Starts a local HTTP server that renders all configured knowledge bases with working links, fuzzy search, and knowledge graph visualization.
kb-monitor
Monitors KB usage patterns and skill health. Activates when KB access tracking detects frequently-read content that could become a skill, or when user corrections suggest a skill is underperforming. Also triggers on `this isn't working right`, `this skill keeps getting X wrong`, `convert this to a skill`, or `what should become a skill`. Tracks cross-session observations via memory.
kb-mint
Mints skills from KB topics, packages skills into plugins, and prepares them for Cowork. Use when asked to create a skill from KB content, convert to a plugin, package for distribution, or make something cowork-ready. Also triggers on `convert this to a skill`, `package as plugin`, `mint a skill`, or `make this a plugin`.
kb-learn
Manages a personal knowledge base with learning tracking. Modes: (1) learn from articles, (2) learn about topics, (3) fix errors. Uses markdown links with relative paths for cross-references. Maintains a rolling changelog, validates links, and keeps a markdown-compatible knowledge base. When a note reaches ~500 lines, suggests /kb-compact.
kb-find
Read-only KB discovery with progressive 4-tier loading and --challenge mode for counter-evidence.
kb-bootstrap
Sets up the knowledge base for a project. Creates the KB config, directory structure, and appends minimal instructions to the project's CLAUDE.md. Run this once when first using KB skills in a new project.