/ai-knowledge:kb-prune [remove <article> | organize]from ai-knowledge
Audits and cleans up a Claude Code knowledge base: finds duplicates, contradictions, broken links, stale articles, unused scoped globs, and oversized pinned articles, then merges, fixes, or removes them with user approval.
Ships in ai-knowledge. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description, though model invocation is off: only you can start it.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Read kb-format.md first. It defines the layout, frontmatter, load modes and file-move rules used below.
Arguments (may be empty): $ARGUMENTS
| Arguments | Mode |
|---|---|
| None | Audit: review the whole knowledge base |
remove {article} | Remove one article (a file name, path or topic) |
remove | Remove, choosing the article from a list |
organize | Organize articles into category folders |
Every change needs the user's approval.
Run the checks from kb-format.md: stop if there's a 1.x knowledge base (point to /kb-migrate) or no knowledge base (point to /kb-init). Then read every article under .claude/rules/kb/ and .claude/kb/ with its frontmatter, plus _index.md.
_index.md; lines pointing at files that don't exist, or at pinned articles; lines whose summary, keywords or "loads with" globs no longer match the article.paths match no file (check each pattern with Glob). They never load._index.md against the budget in kb-format.md (Layout). Flag pinned articles over about 100 lines in total or more than five of them, and suggest which to scope or make on-demand. Flag an index over about 150 lines, and suggest merges.paths so they load only there..claude/rules/kb/ that aren't articles (a README, log or notes). They load every session.tags, created or last-updated; 1.x fields (scope, pinned, related, sources) or [[name]] links, which /kb-migrate fixes. Flag articles whose last-updated is more than 90 days old as review suggested: stable knowledge is fine, but worth a quick check.api-auth.md and api-tokens.md). Shared tags are a good hint. Merging scoped articles combines their paths._global-learnings.md): entries that are outdated (check whether the files or patterns they mention still exist), duplicated in another article, or area-specific, which should move to a scoped article so they stop loading every session..claude/rules/kb/ or .claude/kb/, suggest category folders (see Organize mode).Knowledge base audit
====================
Index ({n})
- tools/release.md is on-demand but missing from _index.md
Load modes ({n})
- testing/e2e.md: paths match no files (e2e/**; the folder is now tests/e2e/)
- Pinned: 4 articles, 210 lines. Suggest scoping security/auth.md to src/auth/**
- .claude/rules/kb/notes.md isn't an article and loads every session
Frontmatter ({n})
- conventions/naming.md: missing created
- tools/ci.md: last updated 140 days ago (review suggested; may still be right)
Merge candidates ({n})
- api-auth.md + api-tokens.md → api-auth.md (shared tags: api, auth)
Contradictions ({n})
- api-conventions.md: "Return 404 for missing records" vs api-errors.md: "Return 410"
Related ({n})
- tools/release.md → .claude/kb/tools/deploy.md doesn't exist (broken; moved to .claude/kb/ops/deploy.md?)
Global learnings ({n})
- "Use the query builder in src/db/" is area-specific: move to a scoped article for src/db/**
Summary: {n} healthy articles, {n} issues
With no issues: "The knowledge base is clean: {n} articles, {n} global learnings, no issues found."
Ask (Header: "KB Cleanup Plan"; Question: "Here's what I recommend. How do you want to proceed?"; Options: "Apply all" | "Let me review each one" | "Cancel"). When reviewing, ask about each action:
.claude/rules/kb/: "Move {file} to .claude/kb/, or delete it?"Get today's date once (kb-format.md, Dates). Apply only what was approved:
paths (kb-format.md, Moving and deleting files). Moving doesn't change last-updated; new or changed paths do./kb-migrate and mention it.tags, paths, source and the Related sections, delete the merged-away file, point other articles' Related entries at the target, and update _index.md.Update last-updated on every article whose content changed, and on no other. Remove empty sections and folders left behind.
Append to the log:
## [{date}] prune | Cleanup
- Index fixes: {n}; load-mode changes: {n}; frontmatter fixes: {n}
- Merges: {n}; contradictions resolved: {n}; link fixes: {n}
- Deleted: {paths}
Report the files created, updated, moved and deleted, and the final count of articles by load mode with the pinned line total.
.md), paths and titles. With several matches, or no argument, list the articles with their load modes and ask which one (Header: "KB Remove"). If nothing matches, say so and suggest /kb-query list._index.md line if any, and every article whose Related section points at it. Ask (Header: "Confirm Removal"; Options: "Delete it" | "Move it out of the knowledge base" | "Cancel"). Moving out keeps the file but stops it loading: ask where (default docs/{name}.md).git rm if tracked) or move it (git mv). Remove its _index.md line. Remove its entry from other articles' Related sections, dropping a section that ends up empty, and update last-updated on the articles that changed (with today's date, from kb-format.md).## [{date}] prune | Removed {name} with whether the file was deleted or moved, and which articles had links cleaned.Find articles loose at the root of .claude/rules/kb/ or .claude/kb/. _index.md, _global-learnings.md, _log.md and README.md stay where they are. With fewer than three loose articles, say there's too little to organize yet and stop.
For each loose article, read its tags and content and suggest a category folder, reusing existing folders first:
| Folder | For |
|---|---|
architecture/ | system design, patterns, data flow, module boundaries |
conventions/ | naming, style, API contracts |
testing/ | test patterns, fixtures, mocking |
tools/ | build tools, deployment, CI/CD, environments |
external/ | knowledge from other repos or websites |
domain/ | business rules and domain logic |
Use other names when the content calls for them, and don't create a folder that duplicates an existing one.
Show the moves:
KB organize
===========
| Now | Moves to | Why |
|---|---|---|
| .claude/rules/kb/api-conventions.md | .claude/rules/kb/conventions/api-conventions.md | tags: api, conventions |
| .claude/kb/release.md | .claude/kb/tools/release.md | tags: release, ci |
New folders: conventions/, tools/
Staying: _index.md, _global-learnings.md, _log.md, README.md
Ask (Header: "KB Organize"; Options: "Apply all" | "Let me adjust" | "Cancel"). With "Let me adjust", take new destinations as free text and show the plan again.
Move each file (kb-format.md, Moving and deleting files), staying in the same tree so its load mode doesn't change. Update the paths in _index.md and in other articles' Related sections. Don't change last-updated: the knowledge didn't change.
Append ## [{date}] prune | Organized {n} articles into folders with the moves to the log, and report the files moved and folders created.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub charlesjones-dev/ai-agent-plugins --plugin ai-knowledge7 skills in this plugin
/kb-addAdd knowledge to the team knowledge base from a note, project files or folders, another repo, a URL, or the project's own CLAUDE.md and docs/. Distills it into articles, picks how each one loads, records where it came from, and shows every draft before writing./kb-discoverRead the source code to find knowledge nobody wrote down (architecture, naming, API contracts, data models, error handling, configuration, testing patterns) and save it as knowledge base articles scoped to the code they describe. Shows each draft before writing./kb-initSet up a team knowledge base as Claude Code rules: .claude/rules/kb/ for articles Claude Code loads by itself and .claude/kb/ for on-demand articles. Turns auto-capture on for you unless you pass auto=off. On an existing knowledge base it doesn't redo setup: it turns auto-capture on if you never set it, keeps your earlier choice otherwise, and auto=on|off switches it. Also adds a short section to AGENTS.md so Codex and Cursor read the knowledge base (agents=off to skip). Points to /kb-migrate when the project has a 1.x knowledge base.Other plugins' skills for the same job