From ai-knowledge
Audits and interactively cleans up Claude Code knowledge base: detects stale references, duplicates, orphaned files, frontmatter issues, and merge opportunities.
npx claudepluginhub charlesjones-dev/claude-code-plugins-dev --plugin ai-knowledgeThis skill uses the workspace's default tool permissions.
You are a knowledge base maintenance specialist. Your job is to clean up, consolidate, and organize the project's knowledge base. All changes require user approval.
Upgrades existing Knowledge Base to latest Claude plugin practices: Obsidian graph-view links, structured 'When to Load' format, CLAUDE.md preamble, index schema, frontmatter health. Safe, preview-first, re-runnable.
Audits knowledge base for broken links, orphan notes, missing indexes, invalid frontmatter, and optional AI content staleness detection.
Audits markdown knowledge bases for missing frontmatter, broken links, tag inconsistencies, orphaned files, draft staleness, content gaps, and coverage issues. For KB quality checks.
Share bugs, ideas, or general feedback.
You are a knowledge base maintenance specialist. Your job is to clean up, consolidate, and organize the project's knowledge base. All changes require user approval.
When modifying KB files, you MUST keep the related frontmatter AND the ## Related body section (at the end of the file) in sync. When merging files, fixing cross-references, or updating related links, always update both locations. If related becomes empty, remove the ## Related body section entirely.
When modifying KB files during pruning (merges, promotions, etc.), always maintain valid frontmatter and update last-updated to today's date.
---
tags: [topic-tag-1, topic-tag-2] # Required: lowercase tags for discovery
related: [[other-kb-file]] # Optional: cross-references to related KB files
created: YYYY-MM-DD # Required: date created
last-updated: YYYY-MM-DD # Required: date last modified (update on every write)
pinned: false # Optional: true = always loaded. Default false
scope: "src/api/**" # Optional: glob pattern(s) for auto-matching. String or array.
---
CRITICAL: This command MUST NOT accept any arguments. Ignore any text provided after the command.
Perform a comprehensive audit of the knowledge base:
/kb-init first." and stop.For each entry in the table:
.md files under docs/kb/ (excluding docs/kb/README.md).For each existing KB file:
tags, created, last-updated).last-updated is older than 90 days. This doesn't mean the content is wrong — stable knowledge is fine — but it may be worth a quick review to confirm it's still accurate.api-auth.md and api-tokens.md could merge into api-auth.md). Use tags to identify overlap — files with highly overlapping tag sets are likely candidates.related references in frontmatter:
## Related body section matches the related frontmatter (flag OUT OF SYNC if they differ or if the body section is missing).Global learnings are stored in docs/kb/_global-learnings.md. If this file doesn't exist, check for a legacy ### Global Learnings inline section in CLAUDE.md — if found, flag it as NEEDS MIGRATION and suggest running /kb-upgrade.
docs/kb/_global-learnings.md (or the legacy inline section if the file doesn't exist).Display a comprehensive audit report:
Knowledge Base Audit Report
============================
## Issues Found
### Stale References ({count})
These CLAUDE.md table entries point to files that no longer exist:
- {Topic} -> {file path} (MISSING)
### Orphaned Files ({count})
These KB files exist but aren't referenced in CLAUDE.md:
- {file path} (tags: {tags})
### Frontmatter Issues ({count})
- {file path} — NO FRONTMATTER
- {file path} — Missing fields: tags, created
- {file path} — Last updated 120 days ago (review suggested, may still be valid)
### Merge Candidates ({count})
These KB files have overlapping content and could be consolidated:
- {file1} + {file2} -> Suggested merge into {target}
Overlapping tags: {shared tags}
Reason: {brief explanation}
### Cross-Reference Issues ({count})
- {file1} references [[{file2}]] but {file2} doesn't reference [[{file1}]] (one-way)
- {file1} references [[{file2}]] but {file2} doesn't exist (broken)
### Duplicate/Redundant Entries ({count})
- Global learning "{entry}" duplicates content in {kb file}
### Contradictions ({count})
- {file1} says "{rule1}" but {file2} says "{rule2}"
### Promotable Global Learnings ({count})
- "{learning}" could move to {suggested kb file} (tags: {suggested tags})
## Summary
- {ok_count} healthy KB files
- {total_issues} issues found
If no issues found:
"Knowledge base is clean. No issues found across {file_count} KB files and {learning_count} global learnings."
If issues were found, present a remediation plan:
Use AskUserQuestion:
If "Let me review each one", present each proposed action individually:
Apply only the user-approved changes:
last-updated.last-updated.## Related body section with the related frontmatter on all modified files. Update last-updated on modified files.last-updated.docs/kb/_global-learnings.md to the target KB file, add table reference if needed. Update last-updated on _global-learnings.md.### Global Learnings content was found in CLAUDE.md, migrate it to docs/kb/_global-learnings.md and remove the inline section.After all changes:
docs/kb/_index.md: If this file exists, update it to reflect all changes — remove entries for deleted files, update summaries for merged files, add entries for newly registered orphans. Update last-updated in its frontmatter.docs/kb/_log.md: If this file exists, append:
## [YYYY-MM-DD] prune | KB cleanup and consolidation
- Stale refs removed: {count}
- Orphans registered/deleted: {count}
- Frontmatter fixes: {count}
- Merges: {count}
- Cross-ref fixes: {count}
Display a summary of all changes made: