agentleFS
ravidsrkravidsrk/agent-skills/skills/knowledge-maintenance/SKILL.md

knowledge-maintenance

Skill1 starsChanged 21 days agoMITView on GitHub

Audit and repair a markdown knowledge base — missing or malformed frontmatter, broken wikilinks, orphan pages, stale pages, duplicate titles, oversized pages, and taxonomy drift. Use when the user asks to "check brain health", "audit my notes", "fix broken links", "find stale pages", "clean up my knowledge base", or after a large import.

2 other projects use a version of this.

Adopted by

Most recently taken up by

The file

Show its rules and text

We split this skill into the rules it gives an agent

16 rules. About 0 are common, 10 are distinctive, and 6 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈10

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 6

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    After a large import, a rename, or a month of captures

    line 31
  2. Distinctive:

    Before relying on the base for a decision

    line 32
  3. Distinctive:

    If the base is a git repo, commit or stash first.

    line 60
  4. Distinctive:

    Do not batch-fix a category you have not read.

    line 103
  5. Very specific:

    Add missing title, type, slug, captured_at, content_hash.

    line 109
  6. Distinctive:

    If the target exists under a new slug, update the link.

    line 115
  7. Distinctive:

    If the target is a person/company that should exist, create the page and add the backlink.

    line 116
  8. Very specific:

    If the target is obsolete, remove the link or point it at archive/.

    line 117
  9. Distinctive:

    Do not delete a page to silence a link.

    line 118
  10. Very specific:

    If they are genuinely isolated, move them to archive/ or delete them after confirmation.

    line 123
  11. Distinctive:

    Read the page and its timeline.

    line 128
  12. Very specific:

    If the page is historical, set status: archived or move it to archive/.

    line 130
  13. Very specific:

    Do not merely bump updated_at.

    line 131
  14. Distinctive:

    Leave a redirect or an alias in the old page.

    line 137
  15. Distinctive:

    Keep a hub page that links to the parts.

    line 143
  16. Very specific:

    Add a new type only when at least ten pages share the shape.

    line 182

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Knowledge Maintenance

A knowledge base degrades quietly: captures pile up with missing frontmatter, links point at renamed pages, entities become orphans, and old decisions stay on the front page after newer evidence lands. This skill makes the decay visible and fixes it one category at a time.

The audit script is generic and standard-library-only. If gbrain is installed, its schema, taxonomy, and embedding checks can run in addition.

When to use

  • "Check my brain health"
  • "Audit my notes / knowledge base"
  • "Find broken links" / "find orphan pages"
  • "What is stale?"
  • "Clean up frontmatter"
  • "The taxonomy is a mess"
  • After a large import, a rename, or a month of captures
  • Before relying on the base for a decision

When NOT to use

  • The base has fewer than ten pages; read them directly.
  • The user wants a content rewrite, not a structural audit.
  • A page is intentionally unlinked (a scratchpad); mark it as exempt instead of "fixing" it.
  • A destructive cleanup without a backup; always snapshot first.

Setup

export KB_ROOT="${KB_ROOT:-$HOME/brain}"
python3 --version

Optional gbrain:

gbrain doctor --json
gbrain schema stats --json
gbrain frontmatter audit --json

The workflow

Step 1 — Snapshot

If the base is a git repo, commit or stash first. If it is not, copy it or create a tar archive. Never run a repair on the only copy.

git -C "$KB_ROOT" status --short
git -C "$KB_ROOT" add -A && git -C "$KB_ROOT" commit -m "chore: snapshot before KB audit"

Step 2 — Audit

python3 scripts/kb-audit.py --root "$KB_ROOT"

Machine-readable:

python3 scripts/kb-audit.py --root "$KB_ROOT" --json > audit.json

The audit is read-only. It reports:

CodeSeverityMeaning
missing_frontmattererrorNo opening/closing --- block
empty_frontmattererrorOpening and closing present but nothing between
frontmatter_parse_errorerrorMalformed YAML (unterminated quote/array, unknown line)
missing_required_fielderrorslug, captured_at, or content_hash is missing
missing_titleerrorNo frontmatter title or H1
missing_typewarnFrontmatter has no type
slug_mismatcherrorFrontmatter slug differs from the path
broken_wikilinkerror[[target]] resolves to no page
broken_asseterrorA local image/PDF/file link does not exist
read_errorerrorThe page could not be read (permissions/encoding)
invalid_datewarnupdated_at / captured_at is not parseable
stale_pagewarnOlder than --stale-days (default 90)
orphan_pagewarnNo inbound links
duplicate_titlewarnTwo pages share a normalized title
oversized_pagewarnMore than --max-lines (default 500)

