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.
- License 许可
- MIT
- 最近更新
- 2026-04-11
- Stars
- ★ 2
- Forks
- 0
01 前言 Front Matter
- name
- kb-monitor
- effort
- low
- description
- 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.
- argument-hint
- [--status | --convert <topic-path> | --health <skill-name>]
02 资源文件 12
- 参考文档agents/analyzer.md1.4 KB
- 参考文档reference/scoring-rules.md1.7 KB
- 参考文档references/authentication-with-jwt.md832 B
- 参考文档references/basic-express-setup.md626 B
- 参考文档references/database-integration-postgresql-with-sequelize.md830 B
- 参考文档references/environment-configuration.md462 B
- 参考文档references/error-handling-middleware.md877 B
- 参考文档references/middleware-chain-implementation.md999 B
- 参考文档references/restful-routes-with-crud-operations.md1.7 KB
- 脚本scripts/analyze_access.py13.0 KB
- 脚本scripts/security-checklist.sh734 B
- 脚本scripts/track_kb_access.py14.1 KB
03 SKILL.md 正文
/kb-monitor — KB Usage Monitoring & Skill Gardening
1. Routing
Parse $0 (the first argument) to determine the mode:
- If
$0is--statusor empty (default/proactive activation): Follow Section 3 (Status Mode). - If
$0is--convert: Follow Section 4 (Convert Mode).$1is the topic path. - If
$0is--health: Follow Section 5 (Health Mode).$1is the skill name. - Otherwise: Show usage:
Usage: /kb-monitor [mode] Modes: --status Show candidates + health (default) --convert <topic-path> Convert KB topic to skill --health <skill-name> Check skill health + correction history Examples: /kb-monitor /kb-monitor --convert claude/mcp/ /kb-monitor --health writing-article
1a. Target Format Awareness
When recommending or executing conversions, consider the target environment:
| Environment | Recommendation | Delegate to |
|---|---|---|
| Standalone project (default) | Convert to KB-backed skill | /kb-mint --skill |
| Plugin distribution | Convert to skill, then package as plugin | /kb-mint --skill then /kb-mint --plugin |
| Cowork plugin | Convert to skill, then package with Cowork additions | /kb-mint --skill then /kb-mint --cowork |
Detect environment from context: if the project has a .claude-plugin/plugin.json, it's a plugin project. If skills reference Cowork connectors or the project targets Cowork, recommend the Cowork path.
For plugin projects, also track plugin candidates — groups of related skills that could be bundled under a shared namespace. A group becomes a plugin candidate when 3+ skills share a common category prefix.
2. References
| Reference | Purpose |
|---|---|
| scoring-rules | Thresholds and scoring criteria for candidates and health |
2a. Data Sources
Access Log
Run analyze_access.py to query the access log without loading it into context:
uv run ${CLAUDE_SKILL_DIR}/scripts/analyze_access.py --top-topics --candidates --health --format=json
Output is compact JSON (~50-100 tokens).
Global KB Suggestions
Check for pending suggestions to global (read-only) KBs:
uv run ${CLAUDE_SKILL_DIR}/../kb-learn/scripts/suggestion.py list --status pending --json
If count > 0, include in status output. Alert when > 5 pending suggestions.
Memory
Read the memory file at the standard Claude memory location for this project. Look for monitoring_kb_observations.md. This contains:
- Skill candidate tracking (KB topics, session counts, status)
- Skill health tracking (corrections, status)
- Conversion history
- Policy gates (exclude, cooldown, condition, throttle)
2a. Agents
| Agent | Model | Purpose | Used by |
|---|---|---|---|
| analyzer | haiku | Compute access scores from raw log | --status (optional, for large logs) |
Use the analyzer agent when the access log is large (1000+ entries). For most cases, the analyze_access.py CLI output is sufficient.
3. Status Mode (--status)
-
Gather data: Run
analyze_access.py --top-topics --candidates --health --format=json -
Check suggestions: Run
suggestion.py list --status pending --jsonto count pending global KB suggestions -
Read memory: Load
monitoring_kb_observations.mdfrom memory directory -
Present findings:
Skill Candidates: For each candidate topic (high read count, no
skill/folder):- Topic name, session count, total reads
- Whether memory has any gate (cooldown, exclude, condition)
- Recommendation: "Convert?", "Skip", "Never for this topic"
Skill Health Issues: For each skill with corrections in memory:
- Skill name, correction count, last issue description
- Status:
watch(1-2 corrections),action(3+ corrections) - Recommendation: "Fix?", "Skip", "Mark resolved"
Pending Suggestions (Global KBs): If any pending suggestions exist, show count and summary per target KB. Alert if > 5 pending — user should review in the global KB repo.
Recent Conversions: List from memory's Conversion History table.
-
Prompt for action: Use
AskUserQuestionto ask the user what to do with each candidate/issue. Present the options clearly (Convert / Fix / Skip / Never / Not now / Wait until condition). Then process:- "Convert" → Switch to Section 4 (Convert Mode) for that topic
- "Fix" → Switch to Section 5 (Health Mode) for that skill
- "Skip" → No action, no memory update
- "Never" → Add
excludegate to memory's Policy Gates table - "Not now" → Add
cooldowngate with session count to memory - "Wait until <condition>" → Add
conditiongate to memory
-
Update memory: After each interaction, update
monitoring_kb_observations.md:- Update candidate session counts and statuses
- Record any new policy gates
- Keep under 100 lines (archive old entries)
4. Convert Mode (--convert <topic-path>)
Delegate the actual conversion to /kb-mint:
/kb-mint --skill <topic-path>
After kb-mint completes the conversion:
- Update monitoring memory: Add conversion record to memory's Conversion History table
- Remove from candidates: Remove the topic from Skill Candidates table
- If plugin project: Suggest follow-up:
/kb-mint --plugin <new-skill-name>(in plugin contexts, use the namespaced form instead)
5. Health Mode (--health <skill-name>)
- Read memory: Load correction history for this skill from
monitoring_kb_observations.md - Read skill files: Load the skill's
SKILL.mdand key reference files - Present health summary:
- Correction count (30-day window)
- Specific issues from memory's Skill Health table
- Comparison between recorded issues and current skill content
- Offer remediation: Use
AskUserQuestionto ask the user which action to take:- "Fix" → Run
/kb-learn fixwith pre-filled description constructed from correction history - "Mark resolved" — if issues have been fixed
- "Skip" — no action
- "Fix" → Run
- Update memory: Record health check, update status
6. Memory Management
Memory File Location
Standard Claude memory: ~/.claude/projects/<project-key>/memory/monitoring_kb_observations.md
Memory File Structure
---
name: kb-monitoring-observations
description: Cross-session KB access patterns, skill health scores, conversion history, and pending recommendations
type: project
---
# KB Monitoring Observations
## Skill Candidates
| KB Topic | First Seen | Sessions | Status |
|----------|-----------|----------|--------|
## Skill Health
| Skill | Corrections (30d) | Last Issue | Status |
|-------|-------------------|------------|--------|
## Conversion History
| Topic | Converted | Skill Name |
|-------|-----------|------------|
## Policy Gates
| Topic/Skill | Gate Type | Condition | Set On |
|-------------|-----------|-----------|--------|
| * (global) | throttle | max 1 conversion suggestion per session | — |
Gate Types
- exclude: Never surface this topic/skill (permanent)
- cooldown: Wait N more sessions before resurfacing
- condition: Don't surface until free-text condition is met
- throttle: Global rate limits on recommendation frequency
Housekeeping
- Keep memory file under 100 lines
- Archive old conversion history entries (older than 90 days)
- Remove stale cooldowns when session count is met
- Remove conditions when user confirms they're resolved
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-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-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.
kb-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.