Dual-Layer AI Documentation Method: An AI-First Documentation System for Repositories

April 20, 2026 · 5 min read ·

Claudio Caporro - v0.3

This is a practical guide for the Dual-Layer AI Documentation Method, a repository documentation system used primarily by agents. It defines where documentation lives, what each area is responsible for, and how updates should be made incrementally.


AI-First Documentation Philosophy

Documentation in a repository adopting this system is designed primarily for AI Agents. By maintaining high-quality docs, we achieve:

  1. Token Efficiency: Reducing the “research loop”. Instead of an agent reading 20 source files to understand a pattern, it reads one doc.
  2. Ambiguity Reduction: Providing the Rationale (Why) behind specific architectural choices prevents agents from “correcting” intentional designs they might perceive as non-standard.
  3. Active Context: Documentation serves as an external memory for the model, ensuring it operates with the same strategic context as the original architect.

1) File Types and Responsibilities

A) Bootstrap Files (Always Loaded)

Root bootstrap file (e.g. /AGENTS.md or /agents.md)

B) Informational (Loaded on Demand)

docs/features/[feature].md

C) Prescriptive Rules (Validated by Reviewer)

docs/rules/[feature].rules.md

D) Global Rules

docs/rules/general.rules.md

E) Execution Workflows

docs/workflows/*.md

F) Metadata Header (features + rules)

All files in docs/features/*.md and docs/rules/*.rules.md must include YAML frontmatter for automated routing and incremental updates.

Required keys:

---
title: <name>
doc_type: feature | rules
status: active
last_updated: YYYY-MM-DD
covers:
  - path/pattern/**
related_docs:
  - docs/README.md
---

2) The 2-Stage Workflow

To prevent Prompt Fatigue (where agents lose quality due to over-constraint), we follow a two-stage engagement model:

Stage 1: Explore / Generate (The “Builder” Phase)

Stage 2: Converge / Enforce (The “Polishing” Phase)


/AGENTS.md (root bootstrap file, or `/agents.md`)

/docs
  README.md
  INDEX.md
  /features
    pages.md
    app-shell.md
    ...
  /rules
    general.rules.md
    pages.rules.md
    ...
  /workflows
    create-docs.md
    update-docs.md
    review-docs.md

4) Info vs. Rules: Content Separation

Inside docs/features/[feature].md (INFO)

Focus on Building. Helpers, not judges.

Inside docs/rules/[feature].rules.md (RULES)

Focus on Validation. Must be checkable.

Template:

pages.04 - [PRIORITY]
Rule: ...
Why: ...
Check: ... (optional)
Autofix: ... (optional)

5) Priority Matrix

LevelDefinitionGuideline
CRITICALSevere bugs, data loss, security, breaking contracts, major refactors.”If this hits production, we are in trouble.”
HIGHTechnical debt, UI inconsistency, bad maintainability.”We will have to fix this very soon.”
NICE TO HAVEStyle, readability, preferences.”Clean it up when we have time.”

6) Usage Policy for Agents


7) Incremental Update Policy


8) File Linking Convention

When linking to files within the repository from documentation:


The Golden Rule

If a “rule” is not checkable via code/diff, it is not a rule. Move it to docs/features/*.md as a best practice.

Stay in the loop

New articles on AI, engineering management, and surviving legacy code — directly in your inbox. No spam, unsubscribe anytime.

Claudio Caporro

© 2026

LinkedIn Medium Telegram