Skip to content

Documentation Size Management

Documentation Size Management is the practice of enforcing strict size limits on governance files to keep them focused, maintainable, and scannable by both humans and AI agents.

Documentation tends to grow unbounded without limits:

The solution: Enforce size limits. Every line of documentation must justify its existence.


Cortex TMS enforces strict size limits on HOT files and relaxed limits on WARM files:

FileMax LinesWhy This Limit?
NEXT-TASKS.md200 linesOne sprint maximum (1-2 weeks)
.github/copilot-instructions.md100 linesCritical rules only, no explanations
FileMax LinesWhy This Limit?
docs/core/PATTERNS.md650 linesReference manual with quick-reference index
docs/core/DOMAIN-LOGIC.md400 linesCore rules + Maintenance Protocol
docs/core/ARCHITECTURE.md500 linesSystem design without implementation details
docs/core/GIT-STANDARDS.md250 linesGit conventions + commit standards
docs/core/GLOSSARY.md200 linesTerminology definitions

No limits. Archive files can grow indefinitely—AI agents ignore them unless explicitly asked.


Let’s compare two projects:

# NEXT-TASKS.md (850 lines)
## Q1 2026 Tasks
- [ ] 50 tasks planned for January-March
...
## Q2 2026 Tasks
- [ ] 60 tasks planned for April-June
...
## Q3 2026 Tasks
- [ ] 70 tasks planned for July-September
...
## Completed Tasks (2025)
- [x] 100 tasks from last year
...

AI behavior:

  • Gets confused about current priority
  • References completed tasks as if they’re active
  • Asks “Which task should I work on?” repeatedly
# NEXT-TASKS.md (180 lines)
## Active Sprint: User Authentication
**Why this matters**: Mobile app needs secure API access
- [ ] JWT token generation
- [ ] Token validation middleware
- [ ] Refresh token rotation
...

AI behavior:

  • Immediately understands current focus
  • Stays on task without prompting
  • Follows established patterns from WARM tier

Result: Focused docs = better AI behavior and easier maintenance


Before archiving a task, check file size:

Terminal window
wc -l NEXT-TASKS.md
# Output: 185 NEXT-TASKS.md

If approaching 200 lines → Archive completed tasks or move backlog items to FUTURE-ENHANCEMENTS.md.

Use the Cortex TMS CLI:

Terminal window
cortex-tms validate --strict

Output:

✓ NEXT-TASKS.md (185 lines) - Under limit
✗ copilot-instructions.md (120 lines) - EXCEEDS LIMIT (max 100)
Recommendations:
- Move detailed examples to docs/core/PATTERNS.md
- Keep only critical rules in copilot-instructions.md

Add a git hook to prevent oversized commits:

.git/hooks/pre-commit
#!/bin/bash
NEXT_TASKS_LINES=$(wc -l < NEXT-TASKS.md)
if [ $NEXT_TASKS_LINES -gt 200 ]; then
echo "❌ NEXT-TASKS.md exceeds 200 lines ($NEXT_TASKS_LINES lines)"
echo "Archive completed tasks before committing"
exit 1
fi
echo "✓ NEXT-TASKS.md size OK ($NEXT_TASKS_LINES lines)"

When NEXT-TASKS.md approaches 200 lines:

Archive Completed Tasks

Move finished tasks to docs/archive/sprint-YYYY-MM.md

Terminal window
# Before: 195 lines
# After: 120 lines

Move Backlog to FUTURE

Move low-priority tasks to FUTURE-ENHANCEMENTS.md

Terminal window
# Move "nice to have" tasks out of current sprint

Break Down Large Tasks

Split 50-line epics into smaller increments

Terminal window
# Instead of 1 huge task, create 5 focused ones

When docs/core/PATTERNS.md exceeds 650 lines:

Option 1: Split into Multiple Files

docs/core/
├── PATTERNS.md (index + core patterns)
├── PATTERNS-FRONTEND.md (React/Vue patterns)
├── PATTERNS-BACKEND.md (API patterns)
└── PATTERNS-DATA.md (Database patterns)

Option 2: Create Quick-Reference Index

PATTERNS.md
## Quick Reference
| Pattern | Line | Use When |
|---------|------|----------|
| Auth Pattern | 45 | Implementing login/signup |
| API Pattern | 120 | Building REST endpoints |
| ...
## Detailed Patterns
### Auth Pattern
...

AI can scan the index, jump to the relevant section.


Bad (wastes context):

## Button Pattern
[300 lines of duplicated code from Button.tsx]

Good (saves context):

## Button Pattern
**Canonical Example**: `src/components/Button.tsx:15`
**Key Rules**:
- Use `cva` for variant composition
- Support `size`, `variant`, `disabled` props

Bad:

## JWT Authentication
Here's a complete implementation:
[500 lines of code]

Good:

## JWT Authentication
**Canonical Implementation**: `src/middleware/auth.ts`
**Key Points**:
- Use RS256 (not HS256)
- Set 15-minute expiry
- Include user_id and role in payload
**Example**:
```typescript
const token = jwt.sign({ user_id, role }, privateKey, {
algorithm: 'RS256',
expiresIn: '15m'
});
### 3. Archive Aggressively
**Rule of thumb**: If you haven't referenced it in 2 months, archive it.
Historical context is valuable, but it's **COLD** context. Keep it in `docs/archive/`, not in files AI reads regularly.
### 4. Prefer Bullet Points Over Prose
**Bad** (verbose):
```markdown
When you are implementing authentication, you should make sure
that you are using the RS256 algorithm instead of HS256 because
RS256 is more secure and uses asymmetric keys which are better
for distributed systems where you can't share a secret safely.

Good (concise):

- Use RS256 (not HS256) for JWT signing
- Why: Asymmetric keys are safer for distributed systems

Benefit: More concise and scannable for both humans and AI.


Mistake: Adding tasks to NEXT-TASKS.md without removing completed ones

Impact: File grows from 180 → 220 → 300 lines over 2 months

Fix: Archive completed tasks immediately after marking ✅ Done

Violation 2: Documenting Implementation Details

Section titled “Violation 2: Documenting Implementation Details”

Mistake: Copying entire source files into PATTERNS.md “for reference”

Impact: PATTERNS.md grows to 2,000 lines

Fix: Use canonical links. Provide rules, not implementations.

Mistake: Keeping 2 years of changelog in CHANGELOG.md at project root (HOT tier)

Impact: AI reads 5,000 lines of irrelevant history every session

Fix: Keep only current version in HOT. Archive old versions to docs/archive/v1.0-CHANGELOG.md (COLD).


Better AI Focus

Lean docs keep AI focused on what matters. Less time scanning, more time coding.

Easier Maintenance

Smaller files are easier for humans to review, update, and keep current.

Reduced Staleness

Focused docs are more likely to stay up-to-date with code changes.

Enforced Clarity

Size limits force concise writing. No room for fluff or redundancy.


Before marking a task ✅ Done, verify:

  • NEXT-TASKS.md is under 200 lines
  • copilot-instructions.md is under 100 lines
  • WARM files are under their recommended limits
  • Completed tasks archived to docs/archive/
  • Backlog items moved to FUTURE-ENHANCEMENTS.md

Tool: Run cortex-tms validate --strict to check automatically.


Now that you understand context budgets: