Specification Book
Specification Book (SpecBook) is the opinionated Open Source tooling of renowned and prolific author Dr. Ralf S. Engelschall for a generic, fully typed, Markdown-based specification format, which can be configured for the specifications of arbitrary contexts through a YAML-based schema configuration. It ships with a CLI, a TypeScript API, and a Model-Context-Protocol (MCP) interface — so humans, programs, and AI agents all reach the same functionality.
A specification is a hierarchical object model of typed objects, authored as plain Markdown through a versatile object to Markdown mapping (as sections or as tables), interconnected through Wiki-style object linking, and subject to a strict validation against its schema.
SpecBook lets a specification be initialized, linted, exported (JSON, JSON5, YAML, TOON, HTML, PDF, and normalized Markdown), previewed (HTML, live in the browser), and described to LLMs — so a single source of truth becomes the live HTML export your developers read, the PDF-based binding document export your customers receive, and the AST exports programs and/or AI/LLM agents can consume. Its object model diagram visualisations are rendered automatically, as their nodes and edges are directly derived from the specification objects and their references — so no diagram is ever drawn by hand or drifts away from the specification.
In an alternative view, as SpecBook allows arbitrary specifications comprised of objects and relationships, it can be considered as some sort of a graph "database" in the corset of Markdown files and with a document-style rendering as its data view.


