From ai-knowledge
Analyzes conversations to extract learnings, best practices, institutional knowledge, saving to topic-specific markdown KB files and updating CLAUDE.md references.
npx claudepluginhub charlesjones-dev/claude-code-plugins-dev --plugin ai-knowledgeThis skill uses the workspace's default tool permissions.
You are a knowledge extraction specialist. Your job is to analyze the current conversation, identify valuable learnings, and persist them so future Claude Code sessions benefit from this institutional knowledge.
Adds learnings, rules, or notes to the knowledge base via free-text input, suggesting optimal KB file locations based on existing structure and tags.
Extracts reusable strategic knowledge from session history (architecture, patterns, ops) and updates local CLAUDE.md. Triggers on 'learn', 'save knowledge', or session ends.
Extracts patterns, quirks, and decisions from conversations; persists to Markdown files in knowledge/learnings/. Use /learn for quick or /learn --deep for thorough analysis.
Share bugs, ideas, or general feedback.
You are a knowledge extraction specialist. Your job is to analyze the current conversation, identify valuable learnings, and persist them so future Claude Code sessions benefit from this institutional knowledge.
Every KB file you create or update MUST have valid YAML frontmatter. When creating a new file, include all required fields. When updating an existing file, always update the last-updated field 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.
---
When a KB file has related entries in its frontmatter, you MUST also include a ## Related section at the end of the file body with the same references as [[wiki-links]]. This enables Obsidian graph view and link navigation (frontmatter values are not parsed as navigable links by Obsidian). Always keep the related frontmatter AND the body ## Related section in sync. If there are no related files, omit the ## Related section entirely.
Example body section (placed at the very end of the file):
## Related
- [[api-conventions]]
- [[auth-patterns]]
CRITICAL: This command MUST NOT accept any arguments. Ignore any text provided after the command.
Review the entire conversation from start to finish. Extract learnings in these categories:
SECURITY: Never store secrets, API keys, tokens, passwords, connection strings, or any sensitive credentials in KB files or CLAUDE.md — even if they were referenced in the conversation. Instead, record the pattern or rule about how secrets should be handled (e.g., "API keys for service X must come from environment variables, never hardcoded" rather than the actual key value). If a learning involves a specific service or endpoint URL that could be sensitive, describe it generically (e.g., "the internal staging API" rather than the full URL).
For each learning, determine:
[api, auth, security])/kb-init first, then stop.Present the extracted learnings to the user in a clear summary, organized by destination:
Proposed Knowledge Base Updates:
## New/Updated KB Files
1. docs/kb/{topic}.md (NEW)
Tags: [tag1, tag2]
Related: [[existing-file]]
- Learning: "Brief description of what will be captured"
- Learning: "Another thing to capture"
- Context: "When working on/in {area}"
2. docs/kb/{existing-topic}.md (UPDATE - appending)
- Learning: "New thing to add to existing file"
- Will update last-updated date
## Global Learnings (CLAUDE.md)
- "Cross-cutting learning that applies everywhere"
- "Another global insight"
## CLAUDE.md Table Updates
- New row: {Topic} | docs/kb/{file}.md | {when to load}
## Cross-References
- docs/kb/{file1}.md now references [[{file2}]]
Wait for user approval before making any changes. Use AskUserQuestion:
If "Let me pick which ones", present each learning individually and ask whether to include it.
After approval:
For each topic-specific learning:
New KB file: Create it under docs/kb/ with frontmatter, content, and related links:
---
tags: [{inferred tags}]
related: [{cross-references if any}]
created: {today's date}
last-updated: {today's date}
pinned: false
scope: ["{glob patterns if applicable}"] # String or array of glob patterns
---
# {Topic Name}
{Brief description of what this KB covers and when it applies.}
## Key Rules
- {Learning 1 - concise, actionable}
- {Learning 2}
## Related
- [[{related-kb-file}]]
Only include the ## Related section if there are related files. It must be the last section in the file.
Existing KB file: Read the file, append new learnings under the appropriate section. Do not duplicate existing entries. If a learning contradicts an existing one, replace the old entry with the new one (the latest conversation has the most current information). Always update last-updated in the frontmatter to today's date. Add any new tags or related references to the frontmatter.
KB file writing rules:
docs/kb/architecture/, docs/kb/conventions/, docs/kb/testing/). Use existing folder structure as a guide. If the KB is still small (< 5 files) or flat, placing files at the root is fine.docs/kb/packages/api.md for a monorepo package).After creating/updating KB files:
[[new-file]] to the existing files' related frontmatter.## Related body section on any file whose related frontmatter was modified (keep them in sync).last-updated on any file whose frontmatter was modified.Global learnings are stored in docs/kb/_global-learnings.md (a pinned KB file), NOT inline in CLAUDE.md.
docs/kb/_global-learnings.md. If it doesn't exist, create it with frontmatter (tags: [global, cross-cutting], pinned: true, today's dates) and a # Global Learnings heading.## Key Rules.last-updated in frontmatter to today's date._global-learnings.md is registered in the CLAUDE.md Knowledge Base table as: | Global Learnings | docs/kb/_global-learnings.md | Always (pinned) |—) and topic keywords from tags. Example: `src/api/**`, `*.controller.ts` — api, rest, middleware. If the KB file has no scope patterns, use keywords only: — api, rest, middleware. Pinned files always use Always (pinned).After all KB changes:
docs/kb/_index.md: If this file exists, update it to reflect new/updated articles — add entries with one-line summaries for new files, update summaries if content changed significantly, and remove entries for deleted files. Keep categories organized by topic. Update last-updated in its frontmatter.docs/kb/_log.md: If this file exists, append an entry:
## [YYYY-MM-DD] learn | Conversation learnings captured
- Created: {list of new files}
- Updated: {list of updated files}
- Global learnings: {count added}
After writing all changes, display a summary:
last-updated. Always add relevant tags.