Guide
What is docs as code?
Docs as code (also written documentation as code) is the practice of producing documentation with the same tools and workflow you use for software: plain-text source files in version control, changes proposed as pull requests, correctness enforced by automated checks in CI, and publishing done by a build step. The document in the repository is the single source of truth — the website, PDF, or slide deck is just a build artifact.
Why teams adopt it
The alternative — wikis, shared drives, design-tool canvases — fails the same way every time: documentation lives far from the code it describes, nobody reviews changes, and nothing tells you when a page goes stale. Moving docs into the engineering workflow fixes each of those structurally:
- Version control. Every change has an author, a diff, and a revert. Docs and the code they describe can change in the same commit.
- Review. Documentation goes through pull requests, so accuracy is checked by the people who built the thing — before publishing, not after a reader complains.
- CI validation. Broken links, invalid examples, and malformed content fail the build instead of shipping.
- One source, many outputs. The same source renders to a docs site, a PDF for the auditor, or slides for the review meeting.
The docs-as-code workflow
A minimal pipeline has four stages, and each maps onto a familiar software practice:
- Write in a plain-text format — Markdown, almost always — in the same repository as the code.
- Review through a pull request, like any other change.
- Validate in CI: linting, link checking, and — if your format supports it — schema validation of the content itself.
- Publish with a build command that turns source into a website, PDF, or slides.
Where classic docs as code breaks down
Prose survives this pipeline well. Everything else degrades. Diagrams get pasted in as screenshots that no diff can inspect and no check can validate. API tables drift from the handlers they describe. Roadmaps live in a slide deck two quarters behind reality. The parts of documentation most likely to be wrong are exactly the parts CI can't see.
Chiltepin's answer is to give the visual parts of a document the same rigor as the prose: anything visual is a typed block — a fenced section of Markdown with a type and a YAML body, validated against a strict schema. This sequence diagram is source code, not a screenshot:
```sequence
id: seq-place-order
title: Place order
endpoint: { method: POST, path: /orders }
actors:
- { id: Client, name: Client }
- { id: API, name: Orders API }
messages:
- { from: Client, to: API, label: POST /orders, kind: sync }
- { from: API, to: Client, label: 201 Created, kind: response }
```There is a growing library of block types — sequence diagrams, ERDs, C4, flowcharts, state machines, Gantt charts, API endpoints, ADR-style decision records — and chiltepin check validates every block and every cross-reference, failing CI on errors. One command exports a static site, slides, or PDF. Your .md files stay the single source of truth.
Docs as code in the AI era
Docs as code turned out to be the right architecture for a reason nobody predicted: plain text is what AI agents are best at writing. But an agent that can write anything will also confidently write nonsense — which is why the missing half of AI-written documentation is verification. Because every Chiltepin block has a schema, an agent can write your docs and chiltepin check can prove they're structurally right, the same way a test suite gates AI-written code. You review content, not syntax. That's what we mean by AI-first docs as code.
Choosing docs-as-code tools
For prose-only documentation, a static site generator (Docusaurus, MkDocs, Hugo) plus a linter is a fine stack. Reach for Chiltepin when your documents are more than prose — when they need diagrams your agent can write and CI can validate, when the same source must ship as a website and slides and PDF, or when you're replacing an unvalidated diagram DSL (see Chiltepin vs Mermaid). It's MIT-licensed, and the whole editor runs in your browser with nothing uploaded.
Frequently asked questions
- What does "docs as code" mean?
- Docs as code is the practice of treating documentation the way you treat source code: written in plain-text formats like Markdown, stored in version control next to the code it describes, reviewed through pull requests, validated by automated checks in CI, and published by a build step instead of edited in place on a wiki.
- What is the difference between docs as code and a wiki?
- A wiki is edited in place with no review step, so pages drift out of date silently and nobody owns their accuracy. Docs as code puts every change through the same pipeline as code — a diff, a review, an automated check, a deploy — so documentation has the same history, accountability, and rollback story as the software itself.
- What tools are used for docs as code?
- The classic stack is Markdown or AsciiDoc plus a static site generator (Docusaurus, MkDocs, Hugo), a linter like Vale, and CI to build and deploy. Chiltepin extends that stack with typed blocks: diagrams, tables, and API specs are structured YAML inside Markdown, validated by a schema with chiltepin check, and rendered to a website, slides, or PDF with one command.
- Is Markdown enough for docs as code?
- Markdown covers prose well, but everything visual — diagrams, ERDs, roadmaps, API references — usually ends up as pasted screenshots or unvalidated DSL snippets that CI cannot check. That is the gap typed blocks close: the visual parts of a document get a schema, so a validator can fail the build when they are wrong or incomplete.
- How does AI fit into a docs-as-code workflow?
- Plain text is the one format AI agents are genuinely good at producing, which makes docs as code the natural home for AI-written documentation. The missing piece is verification: with a schema over the content, a checker like chiltepin check can prove an agent’s output is structurally correct before a human reviews it, the same way tests gate AI-written code.