Self-Maintaining Documentation System Using Fenced Blocks for Zero Drift

A developer on r/ClaudeAI shared a solution for maintaining accurate documentation in multi-project workspaces where AI coding agents like Claude Code forget context between sessions. The system addresses problems with 8 projects, 20 Lambda functions, 42 API keys, 12 API endpoints, and 19 environment variables where the agent would guess at function names, edit wrong files, and lose context.
The Fence System
Instead of asking Claude to update docs after implementation, the developer built a 740-line bash script that extracts structured data directly from source files and injects it into CLAUDE.md through fenced HTML comment blocks. Each CLAUDE.md has fences marking auto-generated sections:
## Serverless Functions <!-- auto:lambdas generated="2026-03-26" source="infrastructure/lib/api-stack.ts" -->
| Function | Route | Memory | Timeout |
|----------|-------|--------|---------|
| quote-save | /quotes/save | 256MB | 15s |
| quote-get | /quotes/get | 256MB | 15s |
...20 rows extracted from CDK config...
<!-- /auto:lambdas -->
## Architecture <-- hand-written, never touched by the script
How It Works
The script:
- Parses actual source files (CDK TypeScript, FastAPI Python, package.json, etc.)
- Extracts structured data (function names, routes, env vars, dependency versions)
- Replaces everything between the fences
- Updates the generated date to show freshness
- Validates: checks that every Lambda name has a matching handler file, every env var exists in .env
Hand-written sections (architecture descriptions, gotchas, business logic context) live outside fences and are never touched.
Auto-Generated Content
- Quoting tool (20 Lambdas): Lambda inventory, CDK stacks, env vars, test counts, deps from CDK TypeScript and package.json
- Sales dashboard (12 endpoints): API routes, theme list, deps from FastAPI decorators, TypeScript types, and requirements.txt
- Data parsing (42 Users): User data, deps from Python credential file and requirements.txt
- 5 other projects: Dependency versions from package.json/requirements.txt
Staleness Warning System
A doc-sync hook (fires after every code edit) checks the generated date on each fence. If any section is older than 7 days:
Warning: 3 auto-generated sections in agent-quoting-tool/CLAUDE.md are stale (oldest: 2026-03-19).
Run: ./scripts/generate-inventory.sh quoting
This is non-blocking — warns but never stops you from working. The staleness check rides alongside existing hooks with the same 10-minute throttle window, zero extra overhead.
Implementation Details
The setup uses pure bash with grep/sed/awk/jq, zero dependencies. Commands:
scripts/generate-inventory.sh all # Refresh everything
scripts/generate-inventory.sh quoting # Just one project
The script backs up each CLAUDE.md first (one backup per day, per project). The developer notes not to parse ASTs from bash — their TypeScript parser is a line-by-line grep/sed loop that works for controlled files but would be fragile for arbitrary TypeScript.
Key Insights
The fences allow auto-generated and hand-written content to coexist in the same file. Claude reads the whole CLAUDE.md at session start and gets both: accurate extracted data AND human context it can't infer from code. The developer recommends starting with highest-value extractions (Lambda inventories and env var tables that cause bugs when they drift) and notes that the staleness warning is more valuable than auto-running.
The entire system took about 3 hours to build (design, implementation, testing, first run).
📖 Read the full source: r/ClaudeAI
👀 See Also

Claude Text Adventure Skill v1.1.0 Adds Campaign Arcs and Enhanced NPCs
The Claude text adventure skill update v1.1.0 introduces campaign arcs where character progression persists across adventures, NPCs with hidden stats and levels, and optional visual/audio modules. Download text-adventure.zip from GitHub releases to use with Claude Desktop or claude.ai.

Developer builds MCP server connecting 18 e-commerce tools to Claude
A developer created an MCP server that integrates 18 e-commerce platforms and tools with Claude, enabling cross-referencing queries across multiple data sources. The project was primarily built using Claude Code (Opus) in days rather than months.

Codebase Memory MCP: Graph-based code exploration for Claude Code
A developer built an MCP server that indexes codebases into a persistent knowledge graph using Tree-sitter and SQLite, reducing token usage by 20x on average for structural queries like call tracing and dead code detection.

Qwen 3.6 27B with MTP on V100 32GB: 54 t/s via llama.cpp Branch
am17an's MTP branch of llama.cc runs Qwen 3.6 27B at 54 t/s on V100 32GB via PCIe adapter, dropping to 29-30 t/s without MTP.