/ai-knowledge:kb-add [note | path, glob or URL ... | --absorb]from ai-knowledge
Adds knowledge to the team knowledge base from notes, files, folders, URLs, or project docs. Distills content into articles with load modes and shows drafts before writing.
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 writing rules used below.
Arguments (may be empty): $ARGUMENTS
| Arguments | Mode |
|---|---|
| None | Ask (below) |
--absorb | Absorb: review the project's CLAUDE.md and docs/ for content that belongs in the knowledge base |
| Only paths, globs and URLs, separated by spaces or new lines | Sources: distill each into articles |
Only paths under .claude/rules/kb/ or .claude/kb/ | Check: fix up article files someone added by hand |
| Anything else | Note: the text is one learning or rule |
A token counts as a source when it starts with http:// or https://, or when it's an existing file, an existing folder or a glob that matches files. Paths outside the project, such as a sibling repo, are fine. If some tokens are sources and the rest is prose, treat the whole text as a note and mention that the user can pass the paths alone to import them.
With no arguments, ask with AskUserQuestion:
Then ask for the text, paths or URLs as free text. The last option is Absorb.
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), and pass on any git warning.
Then read what exists: every article under .claude/rules/kb/ and .claude/kb/ (path, load mode, paths, tags, source, title), and _global-learnings.md if present. Use it to find overlaps, avoid duplicates and suggest destinations.
.claude/rules/kb/conventions/api.md (scoped: src/api/**)");## Key rules, in the imperative and concise. If a similar rule exists, update it instead; if the note contradicts one, replace it. Update last-updated, and add new tags or links..claude/rules/kb/_global-learnings.md doesn't exist, create it (frontmatter tags: [global, cross-cutting], created, last-updated; heading # Global learnings; rules under ## Key rules). Add the rule as a bullet, without duplicates, and remove placeholder text._index.md for a new scoped or on-demand article (or update the keywords of an existing article whose tags changed), and append an add entry to the log with the destination and the rule..md, .mdx and .txt files recursively. Skip CHANGELOG.md, LICENSE*, node_modules/, .git/, dist/, build/ and coverage/.{base}/{module}/docs/... or {base}/{module}/... it's {module}; otherwise use the folder above the docs folder. Those articles get a module:{name} tag..claude/rules/kb/ or .claude/kb/ go to Check mode instead.When a folder, glob or several sources were given, show a numbered report grouped by source:
KB Add: sources found
=====================
billing-module (../billing-module/docs/): 3 files
1. [x] api-conventions.md: "API conventions and patterns"
2. [x] deployment.md: "Deployment procedures"
3. [ ] README.md: "Module README" (probably not knowledge-base material)
Web: 2 URLs
4. [x] https://wiki.example.com/billing/api: "Billing API integration guide"
5. [ ] https://wiki.example.com/onboarding: failed (404 Not Found)
Check the sources that hold actionable knowledge and uncheck READMEs, changelogs, generated content and failed fetches. Ask (Header: "KB Add: Sources"; Question: "Which should I add? Give numbers to toggle, such as 1,3, or confirm."; Options: "Proceed with selection" | "Select all" | "Let me pick" | "Cancel"). A single file or URL skips this step.
For each selected source:
external/ suits other repos and sites), or an existing article on the same topic. If an article already has this source, propose refreshing that article with what changed instead of creating a new one.module:{name} for outside sources) and a load mode: scoped when the content is about specific folders or file types of this project, otherwise on-demand. Pinned only if the user asks.Show the plan and ask (Header: "KB Add: Plan"; Options: "Proceed with all" | "Let me adjust" | "Cancel"):
1. ../billing-module/docs/api-conventions.md
→ new: .claude/rules/kb/external/billing-api-conventions.md (scoped: src/billing/**)
→ tags: module:billing, api, conventions
→ actionable
2. https://wiki.example.com/billing/api
→ new: .claude/kb/external/billing-api-integration.md (on-demand: billing, api, integration)
→ reference (you asked to include it)
3. ../billing-module/docs/deployment.md
→ append: .claude/kb/tools/deployment.md (overlapping topic)
With "Let me adjust", take free-text changes to destinations, tags, load modes or the list, then show the plan again.
Get today's date once. Then, one article at a time:
source to the original path or URL. For an existing article that already has a source, make it a list and add the new one.last-updated.After the first three articles, offer to approve the rest without review ("Approve the remaining {n} articles without review?"). Articles from a URL or from a source outside the project still get their own review.
Where new and existing articles bear on the same tasks, list each in the other's Related section as a path (kb-format.md, Related articles). Add _index.md lines for new scoped and on-demand articles, and append an add entry to the log listing the sources and the files created or updated. Report each article with its source and the key rules it captured, and say that the sources weren't changed. Mention that running /kb-add on the same source later refreshes the article.
This replaces 1.x /kb-absorb. Moving content out of CLAUDE.md can weaken every session, so be conservative.
CLAUDE.md. Split it into sections and classify each:
When in doubt, classify a section as core. Moving a section that applies everywhere into a pinned article saves no context, because pinned articles load every session too, so only scoped and on-demand candidates are worth moving.
docs/. Find .md files (outside the knowledge base folders) and classify them as candidate (rules, conventions, guides Claude should follow in some context), reference only (human-facing tutorials, onboarding, API references) or skip (generated or irrelevant).
Other docs. Check *.md in the project root (other than CLAUDE.md and README.md), .github/ (CONTRIBUTING, templates), and CONTRIBUTING.md, ARCHITECTURE.md, DECISIONS.md and ADR folders. Classify them the same way.
Don't touch CLAUDE.md files in subdirectories; Claude Code already loads them only when Claude works in that folder.
Documentation review
====================
CLAUDE.md
Can move ({n}):
1. "{heading}" (lines {a}-{b}) → .claude/rules/kb/{category}/{name}.md (scoped: {globs})
Why: {it only applies to ...}
Stays ({n}): "{heading}": {reason}
Possibly redundant ({n}): "{heading}": {reason}
docs/ ({n} files)
Can absorb ({n}):
2. docs/guides/api-guide.md → .claude/kb/conventions/api-guide.md (on-demand: api, rest)
Reference only ({n}): docs/onboarding.md
Skipped ({n}): docs/generated/
Other documentation ({n})
...
Ask (Header: "KB Absorb"; Question: "How do you want to proceed?"; Options: "Move all candidates" | "Let me review each one" | "Cancel"). When reviewing, show each candidate's content and destination (Options: "Move to the knowledge base" | "Keep where it is" | "Different destination" | "Skip"). Confirm every CLAUDE.md section on its own even after "Move all candidates".
Get today's date once.
_index.md.docs/ or elsewhere: by default, write a distilled article with source set to the file and leave the original where it is, since people may read it there. If the file is already short, rule-like and only meant for Claude, offer to move it into the knowledge base instead (git mv, then add frontmatter).Then list related articles in each other's Related sections as paths, add _index.md lines for new scoped and on-demand articles, and append an add | Absorbed project documentation entry to the log listing what moved. Report the sections moved out of CLAUDE.md, the files absorbed, the articles created, and how many lines shorter CLAUDE.md is now. Remind the user to review the diff and check that Claude still has the context it needs, and that git can restore anything moved by mistake.
This replaces 1.x /kb-import. In 2.x there's nothing to register: a file under .claude/rules/kb/ loads by its location and frontmatter. The check makes hand-added files follow the format.
For each given file:
created and last-updated from today's date. If fields are missing, propose them. If it has 1.x fields (scope, pinned, related, sources) or [[name]] links, convert them the way /kb-migrate does: paths for scope, location for pinned, and plain paths in a Related section for the links..claude/rules/kb/ without paths loads every session, so ask whether to keep it pinned, scope it (suggest globs from its content), or make it on-demand. Scoped articles and files in .claude/kb/ need a line in _index.md.Apply what was approved, append an add | Checked {n} files entry to the log, and report each file's load mode and the fixes made.
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-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./kb-learnSaves team knowledge (corrections, rules, decisions, codebase gotchas) to the project's knowledge base in .claude/rules/kb/. Invoke it yourself in only two cases: (1) your context holds the instruction 'ai-knowledge auto-capture is on for this project' and such a learning just came up; pass `auto` and the learning. (2) The user explicitly asks you to save or add something to the knowledge base, KB or team rules; pass `auto` and that thing. A user stating a rule, convention or correction is not a request to save it: without the auto-capture instruction, don't invoke this skill for it. Typed as /kb-learn, it reviews the whole conversation and asks before saving./kb-migrateMove a 1.x knowledge base (the CLAUDE.md Knowledge Base table and docs/kb/) to Claude Code rules: pinned articles load every session, scoped ones when Claude touches matching files, and the rest through a short index. Shows the plan and asks first, supports --dry-run, is safe to re-run, turns on auto-capture, which replaces /kb-auto, unless you pass auto=off, and adds a short AGENTS.md section so Codex and Cursor read the knowledge base (agents=off to skip). It also finds references to renamed or removed marketplace commands in the knowledge base, CLAUDE.md, AGENTS.md, .gitignore and docs/, and proposes fixes. On a 2.x knowledge base it checks and repairs the format and runs the same command check, so running it again after a marketplace update catches newly stale references./kb-pruneClean up the team knowledge base: find duplicates, contradictions, broken links, stale articles, scoped globs that match nothing and pinned articles that cost too much context, then merge, fix or remove with your approval. Also removes a single article, or sorts articles into category folders./kb-queryAnswer a question from the team knowledge base with cited articles and offer to file the answer back as an article. Also searches by keyword or tag:name and lists every article with how it loads.Other plugins' skills for the same job