From just-useful-plugin
Use when asked to verify docs match code, after structural changes needing doc updates, periodic doc maintenance, detecting stale docs, doc consistency checks, doc gardening, knowledge base structure design, CLAUDE.md authoring/refactoring
How this skill is triggered — by the user, by Claude, or both
Slash command
/just-useful-plugin:garden-docsThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Process for keeping docs in sync with code and maintaining the knowledge base as a **system of record**.
Process for keeping docs in sync with code and maintaining the knowledge base as a system of record.
CLAUDE.md (or AGENTS.md) should contain only a table of contents. All context for agents to read must live in the docs/ knowledge base.
| Location | Role |
|---|---|
| CLAUDE.md | ~100-line table of contents. Contains only conditional triggers pointing to docs/ files. Target ≤ 500 tokens (wc -w ≤ ~375 words) |
| docs/ | All context. Architecture, conventions, design docs, execution plans, etc. |
"It's short enough to keep in CLAUDE.md" is a rationalization. Whether it's a 1-line project overview, 5-line convention, or behavior rule — all context belongs in docs/. CLAUDE.md should only contain triggers pointing to the relevant docs/ file.
Every token loaded into context competes for the model's attention. Bloated context makes agents dumber, not smarter.
| Target | Budget |
|---|---|
| CLAUDE.md | ≤ 500 tokens (~375 words). Measure with wc -w |
| docs/ file | ≤ 200 lines each. Split if larger |
| Enforceable rules | Do NOT document in CLAUDE.md or docs/. Delegate to linter/formatter. One trigger suffices: Run \lint:fix` after changes` |
Rules that linters, formatters, or type checkers can enforce (indentation, quotes, line length, import ordering) waste tokens when written in docs. The tool config is the documentation.
Every instruction competes with every other instruction for the model's reasoning priority. Low-value instructions dilute the effectiveness of existing ones.
Decision rule: "Does this prevent a specific, nameable agent mistake that justifies its token cost?"
When removing instructions: deleting a low-value instruction improves every remaining instruction. Pruning is a force multiplier, not a loss.
| Red Flag | Reality |
|---|---|
| "This is important context" | Important to whom? Name the agent mistake it prevents, or delete it |
| "Better to have it and not need it" | Every token you don't need actively harms the tokens you do need |
Each CLAUDE.md entry must specify when to read it. Simple pointers (path + description) won't be read by agents.
# ❌ Simple pointer — agents won't read this
## References
- [Architecture Details](docs/architecture.md): Directory structure and layer relationships
- [Conventions](docs/conventions.md): Coding rules and workflows
# ✅ Conditional trigger — agents actually read this
## References
- When understanding project structure → read `docs/architecture.md`
- When adding/modifying skills or plugins → read `docs/conventions.md`
- When checking MCP server integration → see `docs/mcp-servers.md`
- When working on tech debt → check `docs/exec-plans/tech-debt-tracker.md`
The difference: Simple pointers say "this exists." Conditional triggers say "read this when." Agents act on instructions, not awareness.
Context should flow through layers, not be dumped all at once. Apply a 3-layer architecture to both triggers and docs/ structure:
| Layer | What | Token Cost | When Loaded |
|---|---|---|---|
| Index | CLAUDE.md triggers, docs/index.md routing map | ~500 tokens | Always |
| Details | docs/*.md (architecture, conventions) | ~200 lines each | On trigger match |
| Deep Dive | docs/deep-dive/*.md, docs/design-docs/*.md | Unlimited | On explicit need from Details |
Trigger format with layers:
# ❌ Flat — agent reads entire file, no path to deeper context
- When understanding layer boundaries → read `docs/architecture.md`
# ✅ Layered — agent targets section, can go deeper if needed
- When understanding layer boundaries → read `docs/architecture.md` §Layer Dependencies
# Deep dive available: `docs/deep-dive/layer-dependency-rationale.md`
Rules for section hints (§):
§ followed by the section heading name (matching the ## or ### heading in the doc)Vague triggers fire too broadly or not at all. Each trigger condition must match an observable agent action, not an abstract intent.
# ❌ Vague — "understanding" is not an observable action
- When understanding the project → read `docs/architecture.md`
# ❌ Too broad — fires on every file touch
- When working on the project → read `docs/conventions.md`
# ✅ Specific — matches observable file access patterns
- When modifying src/middleware/ or adding new API routes → read `docs/architecture.md` §Middleware Layer
- When adding/modifying skills or updating plugin metadata → read `docs/conventions.md`
Self-test: for each trigger, ask "can I name a specific file or command that would cause this to fire?" If not, the trigger is too vague.
All context that agents need to read lives here. Structure docs/ for progressive disclosure — agents should read a routing map first, then dive into specific files.
docs/
├── index.md # Routing map — what's in each file, when to read it
├── architecture.md # ≤ 200 lines. Project structure, layer boundaries
├── conventions.md # ≤ 200 lines. Coding rules, workflows
├── design-docs/ # Design documents (navigated via index.md)
├── deep-dive/ # Detailed context, accessed only from Details-layer docs
│ ├── auth-flow.md
│ └── data-model.md
├── exec-plans/ # Execution plans
│ ├── active/ # In progress
│ ├── completed/ # Done
│ └── tech-debt-tracker.md
├── generated/ # Auto-generated docs (DB schemas, etc.)
├── product-specs/ # Product specs
└── references/ # External references (LLM-friendly docs, etc.)
docs/generated/: Auto-generated files (DB schemas, API specs, type exports). Each file must include a generation command header: <!-- Generated by: npm run gen:schema -->. Never edit generated files directly — modify the generation source instead. CLAUDE.md triggers should never point directly to generated/ files.
docs/references/: LLM-friendly documentation for external dependencies (e.g., uv-llms.txt, prisma-reference.md). Include only for dependencies where agents frequently make API misuse errors. Each file must have a source header: <!-- Source: https://... | Fetched: 2026-03-15 -->. Keep under 200 lines — extract only sections relevant to this repo's usage patterns. Naming: {library}-llms.txt or {library}-reference.md.
Cross-cutting concern docs (large repos only): For concerns that span multiple domains, create dedicated docs files (e.g., docs/SECURITY.md, docs/RELIABILITY.md, docs/DESIGN.md). Each document should: (1) define the principles for that concern, (2) grade compliance per module/domain, (3) list known gaps. Access via conditional triggers: When modifying auth or data access → read docs/SECURITY.md. Create these only when cross-domain agent mistakes have actually occurred — do not create preemptively.
docs/index.md is optional but recommended for repos with 5+ docs/ files. It serves as a routing map that agents consult before reading individual docs. CLAUDE.md triggers should point to specific docs/ files, not to index.md.
docs/deep-dive/ files should NOT appear in CLAUDE.md triggers. They are referenced from within Details-layer docs (architecture.md, conventions.md, etc.) when an agent needs to go deeper.
For repos with 5+ docs/ files, track document health using verification status and quality grades.
Verification status:
Quality grades:
Add optional frontmatter to docs/ files to track health:
---
verified: 2026-03-15
grade: B
covers: skills/garden-docs/
---
Health tracking integrates with existing workflows:
Grade column alongside Statusverified date is within 3 months; flag any C/F grade docs for remediationstale status triggers the Staleness Remediation workflowIn monorepos, follow the inheritance model. Root CLAUDE.md triggers and rules automatically apply to all workspaces. Workspace CLAUDE.md should only add triggers for its own scope — never repeat what's in root.
| Item | Root CLAUDE.md | Workspace CLAUDE.md |
|---|---|---|
| Shared docs/ triggers | ✅ | ❌ (inherited) |
| Workspace-specific docs/ triggers | ❌ | ✅ |
| Shared behavior rule triggers | ✅ | ❌ (inherited) |
| Workspace-specific rule triggers | ❌ | ✅ |
monorepo/
├── CLAUDE.md # Shared triggers
├── docs/ # Shared knowledge base (context needed by 2+ workspaces)
├── apps/
│ ├── web/
│ │ ├── CLAUDE.md # web-specific triggers
│ │ └── docs/ # web-specific knowledge base
│ └── api/
│ ├── CLAUDE.md
│ └── docs/
└── packages/
└── ui/
├── CLAUDE.md
└── docs/
"Where does this context/trigger go?"
docs/ + root CLAUDE.md triggerdocs/ + workspace CLAUDE.md trigger# ❌ Duplicating root trigger in apps/web/CLAUDE.md
## References
- When understanding project structure → `../../docs/architecture.md` ← already in root
- When modifying routing logic → read `docs/routing.md`
# ✅ Workspace-specific triggers only
## References
- When modifying routing logic → read `docs/routing.md`
| Pattern | Problem | Fix |
|---|---|---|
| Inline context in CLAUDE.md | Loses table-of-contents role | Move all context to docs/ |
Simple pointers [Title](path): description | Agents won't read them | Use conditional triggers when ~ → path |
| 200+ line CLAUDE.md | Context overload | Compress to ~100-line TOC (≤ 500 tokens) |
| "Short enough to inline" | Exceptions pile up into bloat | No exceptions. Everything in docs/ |
| Speculative rules | Noise | Add only on agent mistakes. Review for deletion if unviolated for 3 months |
| LLM-generated docs | -3% success rate, +20% cost | Human-written only. Add on actual agent mistakes |
| Linter rules in docs | Wasted tokens | Delegate to tooling. One trigger: Run lint:fix |
| Vague trigger conditions | Won't fire or fires too broadly | Reference observable actions: file paths, commands |
| Flat docs/ without layers | Agent reads everything | Use Index → Details → Deep Dive layers |
| Stale docs trusted silently | Silent agent failures | Context rot detection in [0] |
| Editing generated docs directly | Overwritten on next generation | Modify the generation source instead |
| Knowledge only in external systems | Agents can't access it | Encode in repo |
| Root-workspace trigger duplication | Fix one, the other drifts | Once in root only. Workspaces inherit |
| Copying shared rules to workspaces | Can't stay in sync | Manage in root docs/ |
| Workspace-specific context in root | Noise for unrelated workspaces | Move to that workspace's docs/ |
| Layer | Target Files | Key Question |
|---|---|---|
| L4: Meta | marketplace.json, plugin.json | Machine-parseable? |
| L3: Skills | SKILL.md, references/ | Does it drive correct behavior? |
| L2: AI Context | CLAUDE.md, AGENTS.md | TOC-only structure? Are triggers valid? |
| L1: Entry Point | README.md | Can someone install and get started? |
If the main agent runs checklists directly, reading many files bloats context and reduces focus. Delegate verification to subagents; the main agent synthesizes results.
Main Agent Subagents
─────────── ──────────
[0] Check change history via git log
│
[1] Dispatch ALL 3 subagents (mandatory)
├──dispatch──→ SubA: L4 Meta + L3 Skills
├──dispatch──→ SubB: L2 AI Context
└──dispatch──→ SubC: L1 Entry Point + Cross-references
│
[2] GATE: Confirm all 3 subagents returned results
│
[3] Synthesize report & apply fixes
│
[4] Re-dispatch subagents for changed layers
│
[5] GATE: Final all-layer status confirmed
Subagent dispatch rules (MANDATORY — not advisory):
Issues Found table format from the report template belowGrouping rationale:
Run git log before reviewing. Do not rely on memory. Always run the commands.
# Recent structural changes (files added/deleted/renamed)
git log --oneline --diff-filter=ADR --name-status --since="2 weeks ago"
# Last modified date for each doc (run individually per file)
git log --format='%ar %s' -1 -- CLAUDE.md
git log --format='%ar %s' -1 -- README.md
Context Rot Detection: Stale docs cause silent failures when agents trust outdated information. Check for docs that haven't been updated while their referenced source code has changed.
# Find docs/ files not modified in 3+ months
find docs/ -name "*.md" -exec sh -c 'echo "$(git log --format=%ar -1 -- "$1") $1"' _ {} \;
# Find source files modified in the last 3 months (compare against stale docs)
git log --since="3 months ago" --name-only --pretty=format: -- src/ | sort -u | head -20
If a docs/ file hasn't been modified in 3+ months but the source code it references has changed, flag it as stale in the subagent prompt. SubB must verify whether the content is still accurate.
Staleness Remediation: When stale docs are found, classify each into an action category:
| Category | Criteria | Action |
|---|---|---|
| Update | Content outdated but structure sound | Fix directly — update sections to match current code |
| Rewrite | Structure no longer matches codebase (grade F) | AskUserQuestion — human must restructure |
| Delete | Covers deleted code/features | AskUserQuestion — confirm deletion + remove CLAUDE.md triggers |
Include a Staleness Remediation table in the report ([3]):
### Staleness Remediation
| Doc | Category | Source Changes | Action |
|-----|----------|---------------|--------|
| docs/architecture.md | Update | src/middleware/ restructured | Update §Middleware Layer |
| docs/old-feature.md | Delete | feature/ removed (abc123) | Delete doc + remove trigger |
Include change history and staleness flags in subagent prompts. Subagents cross-check whether each change is reflected in docs.
Coverage Inventory: After change history, inventory the repo to understand what exists vs what docs/ covers. This is the foundation for coverage gap detection.
# Inventory: top-level directories and key files
ls -1
# Inventory: significant subdirectories (skills, plugins, src, etc.)
find . -maxdepth 2 -type d -not -path './.git/*' -not -path './node_modules/*'
# Inventory: what docs/ currently covers
ls -1 docs/ 2>/dev/null
# Inventory: key config/entry files
ls -1 *.json *.md *.yml *.yaml 2>/dev/null
Build a Coverage Map — a table of "repo areas" vs "docs/ coverage":
Coverage Map:
| Repo Area | Covered By | Grade | Status |
|------------------------|----------------------|-------|------------|
| skills/garden-docs/ | docs/conventions.md | B | ✅ covered |
| skills/agent-benchmark/| (none) | — | ❌ gap |
| Plugin structure | docs/architecture.md | A | ✅ covered |
| Build/CI pipeline | (none) | — | ❌ gap |
What counts as a "repo area": any directory, module, or significant subsystem that an agent might need context about when working in this repo. Use judgment — a utility file doesn't need its own doc, but a major feature directory does.
Include the Coverage Map in SubB's prompt. Gaps flagged here become coverage issues in SubB's report.
Progress updates (adapt to user's language):
After [0]:
[Step 0 complete] Change history + coverage inventory done. Dispatching 3 subagents for L4–L1 layer verification.
After [2] gate passes:
[Step 2 complete] All 3 subagents returned. Synthesizing results.
After [4]:
[Step 4 complete] Re-verification done. Preparing final status.
L4: Meta File Verification
marketplace.json == actual subdirectory count under plugins/.claude-plugin/plugin.json.mcp.jsonplugin.json name field == directory namemarketplace.json description semantically matches plugin.json descriptionL3: Skill Document Verification
skills/ contains SKILL.mdSKILL.md has YAML frontmatter (name, description)name == directory name.mcp.json (excluding built-in tools)references/ are referenced from SKILL.md (no orphan files)references/ files referenced in SKILL.md actually exist (no broken references)TOC Structure & Token Budget:
wc -w ≤ ~375 words)when ~ → path) — not simple pointers ([Title](path): description)?Trigger Quality:
docs/deep-dive/ files are NOT directly referenced from CLAUDE.md triggers?Consistency:
.mcp.json?Freshness (Context Rot):
verified frontmatter: is the date within 3 months?Coverage Completeness (use Coverage Map from [0]):
Self-test for substantive content: Read each docs/ file and ask "if I were an agent modifying code in this area, would this doc prevent me from making a wrong assumption?" If the answer is no, the doc needs improvement — not just existence.
Health:
L1: Entry Point Verification
marketplace.jsonplugin.json descriptionCross-reference Verification
Before synthesizing, verify:
If any subagent failed or was not dispatched, re-dispatch it now. Do NOT proceed with partial results.
Synthesize subagent results into a single report. If issues are found, use AskUserQuestion to confirm fix scope before proceeding.
## Document Gardening Report (YYYY-MM-DD)
### Review Scope
- L4 Meta: ✅/❌
- L3 Skills: ✅/❌
- L2 AI Context: ✅/❌
- L1 Entry Point: ✅/❌
- Cross-references: ✅/❌
- Coverage: ✅/❌
### Issues Found
| # | Layer | File | Issue | Severity | Token Impact |
|---|-------|------|-------|----------|-------------|
| 1 | L2 | CLAUDE.md | Conventions written inline | High | +2,400 tokens/session |
| 2 | L2 | CLAUDE.md | docs/ references are simple pointers | High | — (behavioral) |
| 3 | L2 | docs/arch.md | 350 lines, no § hints in triggers | Med | +800 tokens (full file read) |
| 4 | L2 | docs/style.md | Linter-enforceable rules documented | Med | +600 tokens (wasted) |
### Coverage Gaps
| # | Repo Area | Why It Needs Docs | Proposed Action |
|---|-----------|-------------------|-----------------|
| 1 | skills/agent-benchmark/ | Agents modifying benchmark need metric definitions | Create docs/agent-benchmark.md or add § to existing doc |
| 2 | Build/CI pipeline | Agent may break CI without understanding pipeline | Add §CI to docs/conventions.md |
Token Impact estimates the per-session cost of the issue. Use wc -w on the affected content to estimate. Issues that waste tokens get priority over purely behavioral issues.
Severity criteria:
The urge to downgrade severity is itself a Red Flag. "This repo is special", "this level is fine" are rationalizations. Judge by the criteria.
Fix principles:
AskUserQuestion to present the fix plan and get approval:
AskUserQuestion (adapt to user's language): "I'd like to apply these fixes:
1. [High] Move inline context from CLAUDE.md to docs/conventions.md
2. [Med] Split docs/architecture.md to stay under 200 lines
Proceed? Let me know if you want to skip or modify any items."
After applying fixes, re-dispatch subagents for every layer that had changes:
Do NOT skip this step. "I can see the fix is correct" is a rationalization.
Before declaring the review complete, confirm every layer has a final status:
Final Status:
- L4 Meta: ✅ verified / ❌ issues remain (list)
- L3 Skills: ✅ verified / ❌ issues remain (list)
- L2 AI Context: ✅ verified / ❌ issues remain (list)
- L1 Entry Point: ✅ verified / ❌ issues remain (list)
- Cross-references: ✅ verified / ❌ issues remain (list)
- Coverage: ✅ all gaps addressed / ❌ gaps remain (list)
Completion requires ALL layers to have a status. A missing status means you skipped a layer — go back and verify it. Report this final status to the user.
| Thought | Reality |
|---|---|
| "Too few files to bother reviewing" | Fewer files = higher impact per error |
| "No structural changes, should be fine" | Run git log. Don't rely on memory |
| "Just need to fix CLAUDE.md" | Always review all layers L4→L3→L2→L1 |
| "This inconsistency is minor" | The urge to downgrade severity is itself a Red Flag |
| "Fixed it, no need to re-verify" | Fixes can introduce new inconsistencies. Re-verify |
| "It's short, keep it in CLAUDE.md" | No exceptions. All context goes in docs/ |
| "Behavior rules belong inline" | Behavior rules go in docs/ too. CLAUDE.md holds triggers only |
| "This repo is special" | No repo is special. Principles are universal |
| "Just listing the docs/ path is enough" | Without conditional triggers, agents won't read it |
| "Better add a rule just in case" | Speculative rules are noise. Add only on mistakes |
| "Copy to all workspaces" | Duplication always drifts |
| "The docs haven't changed, so they're fine" | Source code may have changed. Run context rot detection |
| "Let Claude generate the architecture doc" | LLM-generated docs degrade performance. Human-written only |
| "More context = more helpful" | More context = more noise. Every token competes for attention |
| "This trigger is clear enough" | If you can't name a file that fires it, it's too vague |
| "I'll just fix the obvious issues" | Partial fix without full review = incomplete gardening. Run ALL layers |
| "This repo is small, I'll check inline" | Subagent dispatch is mandatory regardless of repo size. HARD-GATE rule |
| "I've created the missing docs, done" | Creating files is step [3]. You still need [4] re-verify and [5] final status |
| "Only L2 is relevant here" | ALL layers must be verified. Relevance is determined by subagents, not skipped by assumption |
| "SubC can be skipped, no cross-ref changes" | Dispatch all 3. Subagents decide what's relevant, not you |
| "Existing docs cover the repo well enough" | Did you build a Coverage Map? Without inventory, you're guessing |
| "This area doesn't need docs" | If an agent might work there and make wrong assumptions, it needs docs |
| "I listed the directory structure, that's docs" | Directory trees are not documentation. Explain WHY/HOW, not just WHAT |
| "I created the missing files, coverage is done" | Creating files ≠ substantive content. Self-test: would this prevent wrong assumptions? |
AskUserQuestion: Fix plan confirmation, knowledge base structure change approval — any point requiring user decisionGlob: Check file existenceGrep: Search references in docs, detect duplicate content, find orphan docs/ filesRead: Verify doc contentsEdit: Modify docsBash (git log): Last modified dates, structural change history, context rot detectionBash (wc -l): Measure CLAUDE.md line countBash (wc -w): Measure CLAUDE.md token budget (~words ≈ tokens)Bash (find + git log): Context rot detection — compare doc freshness vs source changesnpx claudepluginhub identity16/just-useful-plugin --plugin just-useful-pluginOptimizes CLAUDE.md hierarchies, .claude/rules, ecosystem files, and docs/ folders per Anthropic best practices. Detects redundancies, conflicts, and suggests improvements.
Audits documentation against source code using git-based staleness detection. Run with no args for smart check or specify a path. Supports full audit, auto-fix, and check-only modes.
Audits CLAUDE.md, rules, and memory files for stale references, orphaned content, contradictions, duplicates, misplacement, budget overruns, and unenforced claims.