# Typed Markdown blocks

> Why contentbit adds typed blocks to Markdown instead of MDX, and how one registry validates them and writes the instructions an agent follows.

Contentbit keeps prose in Markdown and adds typed
[directive blocks](/docs/reference/syntax) for the structure that prose does
not carry, such as a comparison, steps, or a FAQ:

```md
:::comparison{left="Source-only check" right="contentbit check"}
- Layout h1 | Reported as missing | Read from the page
- Table-of-contents anchors | Not checked | Checked against the ids
:::
```

One registry defines each block. The same definition validates the block,
renders it through [React, Astro, or plain Markdown](/docs/guides/renderers),
and generates the authoring instructions that an agent reads, so the
instructions cannot drift from the schemas.

## Why not MDX

MDX embeds components, and suits developers who want arbitrary JSX in their
content. Typed blocks suit content that an agent writes, or that people edit
outside the codebase:

|                     | MDX                           | Typed blocks                             |
| ------------------- | ----------------------------- | ---------------------------------------- |
| Authoring surface   | JSX + Markdown                | Markdown + constrained directives        |
| Validation          | None (compile errors at best) | Schemas with `file:line:col` diagnostics |
| Execution           | Compiles to JS, runs code     | Never executes code                      |
| Render targets      | React                         | React, Astro, plain Markdown             |
| Safe for LLM output | Risky                         | Designed for it                          |

A document with typed blocks stays readable in any plain-text editor. Without
a renderer, it still makes sense as Markdown.

## The authoring instructions

`contentbit instructions --audience llm` prints the authoring guide for the
project's blocks, [custom blocks](/docs/guides/custom-blocks) included. It
starts with rules for the agent:

```md
# Content block authoring rules

- write regular Markdown by default; use blocks only when they improve scanning or structure
- never invent block names — only the blocks documented below exist
- follow each block's syntax exactly; props use {key="value"} on the open line
- close every :::block with a line containing only :::
- validate generated content and fix diagnostics rather than bypassing them
```

Each block then gives its description, content shape, use and avoid rules, a
verified example, and every prop with its type, enum values, default, and
description. `--audience human` leaves out the rules. In code,
`registry.toAuthoringGuide({ audience: 'llm', includeExamples: true })` returns
the same guide.

The registry is the source of truth, so regenerate a saved guide when the
blocks change:

```bash
contentbit instructions --audience llm --out contentbit-guide.md
contentbit docs --out docs/blocks.md
```

When the contentbit config names a registry or sets `genericBlocks: true`, the
`AGENTS.md` block and the skills that [`contentbit agents`](/docs/guides/agents)
installs send the agent to `contentbit-guide.md` before it writes a block, or to
`contentbit instructions` when the project has not saved the guide.

## Validate what the agent wrote

```bash
contentbit validate "content/**/*.md"
```

Each diagnostic has a source position, a stable code, and a message the agent
can act on:

```text
recipes/dough.md:7:1 error CB_CHILD_COUNT
  :::tabs needs at least 2 children, found 1.
```

The agent fixes the document and runs `validate` again until it exits 0. The
instructions help an agent write valid blocks. They do not verify facts or
replace a human review.
