AgentSkillsCN

doc-hygiene

保持文档的整洁规范——杜绝漂移规则、消除冗余计数,让文档常读常新。

SKILL.md
--- frontmatter
name: doc-hygiene
description: Documentation hygiene — anti-drift rules, count elimination, and living document maintenance

Documentation Hygiene

Prevent documentation drift through structural rules — not manual vigilance.

The Count Problem

Hardcoded counts (e.g., "109 skills", "28 instructions", "6 agents") in prose become stale within days during active development. Every count is a future bug.

Rules

RuleDoDon't
No counts in prose"See the skills catalog for the current list""Alex has 109 skills"
Counts in tables OKTables with `Count
Single source of truthOne canonical location per metricSame count in 5 files
Link, don't copy"See [SKILLS-CATALOG.md]"Duplicate the catalog inline
Timestamp proximityCounts near a "Last Updated" date are acceptableUndated counts

Canonical Sources

The filesystem is always the source of truth. Derive counts from directories, not from prose.

MetricCanonical SourceWhy
Skill count.github/skills/ directory count (or generated catalog if present)Filesystem is truth
Instruction count.github/instructions/ directory listingFilesystem is truth
Prompt count.github/prompts/ directory listingFilesystem is truth
Agent count.github/agents/ directory listingFilesystem is truth
Muscle count.github/muscles/ directory listingFilesystem is truth
Command countpackage.json contributes.commands (if applicable)Code is truth
Synapse countBrain QA validation outputValidated at runtime

Acceptable Count Locations

Counts are tolerated (not encouraged) in these specific locations because they serve as dashboards:

FilePurposeUpdate Cadence
copilot-instructions.md Memory Stores tableAI working contextPer release
ROADMAP-UNIFIED.md Current StateRelease trackingPer release
README.md architecture treeUser-facing overviewPer release

All other files should use descriptive references instead of counts.

Document Freshness

Staleness Indicators

SignalAction
Count doesn't match filesystemFix count or replace with reference
"Last Updated" older than 30 days on living docReview for accuracy
Version number doesn't match current releaseUpdate or archive
References to removed/renamed filesFix or remove reference

Living vs Historical Documents

TypeExamplesCount Policy
LivingREADME, copilot-instructions, ROADMAP, USER-MANUALMinimize counts; keep current
HistoricalResearch papers, competitive analyses, archived docsCounts are snapshots — leave as-is
GeneratedSKILLS-CATALOG, TRIFECTA-CATALOGCounts are output of audit — OK

Docs-as-Architecture

Documentation in a cognitive architecture IS architecture. Apply the same engineering rigor to docs that you would to code:

Code ConceptDocs Equivalent
Broken importBroken cross-reference link
Stale dependencyStale count or version number
Orphan moduleFile not linked from any index
Circular dependencyTwo files claiming to be source of truth
Dead codeArchived content still linked from living docs

Principle: If a doc change would break another doc's accuracy, it's a breaking change. Treat it as such.

Link Integrity

Rules

RuleEnforcement
Every markdown link in living docs must resolveGrep + verify during audit
Every important file in a folder should be linked from its README.mdOrphan check
Moving a file requires updating ALL references in the same commitGrep for filename in all .md files before moving
Archived docs removed from active indexesDon't link to archive/ from living docs
Use relative paths within doc trees./architecture/FILE.md not absolute paths

Orphan Detection

A file is orphaned if it exists in a doc folder but is not referenced by any index or parent document. Orphans are either:

  • Forgotten knowledge → add to appropriate index
  • Stale artifacts → archive or delete

Consolidation Protocol

When reorganizing documentation:

  1. Plan the target structure — Define subdirectories by audience/purpose
  2. Grep before moving — Find ALL references to files being moved
  3. Move + update in one operation — Never leave broken references, even briefly
  4. Verify post-move — Re-run link integrity check after consolidation
  5. Update indexes — All README.md index files must reflect the new structure

Standard Directory Structure

Adapt this pattern to your project. The key is audience-separated folders:

Directory PatternAudienceContent Type
docs/guides/UsersHow-to, setup, reference cards
docs/architecture/Developers + AISystem design, catalogs, mapping
docs/features/DevelopersFeature specs, gap analyses
docs/platforms/Platform devsHeir-specific documentation
docs/operations/MaintainersChecklists, processes, audits
docs/research/StrategistsPapers, competitive analysis
docs/archive/HistoricalSuperseded or completed docs

Multi-Audience Awareness

Different documentation serves different readers. Misplacing content wastes everyone's time.

AudienceNeedsStyle
End UsersSetup, commands, quick referenceStep-by-step, minimal jargon
DevelopersArchitecture, APIs, extension pointsConceptual + code examples
AI (Alex brain)Skills, instructions, promptsTerse, structured, action-oriented
ContributorsOnboarding, conventions, governanceProcedural, welcoming

Rule: Before writing, ask "Who reads this?" and place it accordingly.

Multi-Layer Documentation Strategy

Complex topics benefit from layered depth:

LayerPurposeExample
Executive summary30-second overviewREADME.md intro paragraph
Visual diagramSpatial understandingMermaid diagrams, architecture charts
Detailed inventoryComprehensive referenceSKILLS-CATALOG, AGENT-CATALOG
Code-level detailImplementation specificsInline comments, SKILL.md files

Not every topic needs all four layers, but important architecture should have at least summary + detail.

Timing: Ship First, Document After

Skills and patterns written after successful real-world delivery are worth 10x those written from theory. The recommended flow:

  1. Build it — Get the feature working
  2. Ship it — Validate in real usage
  3. Document it — Capture battle-tested knowledge while fresh
  4. Never skip step 3 — Undocumented shipped work is invisible work

Exception: Architecture Decision Records (ADRs) should be written BEFORE implementation.

Drift Detection During Meditation

Meditation and dream sessions are natural checkpoints for doc freshness:

CheckDuring
Version numbers in living docs match current releaseMeditation consolidation
Framework names in stack descriptions are currentDream maintenance
Diagram labels match actual component namesSynapse validation
README "What's New" reflects recent workPost-release meditation

Doc Audit Checklist

When reviewing documentation after development work:

  1. Search for changed metrics — Did we add/remove skills, instructions, agents, commands?
  2. Grep for stale counts\b{old_count}\b across all .md files
  3. Check canonical sources — Do dashboards match filesystem?
  4. Verify cross-references — Do links point to files that still exist?
  5. Timestamp check — Are "Last Updated" dates current on living docs?
  6. Orphan check — Are there files in doc folders not linked from any index?
  7. Audience check — Is each doc in the right directory for its audience?

CHANGELOG Best Practices

PracticeRationale
Log architectural decisions, not just code changesFuture self needs the "why"
Explain why, not just what"Added muscles" < "Established muscles as Motor Cortex, separate from memory trifecta"
One entry per user-visible changeAvoid implementation noise
Use ### Added, ### Changed, ### Fixed, ### RemovedKeep It Structured
Never skip a versionGit tags should match CHANGELOG headers

Preflight Validation

For release scripts or CI, automated count checks can catch drift early:

powershell
# Example: Verify skill count in copilot-instructions matches filesystem
$actual = (Get-ChildItem .github/skills -Directory).Count
$documented = [regex]::Match((Get-Content .github/copilot-instructions.md -Raw), '(\d+) skills').Groups[1].Value
if ($actual -ne $documented) { Write-Warning "Skill count drift: $actual actual vs $documented documented" }

Integrate similar checks into your project's QA or pre-publish scripts.