/audit
Audit the knowledge base for quality issues: missing frontmatter, broken links, tag inconsistencies, orphaned files, and coverage gaps. Works on any markdown-heavy project.
Steps
Parse focus area from $ARGUMENTS (optional). If provided, focus on that area (e.g., "tags", "frontmatter", "links"). If empty, run full audit.
Find all markdown files: Use Glob to find all .md files, excluding common non-content directories: .venv/, node_modules/, .git/, archive/, .archive_old/.
Frontmatter audit: First, scan a sample of existing files (first 10-20) to detect the frontmatter schema in use (which fields exist, what values are common for type and status). Then for each markdown file, check:
- Has YAML frontmatter (starts with
--- and has closing ---)
- Core fields present:
title, tags (and any other fields consistently used across the KB)
type and status values (if used) are consistent with the detected schema
tags is a non-empty list
Track files missing frontmatter and files with incomplete/invalid frontmatter.
Link check: Look for broken internal links:
- Grep for markdown links
\[.*\]\(.*\.md\) and verify each target file exists
- If a link-checking script exists in the project (e.g.,
scripts/check_links.py), run it as well
Tag consistency audit: Use Grep to find all tags: sections across .md files. Look for:
- Near-duplicate tags (e.g., "ai" vs "AI" vs "artificial-intelligence")
- Tags used only once (potential typos)
- Very common tags that might be too broad
List all unique tags with counts.
Orphaned files: Check which files are NOT referenced in any other file's related: field. Files that exist but are never cross-referenced may be orphaned.
Content quality: Find documents that appear to be ideas or opportunities (based on detected type field or directory location) and check:
- Documents still in
draft status for more than 30 days
- Documents missing key metadata fields that other similar documents have
- Documents with very little content (< 100 words, excluding frontmatter)
Coverage gaps: Check each directory for content:
- Flag any empty or near-empty directories
- Look for directories with only 1-2 files (may need more content)
Output report:
## KB Audit Report
**Date:** [today]
### Summary
- Total .md files: X
- With frontmatter: X (X%)
- Without frontmatter: X
### Frontmatter Issues
| File | Issue |
|------|-------|
| path | Missing field: type |
### Broken Links
[list of broken references]
### Tag Analysis
- Total unique tags: X
- Single-use tags: [list]
- Potential duplicates: [list]
### Orphaned Files
[files not referenced anywhere]
### Content Quality
- Stale drafts (> 30 days): [list]
- Missing metadata: [list]
- Low-content files: [list]
### Coverage
[directory analysis]
### Recommendations
1. [specific action]
2. [specific action]
3. [specific action]
Gotchas
- Single-use tags are not always typos — a tag used once might be intentional (e.g.,
event-2026 for a specific event). Flag but don't auto-merge without checking context.
- Orphaned files may be intentional archives — files in
3-inbox/ or 4-opportunities/ are often standalone by design. Only flag orphans in methodology or principles directories.
- Frontmatter schemas drift across directories —
0-principles/ uses type: principle, 3-inbox/ uses type: capture. Detect per-directory norms, don't enforce one schema globally.
related: field is not authoritative — many valid cross-references exist as inline markdown links [text](path.md), not just YAML related: arrays. Check both.
- Empty directories may be placeholders —
5-active-projects/ or 6-companies/ might be empty by design (populated by automation). Check registry.yaml or Makefile before flagging.
Common Issues
No markdown files found
Cause: Running in wrong directory or all files excluded.
Fix: Ensure you're in the knowledge base root. Check exclude patterns in step 2.
Too many single-use tags
Cause: Inconsistent tagging across documents.
Fix: Pick canonical tags from the most-used list. Run audit again after cleanup.
Frontmatter validation errors
Cause: YAML syntax issues (missing quotes, wrong indentation).
Fix: Ensure --- delimiters are present. Use type: and status: values consistent with your KB's detected schema.
1---2name: solo-audit3description: Use when "audit KB", "check frontmatter", "find broken links", "tag cleanup", "knowledge base quality", or docs need health check. Do NOT use for SEO audits (/seo-audit) or code reviews (/review).4license: MIT5---67# /audit89Audit the knowledge base for quality issues: missing frontmatter, broken links, tag inconsistencies, orphaned files, and coverage gaps. Works on any markdown-heavy project.1011## Steps12131. **Parse focus area** from `$ARGUMENTS` (optional). If provided, focus on that area (e.g., "tags", "frontmatter", "links"). If empty, run full audit.14152. **Find all markdown files:** Use Glob to find all .md files, excluding common non-content directories: `.venv/`, `node_modules/`, `.git/`, `archive/`, `.archive_old/`.16173. **Frontmatter audit:** First, scan a sample of existing files (first 10-20) to detect the frontmatter schema in use (which fields exist, what values are common for `type` and `status`). Then for each markdown file, check:18 - Has YAML frontmatter (starts with `---` and has closing `---`)19 - Core fields present: `title`, `tags` (and any other fields consistently used across the KB)20 - `type` and `status` values (if used) are consistent with the detected schema21 - `tags` is a non-empty list22 Track files missing frontmatter and files with incomplete/invalid frontmatter.23244. **Link check:** Look for broken internal links:25 - Grep for markdown links `\[.*\]\(.*\.md\)` and verify each target file exists26 - If a link-checking script exists in the project (e.g., `scripts/check_links.py`), run it as well27285. **Tag consistency audit:** Use Grep to find all `tags:` sections across .md files. Look for:29 - Near-duplicate tags (e.g., "ai" vs "AI" vs "artificial-intelligence")30 - Tags used only once (potential typos)31 - Very common tags that might be too broad32 List all unique tags with counts.33346. **Orphaned files:** Check which files are NOT referenced in any other file's `related:` field. Files that exist but are never cross-referenced may be orphaned.35367. **Content quality:** Find documents that appear to be ideas or opportunities (based on detected `type` field or directory location) and check:37 - Documents still in `draft` status for more than 30 days38 - Documents missing key metadata fields that other similar documents have39 - Documents with very little content (< 100 words, excluding frontmatter)40418. **Coverage gaps:** Check each directory for content:42 - Flag any empty or near-empty directories43 - Look for directories with only 1-2 files (may need more content)44459. **Output report:**46 ```47 ## KB Audit Report4849 **Date:** [today]5051 ### Summary52 - Total .md files: X53 - With frontmatter: X (X%)54 - Without frontmatter: X5556 ### Frontmatter Issues57 | File | Issue |58 |------|-------|59 | path | Missing field: type |6061 ### Broken Links62 [list of broken references]6364 ### Tag Analysis65 - Total unique tags: X66 - Single-use tags: [list]67 - Potential duplicates: [list]6869 ### Orphaned Files70 [files not referenced anywhere]7172 ### Content Quality73 - Stale drafts (> 30 days): [list]74 - Missing metadata: [list]75 - Low-content files: [list]7677 ### Coverage78 [directory analysis]7980 ### Recommendations81 1. [specific action]82 2. [specific action]83 3. [specific action]84 ```8586## Gotchas87881. **Single-use tags are not always typos** — a tag used once might be intentional (e.g., `event-2026` for a specific event). Flag but don't auto-merge without checking context.892. **Orphaned files may be intentional archives** — files in `3-inbox/` or `4-opportunities/` are often standalone by design. Only flag orphans in methodology or principles directories.903. **Frontmatter schemas drift across directories** — `0-principles/` uses `type: principle`, `3-inbox/` uses `type: capture`. Detect per-directory norms, don't enforce one schema globally.914. **`related:` field is not authoritative** — many valid cross-references exist as inline markdown links `[text](path.md)`, not just YAML `related:` arrays. Check both.925. **Empty directories may be placeholders** — `5-active-projects/` or `6-companies/` might be empty by design (populated by automation). Check `registry.yaml` or Makefile before flagging.9394## Common Issues9596### No markdown files found97**Cause:** Running in wrong directory or all files excluded.98**Fix:** Ensure you're in the knowledge base root. Check exclude patterns in step 2.99100### Too many single-use tags101**Cause:** Inconsistent tagging across documents.102**Fix:** Pick canonical tags from the most-used list. Run audit again after cleanup.103104### Frontmatter validation errors105**Cause:** YAML syntax issues (missing quotes, wrong indentation).106**Fix:** Ensure `---` delimiters are present. Use `type:` and `status:` values consistent with your KB's detected schema.