Step 3 — Triage

Fix errors first, then warnings. Within a category, fix the highest-traffic pages first: index.md, entity pages, and pages with many inbound links.

Do not batch-fix a category you have not read. A "broken" link may be a deliberate reference to a page you are about to create.

Step 4 — Repair, one category at a time

Frontmatter

  • Add missing title, type, slug, captured_at, content_hash.
  • Fix YAML quoting. A title with a colon or quote must be quoted and escaped.
  • Fix slug mismatches by updating the frontmatter to the path-derived slug, not by renaming the file (unless the rename is intentional).

Broken links

  • If the target exists under a new slug, update the link.
  • If the target is a person/company that should exist, create the page and add the backlink.
  • If the target is obsolete, remove the link or point it at archive/.
  • Do not delete a page to silence a link.

Orphans

  • Link them from the relevant index, entity, or project page.
  • If they are genuinely isolated, move them to archive/ or delete them after confirmation.
  • Exempt inbox/, archive/, README.md, and index.md from the orphan check.

Stale pages

  • Read the page and its timeline.
  • Rewrite the synthesis if newer evidence exists.
  • If the page is historical, set status: archived or move it to archive/.
  • Do not merely bump updated_at.

Duplicate titles

  • Pick the canonical page.
  • Merge the content.
  • Leave a redirect or an alias in the old page.
  • Update inbound links.

Oversized pages

  • Split by subject, not by line count.
  • Keep a hub page that links to the parts.
  • Move reference material to references/ or originals/.

Step 5 — Re-run

python3 scripts/kb-audit.py --root "$KB_ROOT" --fail-on error

The repair is done when the same findings are gone, not when the count happens to drop.

Step 6 — Report

## Knowledge Base Health — YYYY-MM-DD

| Dimension | Found | Fixed | Remaining |
|---|---:|---:|---:|
| Missing frontmatter | 4 | 4 | 0 |
| Broken links | 9 | 7 | 2 |
| Orphans | 6 | 3 | 3 |
| Stale pages | 12 | 5 | 7 |
| Duplicate titles | 2 | 2 | 0 |
| Oversized pages | 1 | 0 | 1 |

### Needs a human
- ...

Store the report with the base or in the PR. It is the audit trail.

Schema and taxonomy

A large base needs a small vocabulary:

  • Page types: note, article, meeting, person, company, concept, idea, project, reflection, source, report.
  • Prefixes: people/, companies/, meetings/, concepts/, ideas/, projects/, originals/, voice-notes/.
  • Link verbs: works_at, founded, invested_in, advises, attended, mentions, source.

Add a new type only when at least ten pages share the shape. See references/taxonomy.md.

Cadence

CadenceCheck
Every capturefrontmatter + one backlink
Weeklyinbox triage, broken links, orphans
Monthlystale pages, duplicate titles, oversized pages
Quarterlytaxonomy, schema, archive review
After a rename/importfull audit

Common gotchas

GotchaFix
Audit flags an intentional unlinked scratchpadMove it to inbox/ or add an exemption
Slug mismatch after a renameUpdate the frontmatter slug; links still need updating
Orphan count explodes after an importLink the new pages from an index before re-running
Stale flag on historical minutesMark historical pages status: archived
Duplicate titles are legitimate (two "Weekly review" pages)Include the date in the title
Repair deletes contentNever delete without confirmation; snapshot first
YAML fix breaks a pageValidate one file at a time; keep the backup
gbrain and plain-markdown counts disagreeThey scan different roots/sources; report the root explicitly

References

  • references/health-checks.md — every dimension, threshold, and repair action
  • references/frontmatter-schema.md — fields, validation classes, YAML traps
  • references/taxonomy.md — page types, prefixes, link verbs, merge rules
  • scripts/kb-audit.py — read-only audit with Markdown and JSON output

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.