Codebase-Embedded Documentation
Use this skill to create, maintain, query, and health-check codebase-embedded documentation — curated, structured knowledge stored beside the code.
Definition
Codebase-embedded docs complement, not duplicate, implementation-level docs (Swagger, Protobuf, JavaDoc — agents can scan source for signatures). They are primarily consumed by AI agents gathering context for engineering tasks.
Docs are never mixed into source files: the global docs/ covers cross-cutting concerns, module docs/ covers module-specific ones, and both lean toward consolidated parent branches.
Objective & Philosophy
- Complementary, Not Redundant: Explain what source-level docs may not — the high-level what, why and how.
- Focus on High-Level Constructs: Design decisions, trade-offs, constraints, architecture, patterns, boundaries, data flows, and mental models.
- Persistent Curator Pattern: Act as a persistent curator (Karpathy's LLM Wiki Pattern) building a compounding, interlinked knowledge graph near the code.
Directory Conventions
Docs live in dedicated docs/ subdirectories beside module README.md files, never mixed into source folders:
<repository-root>/
├── README.md # Repository Overview (scope, usage, links to docs/index.md)
├── docs/ # Global / Cross-Cutting Architecture Docs Directory
│ ├── index.md # Global Docs Table of Contents
│ ├── architecture/ # Subdirectory reflecting upper-level docs section
│ │ └── overview.md # OKF Docs Page (type: architecture)
│ └── guides/ # Subdirectory reflecting upper-level docs section
│ └── coding-standards.md # OKF Docs Page (type: guide)
└── <module-name>/ # e.g., auth-service, billing-service (module root)
├── README.md # Module Entry Point (scope, usage, links to docs/index.md)
├── docs/ # Module Docs Directory (supports subdirectories reflecting upper docs levels)
│ ├── index.md # Module Docs Table of Contents
│ ├── concepts/ # Docs subdirectory for concepts section
│ │ └── topic-a.md # OKF Docs Page (type: concept)
│ └── decisions/ # Docs subdirectory for decision records section
│ └── adr-001.md # OKF Docs Page (type: decision-record)
└── src/ # Standard source root
├── main/ # Production application sources
└── test/ # Unit and integration tests
- Open Knowledge Format (OKF): An open, vendor-neutral standard sharing knowledge as a directory of Markdown files with YAML frontmatter.
- Single vs Multiple Modules: Single-module codebases put all knowledge in global
docs/. Multi-module repos use global docs/ for cross-cutting concerns and per-module docs/ for module-specific ones. docs/ live high in the tree: parent modules whose submodules are application-stack layers hold one README.md + docs/ covering their children, rather than scattering a docs/ into every leaf submodule.
- READMEs vs Docs Pages:
README.md files are not OKF — quick scope/usage intros that link to docs/index.md.
- Docs Index: Every
docs/ directory MUST contain an index.md — a flat TOC where headings represent subdirectories and bullets list individual pages, each distilled into a one-sentence summary. Not OKF.
Recommended Structure
Organize docs/ into documentation categories. For example:
specs/: High-level project specifications defining goals, purpose, and functional/non-functional requirements.
architecture/: High-level architecture, system overview, technology stack, architectural patterns.
decisions/: Architecture Decision Records (ADRs) — context, decision, trade-offs, consequences. Atomic, one decision each.
domain/: High-level concepts and mental models — key abstractions, business rules, constraints, stakeholders.
workflows/: Repeatable process patterns — development flows, testing strategy, CI/CD, deployment sequences.
guides/: Practical how-to references — coding standards, contribution guidelines, environment setup.
Considerations:
- Start Small, Grow on Demand. Organizing docs into categories is the full roadmap, not the required layout. Begin with the minimum a module needs — often a single
docs/index.md plus a handful of pages — and open new docs/<category>/ directories only when knowledge genuinely accumulates. Never pre-scaffold category branches.
- Split Long Pages (>500 lines). Keep pages focused. When a page approaches ~500 lines, propose splitting it into focused pages (one concept/decision/guide per page,
docs/index.md updated) — never let a doc silently balloon.
Core Operations
Detailed procedures are modularized in references/. Follow the guide matching the detected trigger.
ingest — Ingest PRs, Commits, & External Docs
- Trigger: Incorporating new architectural decisions, conversations, PR diffs, commit ranges, or external docs (RFCs, design docs, onboarding notes) into module
docs/ pages and updating docs/index.md.
- Procedure: See ingest-operation.md.
query — Knowledge Graph Traversal & Context Building
- Trigger: Gathering context to understand the codebase and prepare for development tasks.
- Procedure: See query-operation.md.
lint — Documentation Health Check & Audit
- Trigger: Performing a health check to keep docs well-organized, up-to-date, and error-free.
- Procedure: See lint-operation.md.
Execution Guidelines
- High-Level Rationale: Explain why and high-level how. Never copy code blocks, signatures, or verbatim logic into docs pages.
- Relative Links Only: Use relative paths for cross-page links and source references; avoid absolute
file:/// URLs.
- Isolate Docs Pages in
docs/: Docs pages live exclusively inside docs/**/*.md, never among source files.
- Confirm-Then-Apply Posture: Present proposed pages,
docs/<category>/ branches, and re-parented modules up front; apply after a single approval. For unattended runs, collect all changes and require one sign-off, then create.
References
- okf-spec.md (frontmatter schema & docs page template)
- index-templates.md (TOC templates)
- readme-template.md (root & module README templates, incl. existing-README link section)
1---2name: codebase-embedded-docs3description: Operate codebase-embedded documentation (ingest, query, lint) following Google's Open Knowledge Format (OKF). Use when managing repository documentation, ingesting PRs or design docs into module docs/, gathering documented architecture or design-rationale context, or auditing documentation health. Not for live source queries (signatures, APIs, implementations) or general-purpose linting — explore the code directly for those.4license: Apache-2.05---67# Codebase-Embedded Documentation89Use this skill to create, maintain, query, and health-check **codebase-embedded documentation** — curated, structured knowledge stored beside the code.1011## Definition1213Codebase-embedded docs **complement, not duplicate**, implementation-level docs (Swagger, Protobuf, JavaDoc — agents can scan source for signatures). They are primarily consumed by AI agents gathering context for engineering tasks.1415Docs are never mixed into source files: the global `docs/` covers cross-cutting concerns, module `docs/` covers module-specific ones, and both lean toward consolidated parent branches.1617## Objective & Philosophy1819- **Complementary, Not Redundant**: Explain what source-level docs may not — the high-level *what*, *why* and *how*.20- **Focus on High-Level Constructs**: Design decisions, trade-offs, constraints, architecture, patterns, boundaries, data flows, and mental models.21- **Persistent Curator Pattern**: Act as a persistent curator (Karpathy's [LLM Wiki Pattern](https://gist.github.com/karpathy/442a6bf555914893e9891c11519de94f)) building a compounding, interlinked knowledge graph near the code.2223## Directory Conventions2425Docs live in dedicated `docs/` subdirectories beside module `README.md` files, never mixed into source folders:2627```text28<repository-root>/29├── README.md # Repository Overview (scope, usage, links to docs/index.md)30├── docs/ # Global / Cross-Cutting Architecture Docs Directory31│ ├── index.md # Global Docs Table of Contents32│ ├── architecture/ # Subdirectory reflecting upper-level docs section33│ │ └── overview.md # OKF Docs Page (type: architecture)34│ └── guides/ # Subdirectory reflecting upper-level docs section35│ └── coding-standards.md # OKF Docs Page (type: guide)36└── <module-name>/ # e.g., auth-service, billing-service (module root)37 ├── README.md # Module Entry Point (scope, usage, links to docs/index.md)38 ├── docs/ # Module Docs Directory (supports subdirectories reflecting upper docs levels)39 │ ├── index.md # Module Docs Table of Contents40 │ ├── concepts/ # Docs subdirectory for concepts section41 │ │ └── topic-a.md # OKF Docs Page (type: concept)42 │ └── decisions/ # Docs subdirectory for decision records section43 │ └── adr-001.md # OKF Docs Page (type: decision-record)44 └── src/ # Standard source root45 ├── main/ # Production application sources46 └── test/ # Unit and integration tests47```4849- **Open Knowledge Format (OKF)**: An open, vendor-neutral standard sharing knowledge as a directory of Markdown files with YAML frontmatter.50- **Single vs Multiple Modules**: Single-module codebases put all knowledge in global `docs/`. Multi-module repos use global `docs/` for cross-cutting concerns and per-module `docs/` for module-specific ones. **`docs/` live high in the tree**: parent modules whose submodules are application-stack layers hold one `README.md` + `docs/` covering their children, rather than scattering a `docs/` into every leaf submodule.51- **READMEs vs Docs Pages**: `README.md` files are **not** OKF — quick scope/usage intros that link to `docs/index.md`.52- **Docs Index**: Every `docs/` directory MUST contain an `index.md` — a flat TOC where headings represent subdirectories and bullets list individual pages, each distilled into a one-sentence summary. Not OKF.5354### Recommended Structure5556Organize `docs/` into documentation **categories**. For example:5758- `specs/`: High-level project specifications defining goals, purpose, and functional/non-functional requirements.59- `architecture/`: High-level architecture, system overview, technology stack, architectural patterns.60- `decisions/`: Architecture Decision Records (ADRs) — context, decision, trade-offs, consequences. Atomic, one decision each.61- `domain/`: High-level concepts and mental models — key abstractions, business rules, constraints, stakeholders.62- `workflows/`: Repeatable process patterns — development flows, testing strategy, CI/CD, deployment sequences.63- `guides/`: Practical how-to references — coding standards, contribution guidelines, environment setup.6465Considerations:6667- **Start Small, Grow on Demand.** Organizing docs into categories is the full roadmap, **not the required layout**. Begin with the minimum a module needs — often a single `docs/index.md` plus a handful of pages — and open new `docs/<category>/` directories only when knowledge genuinely accumulates. Never pre-scaffold category branches.68- **Split Long Pages (>500 lines).** Keep pages focused. When a page approaches ~**500 lines**, propose splitting it into focused pages (one concept/decision/guide per page, `docs/index.md` updated) — never let a doc silently balloon.6970## Core Operations7172Detailed procedures are modularized in [`references/`](references/). Follow the guide matching the detected trigger.7374### `ingest` — Ingest PRs, Commits, & External Docs7576- **Trigger**: Incorporating new architectural decisions, conversations, PR diffs, commit ranges, or external docs (RFCs, design docs, onboarding notes) into module `docs/` pages and updating `docs/index.md`.77- **Procedure**: See [ingest-operation.md](references/ingest-operation.md).7879### `query` — Knowledge Graph Traversal & Context Building8081- **Trigger**: Gathering context to understand the codebase and prepare for development tasks.82- **Procedure**: See [query-operation.md](references/query-operation.md).8384### `lint` — Documentation Health Check & Audit8586- **Trigger**: Performing a health check to keep docs well-organized, up-to-date, and error-free.87- **Procedure**: See [lint-operation.md](references/lint-operation.md).8889## Execution Guidelines90911. **High-Level Rationale**: Explain *why* and high-level *how*. Never copy code blocks, signatures, or verbatim logic into docs pages.922. **Relative Links Only**: Use relative paths for cross-page links and source references; avoid absolute `file:///` URLs.933. **Isolate Docs Pages in `docs/`**: Docs pages live exclusively inside `docs/**/*.md`, never among source files.944. **Confirm-Then-Apply Posture**: Present proposed pages, `docs/<category>/` branches, and re-parented modules up front; apply after a single approval. For unattended runs, collect all changes and require one sign-off, then create.9596## References9798- [okf-spec.md](references/okf-spec.md) (frontmatter schema & docs page template)99- [index-templates.md](references/index-templates.md) (TOC templates)100- [readme-template.md](references/readme-template.md) (root & module README templates, incl. existing-README link section)