| name | maintaining-documentation |
| description | Maintains The Canonical Docs as single source of truth. Trigger after feature completion, before git push, on architecture changes, or explicit "update docs" requests. Skip for trivial changes (<10 LOC, no logic/schema/UI changes). |
Documentation Maintenance Skill
When to use this skill
โ
ALWAYS Trigger
- Post-Feature: After completing any user story or AC
- Pre-Commit: Before
git push if files changed in /src, /app, /lib, /db
- Architecture Change: DB schema, API contracts, auth logic modified
- New Route/Page: Any file added to
/app directory
- Design Token Change: Modifications to colors, spacing, typography in code
- Explicit Request: User says "update docs", "sync documentation", "cleanup docs"
โ NEVER Trigger
- Trivial changes (<10 lines, no business logic)
- Fixing typos in code comments
- Refactoring without behavior change
- Package updates in
package.json (unless major version or new package)
- Test file additions (unless testing new features)
โ ๏ธ ASK FIRST
- Experimental features (ask: "Should I document this now or wait until stable?")
- Breaking changes (ask: "Should I document the migration path?")
- Hotfixes (ask: "Update docs now or after proper solution?")
Canonical Structure
/
โโโ CLAUDE.md # โญ AI reads FIRST every session
โโโ docs/
โโโ progress.txt # Session memory bridge
โโโ product/
โ โโโ prd.md # Feature requirements + status
โ โโโ app-flow.md # Navigation + user flows
โ โโโ product-overview.md # Vision + goals
โ โโโ product-roadmap.md # Planned features
โ โโโ sections/
โ โ โโโ [section-id]/
โ โ โโโ spec.md # Detailed US + AC
โ โโโ shell/
โ โ โโโ spec.md # Layout/nav spec
โ โ โโโ components/ # Shell components
โ โโโ types.ts # Shared types
โโโ design-system/
โ โโโ guidelines.md # Design rules (prose)
โ โโโ design-system.json # Tokens (structured)
โ โโโ components.md # Component library
โ โโโ design-rules.md # Optional constraints
โโโ system/
โโโ tech-stack.md # Dependencies (exact versions)
โโโ data-flow.md # Data sources + viz logic
โโโ data-consistency.md # โญ GOLDEN formulas
โโโ implementation-plan.md # Build sequence
โโโ backend-structure/
โโโ backend-structure.md
โโโ database-model.md # Schema + relations
โโโ architecture-overview.md
โโโ api-expectations.md # Endpoint contracts
โโโ module-map.md # Code organization
โโโ auth-model.md # Auth flows
Decision Tree: What to Update
Use this deterministic tree to decide which docs need updates:
START
โ
โโ Changed /app routes or pages?
โ โโ YES โ Update app-flow.md + progress.txt
โ โ โโ New feature? โ Create sections/[id]/spec.md
โ โโ NO โ Continue
โ
โโ Changed DB schema or API?
โ โโ YES โ Update backend-structure/database-model.md
โ โ โโ API contracts changed? โ Update api-expectations.md
โ โ โโ New dependencies? โ Update tech-stack.md
โ โโ NO โ Continue
โ
โโ Changed business logic or calculations?
โ โโ YES โ Update data-consistency.md (GOLDEN SOURCE)
โ โ โโ grep all docs for old formula โ Replace with LINK
โ โโ NO โ Continue
โ
โโ Changed UI components or design tokens?
โ โโ YES โ Update design-system.json tokens
โ โ โโ New component? โ Update components.md
โ โ โโ Design rule changed? โ Update guidelines.md
โ โโ NO โ Continue
โ
โโ Feature status changed?
โ โโ YES โ Update prd.md status (๐ง โ โ
)
โ โ โโ Update progress.txt with [x]
โ โโ NO โ Continue
โ
โโ DONE
Update Workflow
Step 1: Session Start
1. Read CLAUDE.md to load project context
2. Read progress.txt to understand current state
3. Ask: "What changed since last session?"
Step 2: Determine Scope (use Decision Tree above)
Step 3: Execute Updates
For each file to update:
-
Check redundancy: Does this info exist elsewhere?
- If YES โ Add link, don't duplicate
- If NO โ Proceed
-
Update the file:
- Find exact section to modify
- Make minimal, surgical change
- Preserve existing structure
-
Update cross-references:
- If file moved/renamed โ
grep -r "old-name" docs/
- Fix all broken links
-
Update progress.txt:
- Mark items [x] done
- Add new items [ ] if needed
Step 4: Validate
1. grep -r "\[.*\](.*.md)" docs/
2. Check each link exists
3. Verify no duplicate content (same formula in 2 places)
4. Confirm progress.txt reflects reality
Golden Rules
Single Source of Truth
| Topic | Owner Document |
|---|
| Calculations/formulas | data-consistency.md |
| DB schema | backend-structure/database-model.md |
| API contracts | backend-structure/api-expectations.md |
| Dependencies | tech-stack.md |
| Design tokens | design-system.json |
| User flows | app-flow.md |
Rule: If info exists in owner doc โ Link to it. Never copy.
File Placement
- โ Never put loose .md files in
/docs/ root
- โ
Always organize under
product/, system/, or design-system/
- โ
Exception: Only
CLAUDE.md (root), progress.txt (docs/)
CLAUDE.md Priority
- CLAUDE.md is AI's operating manual
- Update it when conventions change
- Keep it under 2000 words (AI loads it every session)
Progress.txt Discipline
- Update EVERY feature completion
- Format:
[x] Feature name - Brief status
- Acts as session memory bridge
Common Scenarios
Scenario 1: "Feature X is complete"
Trigger: Post-feature
Files to check:
1. progress.txt โ Mark [x]
2. prd.md โ Update status to โ
3. sections/X/spec.md โ Verify spec matches implementation
4. app-flow.md โ If new routes added
5. data-consistency.md โ If formulas involved
Scenario 2: "Changed DB schema"
Trigger: Architecture change
Files to update:
1. backend-structure/database-model.md โ Document new schema
2. backend-structure/api-expectations.md โ If endpoints changed
3. tech-stack.md โ If new DB packages added
4. progress.txt โ Record change
Scenario 3: "Added /dashboard/analytics page"
Trigger: New route
Files to update:
1. app-flow.md โ Add route + user flow description
2. progress.txt โ Add to completed
3. sections/analytics/spec.md โ Create if new feature domain
4. prd.md โ If this fulfills a requirement
Scenario 4: "Changed button radius from 16px to 12px"
Trigger: Design token change
Files to update:
1. design-system.json โ Update radius-button token
2. design-system/guidelines.md โ Update if explanation needed
3. DO NOT update individual component files (they reference tokens)
Scenario 5: "Formula for inventory calculation changed"
Trigger: Business logic change
Files to update:
1. data-consistency.md โ Update THE formula (golden source)
2. Run: grep -r "old formula pattern" docs/
3. Replace all occurrences with LINK to data-consistency.md
4. sections/inventory/spec.md โ Link to data-consistency.md
Scenario 6: "Cleanup documentation"
Trigger: Explicit request
Actions:
1. find docs/ -name "*.md" -type f
2. Check each file against canonical structure
3. Move misplaced files to correct folders
4. rm temp_*.md old_*.md backup_*.md
5. Run link audit: grep -r "\[.*\](.*.md)" docs/
6. Fix broken links
7. Report summary of changes
Scenario 7: "Starting new session"
Trigger: Session start
Actions:
1. Read CLAUDE.md first (AI context)
2. Read progress.txt (what's done/in-progress)
3. Ask user: "What are we working on today?"
4. Proceed with work
Pre-Commit Checklist
Before git push, verify:
[ ] progress.txt updated?
[ ] Feature status in prd.md reflects reality?
[ ] Relevant spec files synced with implementation?
[ ] New pages documented in app-flow.md?
[ ] Design changes in design-system/?
[ ] Backend changes in backend-structure/?
[ ] No broken internal links? (grep check)
[ ] No duplicate content? (same info in 2+ places)
[ ] CLAUDE.md updated if conventions changed?
Validation Commands
Run these to verify docs health:
grep -r "\[.*\](.*.md)" docs/
grep -r "^## " docs/ | sort | uniq -d
find docs/ -maxdepth 1 -name "*.md" ! -name "progress.txt"
grep -r "TODO\|FIXME" docs/
Error Prevention
Common Mistakes to Avoid
-
Updating latest instead of best
- โ Always updating the newest file
- โ
Check if older version has better info
-
Duplicating instead of linking
- โ Copying formula to multiple docs
- โ
Reference data-consistency.md
-
Forgetting progress.txt
- โ Only updating specs
- โ
Always update progress.txt too
-
Breaking links when moving files
- โ Moving file without updating references
- โ
grep for all references first
-
Over-documenting trivial changes
- โ Updating docs for 2-line fix
- โ
Use "When NOT to use" criteria
Success Metrics
After using this skill, docs should be:
โ
Consistent - No contradictions between files
โ
Complete - All implemented features documented
โ
Current - Reflects actual codebase state
โ
Linked - Cross-references work, no duplicates
โ
Organized - Files in correct canonical folders
โ
Accessible - CLAUDE.md + progress.txt provide entry points