Our review
Maintains a living `.knowledge/` directory of focused markdown files documenting architecture, design decisions, and codebase understanding.
Strengths
- Encourages persistent, verifiable documentation rooted in actual code.
- Clearly separates rules (CLAUDE.md), understanding (knowledge), and personal context (Memory).
- Auto-generates an index for easy navigation across topics.
- Forces fact verification by reading code, reducing speculation.
Limitations
- Requires discipline to keep files under 80 lines.
- Only useful if maintained regularly; stale knowledge is misleading.
- Limited to projects with a well-defined structure to reference.
To document non-obvious architecture decisions or onboard new team members with persistent context.
For trivial changes (typo fixes, simple renames) or when knowledge is already well-documented elsewhere.
Security analysis
SafeThe skill uses only Read, Grep, Glob, Write, and Edit to manage markdown files within a .knowledge directory; it does not invoke any shell commands, network requests, or external tools, posing no execution risk.
No concerns found
Examples
Can you document the architecture decision for using WebSockets instead of polling in the notification service? Create a knowledge file in .knowledge/ with the reasoning.Update the knowledge base with the reasoning behind the new caching layer we just implemented. Verify the facts by reading the relevant code.Verify the knowledge base: are all the facts in .knowledge/architecture.md still accurate based on the current code? Update if needed.name: librarian
description: >
Maintains a .knowledge/ directory of focused markdown files about the codebase.
Trigger when: user asks about project structure, architecture, "why was X built
this way", "how does Y work", onboarding questions; user says "update the knowledge
base", "remember this decision", "document this", "verify the knowledge base",
"refresh the knowledge base"; completing a feature/refactor/bugfix that involved
non-obvious decisions or architectural changes. Do NOT trigger for trivial tasks
(typo fixes, simple renames, one-line changes with no design impact).
allowed-tools: Read Grep Glob Write Edit
Librarian — Project Knowledge Agent
Maintain a living knowledge base in .knowledge/ at the project root — short,
focused markdown files with YAML frontmatter, indexed automatically.
Where knowledge lives — the three systems
Claude Code has three persistence mechanisms. They serve different purposes. Never duplicate information across them. When deciding where to store something, use this table:
| What | Where | Why |
|------|-------|-----|
| Project conventions, commands, rules ("use Prettier with tabs") | CLAUDE.md | Auto-loaded every conversation. Affects Claude's behavior. |
| Deep context: architecture, data flow, design decisions, gotchas | .knowledge/ | On-demand retrieval. Too detailed for CLAUDE.md. Shared via git. |
| User profile: role, preferences, corrections to Claude's behavior | Memory (user, feedback) | Personal. Not team knowledge. |
| Active project state: who's doing what, deadlines, incidents | Memory (project) | Ephemeral. Changes fast. Per-user awareness. |
| Pointers to external systems (Linear, Slack, dashboards) | Memory (reference) | Not codebase knowledge. External system locations. |
CLAUDE.md is rules. .knowledge/ is understanding. Memory is personal context.
If it tells Claude how to behave in this project → CLAUDE.md.
If it explains why the codebase works this way → .knowledge/.
If it's about the person or their current situation → Memory.
Core rules
- Only write what you can verify. Every fact in the knowledge base must come from reading actual code, config, or the user's explicit statements. Never infer, assume, or fill gaps with plausible-sounding content. If you don't know something, leave it out — an incomplete file is better than a wrong one. If a detail matters but you can't confirm it, ask the user.
- One topic per file, under 80 lines. Split when exceeded.
- Every file has YAML frontmatter with
summary,tags,terms, andupdated. _index.mdis auto-generated. Rebuild it after every write by globbing.knowledge/*.mdand reading frontmatter. Never edit it by hand.- Update, don't append. Rewrite stale content. Move old decisions to a
## Decisionslog with dates and "superseded" labels. - Be brief. No narration of your process. Confirm updates in one sentence.
For file format: references/file-template.md.
For index format: references/index-template.md.
For writing style: references/writing-guide.md.
Frontmatter schema
Every knowledge file starts with:
---
summary: One sentence, max 20 words — what this file covers
tags: [topic, tags, for, filtering]
terms:
shorthand: What it means → `exact/code/path.ts`
updated: YYYY-MM-DD
---
summary— appears in the generated index. Be specific.tags— usedecisionfor design decisions, domain tags for topics.terms— dictionary entries this file owns. Team jargon → code locations. Replaces the old standalone dictionary. Each file declares its own terms.updated— last modified date.
Rebuilding the index
After every write to .knowledge/, regenerate _index.md:
- Glob
.knowledge/*.md(exclude_index.md) - Read frontmatter from each file
- Write
_index.mdwith three tables: Files, Terms, Tags (seereferences/index-template.mdfor exact format)
This replaces manual manifest and dictionary maintenance. The index is always derived, never hand-edited, and can be regenerated from scratch at any time.
Retrieval
Scale effort to task complexity:
Light (most tasks): Read _index.md. If a relevant file is obvious from the
index, read it. Done.
Deep (unfamiliar areas, cross-cutting changes, onboarding questions):
- Read
_index.md - Match task keywords against tags and terms
- Read 1–3 relevant knowledge files
- Inject a brief context block:
Context loaded: [2–3 sentences with file paths and key facts]
If no knowledge exists yet, say so in one line and proceed with the task.
Staleness check: If a term or file reference points to a path that no longer exists, flag it briefly and fix it during the next record pass.
Recording
Only record when the task produced something worth remembering:
- Design decisions — especially rejected alternatives and why (tag:
decision) - Non-obvious data flow or integration points
- Environment/config requirements not evident from the code
- Gotchas that cost time and would bite someone again
- New domain terms or jargon
Skip recording for: trivial fixes, obvious changes, anything readable from code or git log.
Steps:
- Create or update the knowledge file with proper frontmatter. Use
Editfor surgical updates to existing files. - Add or update
## See alsocross-references in related files. - Rebuild
_index.md. - Confirm in one sentence.
Fix what you see: If during recording you notice a file over 80 lines, a dead term path, or overlapping files — fix it now. Don't defer.
Bootstrapping
Only when explicitly requested ("bootstrap the knowledge base", "set up librarian"). Never auto-bootstrap as a side effect of an unrelated question.
- Create
.knowledge/_index.md(empty, will be populated in step 7) - Scan project structure → create
architecture.mdwith frontmatter - Scan
.env*, docker-compose, CI config → createenv-config.mdif relevant - Scan codebase for key modules → populate
termsin each file's frontmatter - Add
## See alsocross-references between related files - Ask the user about key design decisions for each area documented.
Present what you found ("matching uses a fuzzy threshold of 82 — do you
remember why that value?") and record answers in
## Decisionssections. Don't skip this — decisions are the most valuable content in the knowledge base. - Verify — run the verification pass (see below) and fix all issues found.
- Rebuild
_index.mdfrom all created files - Add the knowledge base directives to the project's CLAUDE.md
(see
references/claude-md-snippet.md— use the minimal version if CLAUDE.md is already long, full version otherwise. Create CLAUDE.md if it doesn't exist.) - Ask the user: commit
.knowledge/to the repo (shared team knowledge) or add to.gitignore(personal use)? Default recommendation: commit it. - Ask about maintenance automation. Present the options:
- Pre-commit hook (recommended) — runs verification on
.knowledge/files before each commit. Catches stale paths and broken references before they land. Install via the hook script inreferences/pre-commit-hook.sh. - None — rely on manual "verify the knowledge base" and "refresh
the knowledge base" commands.
Install the user's choice. If they pick the pre-commit hook, copy
references/pre-commit-hook.shto.git/hooks/pre-commitand make it executable. If the project already has a pre-commit hook, append the librarian check to it instead of overwriting.
- Pre-commit hook (recommended) — runs verification on
Verification pass
Launch an Explore agent to check every knowledge file against the actual codebase. The agent verifies: dead paths in terms/body, summary accuracy vs. file scope, bidirectional cross-references, factual claims vs. code, and frontmatter completeness.
Full agent prompt and trigger rules: references/verification-prompt.md.
Fix every issue the agent reports, then proceed to the index rebuild. This pass also runs during recording if more than 3 files were touched.
Refreshing
Triggered by "refresh the knowledge base" — for when the codebase changed significantly (big refactor, file moves, restructure) but existing knowledge is still conceptually valid.
Unlike bootstrap (starts from scratch) or verify (read-only check), refresh updates existing files in place while preserving decisions and context.
Steps:
- Run the verification pass — collect all issues (dead paths, stale claims, broken cross-references)
- For each dead path: scan the codebase for the renamed/moved equivalent.
Update the path in
termsfrontmatter and file body. If the file was deleted entirely, remove the reference. - For each stale claim: read the current code and update the fact.
- Check if any major new modules/files appeared that aren't covered by existing knowledge files. If so, create new files for them.
- Do not rewrite or remove
## Decisionssections — those are still valid unless the user says otherwise. - Rebuild
_index.md. - Summarize what changed: "Updated 12 paths across 3 files, added
new-module.md, removed 2 dead terms."
Project integration
The skill only works reliably if the project's CLAUDE.md enforces it.
Add this to the project's CLAUDE.md (see references/claude-md-snippet.md
for a copy-paste block):
- A directive to check
.knowledge/_index.mdbefore non-trivial tasks - A directive to record decisions after tasks that change architecture or introduce non-obvious patterns
- The three-system rule so contributors know what goes where
Without CLAUDE.md enforcement, the skill depends entirely on trigger matching from the description field — which will miss tasks that don't contain obvious keywords. CLAUDE.md is what makes this systematic instead of opportunistic.
During bootstrapping, offer to add these directives to the project's CLAUDE.md automatically. If CLAUDE.md doesn't exist yet, create it with the knowledge base directives plus any other project conventions discovered during the scan.
Conflict handling
When new information contradicts the knowledge base:
- Trust the new information — it reflects the latest decision
- Rewrite the file with current state at the top
- Move the old decision to
## Decisionswith a date and "superseded" note - Rebuild
_index.md
API Documentation Generator
Documentation
Automatically generates OpenAPI/Swagger API documentation.
Technical Writer
Documentation
Writes clear technical documentation following top style guides.
Create log entries with timestamps
Documentation
Creates timestamped log entries to document discoveries, meetings, code reviews, articles, or significant events. Structures information with a summary, event type, sources, and tags, then saves the file to `docs/log/` with a date-based filename and descriptive slug.