kb-compact
This skill uses Claude hooks which can execute code automatically in response to events. Review carefully before installing.
/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 learning/skill/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}/../kb-learn/scripts/validate_kb.py --quiet --json
Fix any reported errors before finishing.
More from farzadshbfn/knowledge-skills
kb-find
Read-only KB discovery with progressive 4-tier loading and --challenge mode for counter-evidence.
10kb-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.
10kb-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.
9kb-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.
8kb-bootstrap
Sets up the knowledge base for a project or initializes the global (god) KB config. 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. Use --global to set up the global read-only KB.
7kb-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`.
6