One Single Source of Truth, Full Flexibility
A generic object model, authored as plain Markdown, constrained by a schema you define, and rendered into every format your project actually needs — for developers, for customers, and for the AI agents working alongside both.
Schema-Based Graph Object Model
A specification is a graph of typed objects
Every object carries a kind and a name, an optional id, optional properties, an optional description, and optional child objects. Which object kinds are allowed, how they may nest, and which properties they carry is defined per context by the YAML schema configuration — not hard-wired into the tool.
Versatile Markdown Mapping
Authored as plain Markdown, not as a foreign format
Objects are written as ordinary Markdown headings, property lists, and description prose — readable and diff-able in any editor and any code review. The very same object model maps onto nested sections (the complex format) or onto compact bullet point lists (the concise and group formats).
Wiki-Style Object Linking
Objects reference each other through Wiki [[xxx]] links
References are resolved against the locally-unique ids and names of all objects across the entire corpus, so a fact lives in exactly one place and every other place points at it. In the HTML and PDF exports the references become navigable links onto precise anchors.
Strict Validation
The schema configuration is enforced, not suggested
The YAML schema configuration defines the allowed object kinds, hierarchies, and properties, whose values are constrained by an expression language (regex, enum, tags, list, and reference). Beyond the plain values it constrains the uniqueness and presence of a property among the sibling objects, the shape of a reference-valued property (local, symmetric, and/or acyclic), and it can declare the child objects of an object kind a finite state machine, whose reachability, dead-ends, and livelocks are then checked. Violations are reported as file- and line-precise diagnostics.
Diagram Visualisation
Diagrams derived from the object model itself
Object kinds can declare graph, hub, or grid diagrams in the schema, whose nodes and edges are derived automatically from the object model and its references — so a diagram can never drift away from the specification it depicts. The rendering is done by the sibling project Gradia, which is specialized in rendering object models. Hand-written Mermaid and D2 diagrams can be embedded in addition and are rendered in the very same theme colors.
HTML Export for Developers
One self-contained document for daily reading
A single HTML document with a title page, a table of contents (also as a slide-in side panel), a diagram of contents, a fuzzy full-text search, embedded images, PDF pages, Mermaid/D2 diagrams, and syntax-highlighted code listings, the folding and maximizing of all of them, reference coverage tables,a scroll progress meter, description popups, and a light/dark theme toggle. It can even be previewed live in the browser, updating in place on every change while the scroll position survives.
Full Theming Support
Dark and Light Theme
The specification can define its own base accent color (default is RGB #336699), plus optionally also the signal color, for coloring the specification's texts, tables and diagram boxes. In the HTML rendering you can even ad-hoc toggle between a light and a dark variant of this theme.
PDF Export for Customers
A polished, paginated document to hand over
The PDF export prints the HTML rendering through Chromium and post-processes it with page numbers, headers and footers, a brand bar, and a hierarchical PDF outline. The paper size (A4, Letter, or Legal) drives the pagination and scales the diagrams down to fit onto a single page. This export format is especially intended for creating contract-relevant binding specification documents in customer contexts.
AI/LLM Comprehension
Machine-readable, so agents read and write specifications
The specbook describe command can tell an AI/LLM about the particular specfication schema, so AI agents can directly read and write the SpecBook Markdown files. An easy integration into a typical agent harness like Claude Code exists through the a dedicated /specbook skill and companion specbook mcp command
See the Practical Difference
Markdown alone is already fantastic for a specification, but it leaves every structural rule to discipline. Some recurring work-steps, done three ways: in a classic office document, in plain unconstrained Markdown, and in SpecBook format.
| Office Document | Plain Markdown | SpecBook Markdown | |
|---|---|---|---|
| Reviewing a change | Track-changes inside a binary file, reviewed outside of the code review. | A textual diff in the pull request, but no notion whether the structure is still valid. | A textual diff in the pull request plus a specbook lint run tells whether the structure is still valid. |
| Keeping structure | Structure is a styling convention, upheld by discipline alone. | Headings are free-form; nothing stops a new, undeclared section kind. | Object kinds, nesting, and properties are declared in the schema configuration and enforced on every run. |
| Cross-referencing | Manual cross-references that silently rot when a chapter is renamed. | Hand-written anchors to relative filenames, checked by nothing. | Wiki-style [[xxx]] references, resolved against object ids and names; an unresolvable one is an error. |
| Drawing a diagram | With a drawing tool, exported and updated by hand — if at all. | An embedded image or a hand-written diagram source, maintained separately. | Derived automatically from the object model, so it cannot drift away from the text. |
| Handing it over | The document is the deliverable — one format, one audience. | A separate converter run per target format, configured per project. | One specbook export run can yield HTML, PDF, normalized Markdown, and the machine-readable AST. |
| Feeding an AI agent | Extract the text first and lose the structure on the way. | The agent sees prose and has to infer the intended structure. | The agent gets the specbook describe output, so it understands the specification structure and can also write back. |
| Checking test coverage | A traceability matrix maintained by hand in yet another table. | Not available at all. | The coverage declaration reports the covered/total ratio per object kind, in the verbose log, the HTML export, and the AST. |
| Reading while writing | Save, switch application, scroll back to where you were. | Editor preview, usually per single file. | specbook preview serves the whole corpus live and replaces the document in place — scroll position and theme survive. |
Take a Sneak Preview
This is a Sneak Preview of the export of the specification of a real application: Broadcast, a live video event streaming Web application, specified in SpecBook format against the bundled standard schema configuration. Look at its Markdown sources, and then browse its two exports below: the interactive HTML export and the paginated PDF export.
Check Your Fit
SpecBook is deliberately opinionated, so it fits some projects well and others not at all. Rather than letting you find that out after the installation, here it is up-front — read both columns and decide before you spend more time.
SpecBook is for YOU, if …
- You want your specification in version control
A specification is plain Markdown here, so it branches, diffs, reviews, and merges exactly like the code it specifies — no binary document, no shared drive, no lock.
- You want a specification that is actually checked
SpecBook validates object kinds, hierarchies, property values, and references, and reports every violation as a file- and line-precise diagnostic. An invalid specification never gets exported.
- You want AI agents to read and write your specification
The AST exports (JSON, JSON5, YAML, TOON) and the
specbook describecommand give an LLM both the plain content and rules of the source format, so it can consume and produce a specification instead of guessing at one. - You need one source but several renderings
The same specification corpus becomes a filterable HTML document for developers, a paginated PDF for customers, a normalized Markdown file, and a machine-readable AST — from a single
specbook exportrun. - You like the Unix command-line style
SpecBook is a CLI with explicit commands and Unix-style options, like
specbook export -b docs/spec -o spec.pdf— scriptable, watchable, and CI-friendly. - Your domain needs its own object kinds
The YAML schema configuration defines the objects and properties a specification may contain. An extensive, bundled, standard configuration applies out of the box, and several configurations can be merged into one effective custom schema.
SpecBook is not for YOU, if …
- You want a WYSIWYG editor
SpecBook has no authoring UI at all. You write Markdown in your prefered text editor and let the tool lint, export, and preview it.
- You want free-form documents
Every object has to strictly conform to the schema configuration: allowed object kinds, allowed object nesting, mandatory object properties, and constrained values. That rigor is the whole point — and it is a cost.
- You need real-time collaborative editing
Collaboration happens through your version control system, with branches, pull requests, and reviews — not through simultaneous cursors in a shared document. But you can use a collaborative text editing application to author your Markdown files in the team.
- You are looking for a requirements management suite
There is no issue tracker, no baseline management, no approval workflow, and no user administration. SpecBook is a specification format plus its tooling only.
- You want an unopinionated document generator
SpecBook ships a fixed object model, a fixed Markdown mapping, and a fixed theming mechanism. You configure it through the schema, but you cannot make it fully neutral.
- Your specification is a single short page of prose
Below a certain size the schema configuration, the linting, and the export pipeline cost more than they return. For small specifications, plain Markdown is simply the better tool.
Easy Setup
Getting started with SpecBook takes a single command. Follow the prerequisites and the installation steps on the left, run the ready-to-copy commands shown on the right, and you are up and running within minutes.
As a prerequisite, please install the essential run-time environment Node.js (version 22.13.0 or later) for your particular platform. Everything else SpecBook needs ships inside its own package.
Then execute the command on the right under Installation, which installs the SpecBook Command-Line Interface (CLI) globally and makes the specbook command available. The Updating command keeps SpecBook up to date and the Uninstallation command reverses the installation residue-free again at any time.
Prefer not to install anything globally? Then run SpecBook straight through npx, or add it as a regular development dependency of your project, so the very same version is pinned for everyone and for your Continuous Integration.
npm install -g @rse/specbooknpm install --save-dev @rse/specbooknpx @rse/specbook lint -b docs/spec/npm update -g @rse/specbooknpm update @rse/specbooknpm uninstall -g @rse/specbooknpm uninstall --save-dev @rse/specbookPower-Up with PDF Export
The PDF export prints the HTML rendering through a Chromium-based browser, driven by Playwright. The option-less environment variable SPECBOOK_BROWSER selects which browser that is.
A value carrying a path separator is taken as an executable path and any other one as a Playwright channel name (chromium, chrome, msedge, and their beta/dev/canary variants). The variable itself has no default value: an unset one uses the downloaded Playwright Chromium and, only if that one is absent, a system-installed Google Chrome.
NOTICE:A browser is NOT required for SpecBook to work. It is needed for the PDF export alone; all other export formats are produced without it. A missing browser fails the PDF export before the specification is even parsed, and an explicitly configured browser failing to launch fails the export instead of silently falling back onto another one.
npx playwright install chromiumexport SPECBOOK_BROWSER="chrome"export SPECBOOK_BROWSER="/path/to/browser"specbook export -b docs/spec/ -o spec.pdfPower-Up with the MCP Service and Agent Skill
SpecBook can optionally be attached to an Agentic AI Coding tool as a Model-Context-Protocol (MCP) service over stdio. It then exposes its commands as the tools specbook_init, specbook_lint, specbook_export, and specbook_describe.
Because the CLI and the MCP service are both thin wrappers over the very same SpecBook API class, an agent gets exactly the functionality you get — no second, weaker code path. There is deliberately no preview tool, as that one is a long-running server.
For even more practical convenience, a specbook skill can automatically use these MCP tools.
claude plugin marketplace add rse/specbookclaude plugin install specbook@specbookNOTICE:For an even more full-featured AI integration of SpecBook, check out the sibling project Agentic Software Engineering (ASE). It has SpecBook fully pre-integrated. Check out itsase-spec-activate(based onspecbook describe),ase-spec-edit,ase-sync-import,ase-sync-export(based onspecbook export) andase-sync-reconcileskills and itsase specCLI command.
Quickly Get Started
SpecBook is a small, sharp command-line tool with exactly six commands and no hidden workflow. You author Markdown, it lints and renders. The following gives you a few hints on how to quickly get started.
From Zero to Document
The Four Steps
Start with specbook init, which generates the initial Markdown files for the object kinds the schema configuration declares. Without a -c option, the bundled standard schema configuration applies, so you can start writing immediately.
While writing, keep specbook preview running: it serves the HTML export at http://127.0.0.1:12345/ and replaces the document in place on every change, so your scroll position and your theme choice survive. Then let specbook lint guard your Continuous Integration, and let specbook export produce the deliverables.
specbook init -b docs/spec/specbook preview -b docs/spec/specbook lint -v -b docs/spec/specbook export -b docs/spec/
-o spec.html -o spec.pdfspecbook export -b docs/spec/ -o spec.yamlspecbook export -b docs/spec/ -w -o spec.htmlspecbook export -b docs/spec/
-O diagram:2,text:long -o brief.pdfCommand Catalog
specbook init-v-c-bGenerate the initial specification Markdown files from the schema configuration.
specbook lint-v-c-bParse and validate the whole corpus, reporting file- and line-precise diagnostics.
specbook export-v-c-b-o-w-ORender the specification into one or more output formats, optionally watching the sources.
specbook preview-v-c-b-O-a-pServe the HTML export live in the browser, updating it in place on every change.
specbook describe-v-c-b-e-z-f-p-oEmit the description of the SpecBook models, formats, and the effective schema.
specbook mcp-vRun the Model-Context-Protocol service over stdio for an Agentic AI Coding tool.
| Option | Environment | Meaning |
|---|---|---|
-v, --verbose [<level>] | SPECBOOK_VERBOSE | verbosity: 0 notices, 1 processing, 2 ratios, 3 details |
-c, --config <yaml-file> | SPECBOOK_CONFIG | schema configuration (glob patterns, repeatable, merged) |
-b, --basedir <dir> | SPECBOOK_BASEDIR | base directory the artifact files resolve against |
-o, --output [<format>:]<file> | SPECBOOK_OUTPUT | output file, format inferred from its extension |
-w, --watch | SPECBOOK_WATCH | re-export on every change of a source or an asset |
-O, --omit <aspect>[,...] | SPECBOOK_OMIT | omit diagrams (by type or nesting level) and long cell texts |
-a, --addr <ip-addr> | SPECBOOK_ADDR | IP address of the live preview (default 127.0.0.1) |
-p, --port <tcp-port> | SPECBOOK_PORT | TCP port of the live preview (default 12345) |
-e, --embed | SPECBOOK_EMBED | embed the schema configuration instead of referencing it |
-z, --compress [<level>] | SPECBOOK_COMPRESS | compress the emitted schema configuration (levels 1-3) |
-f, --format <format> | SPECBOOK_FORMAT | rendered Markdown (md) or raw file content (raw) |
-p, --part <part> | SPECBOOK_PART | document part: all, meta, schema, or spec |
The default value of every option --xxx can be overridden by its SPECBOOK_XXX environment variable, while an explicitly supplied option always wins. As -c is repeatable, SPECBOOK_CONFIG carries a list of patterns separated by the path delimiter of the platform. An entirely absent -c or -b falls back onto the config and basedir entries of the closest .specbook.yaml, searched from the current directory upwards.
The Specification Format
A SpecBook specification is nothing but a set of Markdown files plus one YAML file which states what those Markdown files are allowed to contain. The Markdown carries the content; the YAML carries the rules.
The Corpus
Objects as Markdown
Every object is a plain Markdown heading with a kind and a name, an optional id, an optional property list, an optional description, and optional child objects. Depending on the schema, an object kind maps onto nested sections (the complex format) or onto compact bullet point lists (the concise and group formats).
Objects reference each other through Wiki-style [[xxx]] links, resolved against the locally-unique ids and names of all objects across the whole corpus. Exactly the artifact files the schema's file fields reference are loaded — every other Markdown file below the base directory is left alone.
The Schema Configuration
Rules as YAML
The YAML schema configuration declares the allowed object kinds, how they nest, and which properties they carry. Every property value is constrained by a small expression language, and beyond the plain values the configuration also constrains the structure the objects and their references may form.
Several configurations can be merged into one effective schema (objects deeply, list elements by identity), and a bundled standard configuration applies whenever none is given at all. Violations are reported as file- and line-precise diagnostics, and both lint and export fail on any error among them — so a partial or invalid specification is never exported.
Value Constraints
| regex | /^[A-Z][A-Za-z0-9]*$/the value has to match the regular expression |
| enum | enum(draft, review, final)the value has to be one of the listed tokens |
| tags | tags(ui, api, batch)the value is a set out of the listed tokens |
| list | list(/^[A-Z]+$/)the value is a list of the constrained items |
| reference | [[requirement]]the value references a matching object |
Structural Checks
unique / present | a property value is unique among, or mandatory for, the sibling objects |
local / symmetric / acyclic | the shape a reference-valued property is allowed to form |
automaton | the child objects form a state machine: reachability, dead-ends, livelocks |
referenced | an object kind demands to be referenced — a lapse is a warning |
coverage | an object kind reports the covered/total ratio of the objects it references |
Export Formats and Interfaces
One specbook export run can write as many outputs as you list, each format inferred from its filename extension unless given explicitly as a <format>: prefix. The very same functionality is reachable through three interfaces, so the audience decides the door, never the feature set.
| Export Format | Selector | Audience |
|---|---|---|
| HTML | html | developers |
pdf | customers | |
| Markdown | md | authors |
| JSON | json | machines |
| JSON5 | json5 | machines |
| YAML | yaml | machines |
| TOON | toon | AI/LLMs |
| Interface | Shape | Audience |
|---|---|---|
| API | SpecBook.<cmd>() | scripts |
| CLI | specbook <cmd> | humans |
| MCP | specbook_<cmd>() | AI agents |
NOTICE: Export FormatsThe
-ooption can be given as often as you like, and plain-(stdout) defaults to JSON. Themdformat normalizes the entire corpus into a single Markdown document, while the AST formats attach the derived diagram of an object as a textual Gradia spec and the reference coverage it reports as its counts.With
-w, the schema configuration files, the referenced artifact files, and all embedded assets are observed, and every change re-exports once the sources stayed silent for one second. A failed re-export is reported but leaves the observe loop intact.With
-O, a brief edition leaves out what the HTML export otherwise just folds: the diagrams of a type (diagram:graph,diagram:hub,diagram:grid,diagram:code,diagram:image,diagram:listing), the diagrams from a nesting level on (diagram:1todiagram:3, plaindiagramfor all), and the long table cell texts (text:long), which then end in a grey[...]. The AST formats drop the omitted diagrams, too.
NOTICE: InterfacesAll three interfaces are backed by one and the same implementation, so a command behaves identically no matter which of them invoked it. The MCP service exposes the tools
specbook_init,specbook_lint,specbook_export, andspecbook_describe.
previewintentionally has no MCP tool, as it is a long-running server rather than a one-shot command. Usespecbook previewfrom your own shell instead.
Overview of the Architecture
SpecBook implements every command exactly once, in the API class SpecBook. The Command-Line Interface and the Model-Context-Protocol service are nothing but thin wrappers over it — so humans, scripts, and AI agents use literally the same functionality.
Software Architecture
API, CLI, MCP
There is no second, weaker code path behind any of the three interfaces. Whatever the CLI can do, the MCP service can do, and whatever both can do, your own script can do by importing the API class directly.
The one deliberate exception is preview, which is a long-running Fastify HTTP/WebSocket server and hence has no MCP tool of its own.
SpecBook.<cmd>()The facade class every command lives in — the single implementation.
specbook <cmd>A Commander-based thin wrapper for humans, scripts, and CI pipelines.
specbook_<cmd>()A Model-Context-Protocol stdio service, exposing the same commands as agent tools.
Processing Pipeline
Two Parsing Phases
Parsing is split into a syntactic and a semantic phase, so a structural mistake and a rule violation are reported as two clearly different kinds of diagnostic — each pinned to its exact file and line.
Only once both phases pass does any renderer run at all, which is why a partial or invalid specification can never reach an output file.
The Markdown of every referenced artifact file is turned into the Spec Abstract Syntax Tree: headings become objects, property lists become properties, and the prose becomes descriptions.
The AST is validated against the schema configuration: property values against the expression language, the uniqueness and presence flags among the siblings, the shape of the reference-valued properties, the state machines of the automaton kinds, the coverage a referenced kind demands, and the resolvability of every reference.
Thanks to the Contributors
SpecBook received support from the following individual contributors (in alphabetical order), coming from both the industrial Software Engineering and Open Source Software contexts. Many thanks to them for their valuable feedback and support!
Thanks to the Sponsors
SpecBook is developed in the experience context of industrial Software Engineering at the msg group and in the educational context of the Software Engineering Academy (SEA), supported by msg Research and SEA. Many thanks to them for their support!
See Also the Sibling Projects
SpecBook does not stand alone: it renders its diagrams with a dedicated sibling project, and it fits into a larger toolkit for combining Agentic AI Coding with traditional Software Engineering.
