/ai-knowledge:kb-discover [paths ...] [--focus topic,topic]from ai-knowledge
Mines source code to extract undocumented knowledge (architecture, API contracts, data models, error handling, config, testing patterns) and saves it as knowledge base articles scoped to the code. Shows each draft 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
This command mines source code, not documentation. Use /kb-add for docs, other repos and URLs.
Paths (src/api src/models): analyze those folders or files.
--focus api,auth,config: look for those topics across the codebase.
No arguments: ask with AskUserQuestion:
src/api), give me topics (such as api, auth, error-handling), or ask for a full scan and I'll sample the codebase for its most important patterns."Then ask for the folders or topics as free text when needed.
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. Read the existing articles, including their paths and discovered-from, so you don't rediscover what's already captured.
*, src/*, lib/*, app/*, packages/*).package.json and tsconfig.json (Node, TypeScript), requirements.txt, pyproject.toml or setup.py (Python), go.mod (Go), Cargo.toml (Rust), *.csproj or *.sln (.NET), pom.xml or build.gradle (Java), Gemfile (Ruby). A project can use several.api/, routes/, controllers/, handlers/), data models (models/, entities/, schemas/, types/), configuration (config/, settings/, root config files), services (services/, domain/, core/), infrastructure (middleware/, plugins/, interceptors/), shared code (utils/, lib/, shared/) and tests (tests/, __tests__/, spec/).For a full scan, start with entry points, then route definitions, data models, configuration, middleware chains, base classes and shared abstractions, and test setup (fixtures reveal assumptions).
Look for knowledge in these areas, and skip any area where the code has nothing meaningful. Don't invent patterns.
Only count something as a convention when it repeats. A pattern in 1 of 20 files isn't one.
Group findings by topic as they naturally fall, not one article per area above. Good: "API conventions", "Data model patterns", "Testing strategy", "Project architecture". Too narrow: "How the User model works". Too broad: "Everything about the codebase". Too vague: "Naming things".
For each proposed article, prepare:
.claude/rules/kb/{category}/{name}.md, using existing folders where they fit;paths covering the code it describes (src/api/**, **/*.controller.ts). Use on-demand for architecture that spans the whole codebase but matters only for some tasks, and suggest pinned only for a short overview nearly every task needs;discovered-from (the folders or files analyzed);KB Discover: findings
=====================
Analyzed: src/api/ (23 files), src/models/ (15 files), src/config/ (4 files)
Stack: TypeScript, Express, Prisma, Jest
1. API conventions
→ .claude/rules/kb/conventions/api-conventions.md (scoped: src/api/**, src/routes/**)
→ tags: api, rest, conventions, express
→ from: src/api/, src/middleware/
- Routes follow /api/v{n}/{resource}
- Every handler is wrapped in asyncHandler()
- Responses use a { data, meta, error } envelope
2. Testing strategy
→ .claude/rules/kb/testing/testing-strategy.md (scoped: tests/**, **/*.test.ts)
→ tags: testing, jest, fixtures
→ from: tests/
- Test files mirror src/
- Integration tests hit a real test database; repositories aren't mocked
Overlap with existing articles: none
Ask (Header: "KB Discover: Findings"; Question: "I found {n} areas worth saving. Which should I create?"; Options: "Create all" | "Let me pick" | "Adjust and create" | "Cancel"). With "Let me pick", take comma-separated numbers. With "Adjust and create", take free-text changes (rename, merge two, add or remove findings, change paths or load modes).
Get today's date once (kb-format.md, Dates). Then, one article at a time:
discovered-from, and a Related section of paths to articles that bear on the same tasks, if any.discovered-from and update last-updated.After the first three articles, offer to approve the rest without review.
Where new articles and existing ones 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 the new scoped and on-demand articles, with each one's tags as keywords and its paths after "loads with".
Append to the log:
## [{date}] discover | Knowledge found in the code
- Analyzed: {folders and files}
- Created: {paths}
- Updated: {paths}
Report the articles created and updated with their load modes and key rules, the links added, and coverage: what was analyzed, whether large folders were sampled rather than read in full, and which other folders might be worth a /kb-discover {folders} run.
DATABASE_URL").paths with Glob before writing: a scoped article whose globs match nothing never loads.What SKILL.md sets; muted values are Claude Code's defaults
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-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