
SpecBook
Markdown-based Specification Format
specbook.tools

About
SpecBook defines a generic, Markdown-based specification
format which can be configured for the specifications of particular
contexts through a YAML-based schema configuration. SpecBook allows
specifications to be initialized, linted, exported (JSON, JSON5,
YAML, TOON, HTML, PDF, and normalized Markdown), previewed (HTML, live
in the browser), queried (ASTq selectors on the AST), and described
to LLMs, while shareable schema configurations can be searched on npm
and GitHub.
SpecBook ships with an API class with methods <xxx>(), a
CLI with commands specbook <xxx>, and an MCP service with tools
specbook_<xxx>().
SpecBook provides the following distinct features:
-
Hierarchical Object Model:
A specification is a tree of typed objects, each with a kind and
name, an optional id, optional properties, an optional description, and
optional child objects. The allowed object hierarchy is defined per
context by the YAML schema configuration.
-
Versatile Object to Markdown Mapping:
Objects are authored as plain Markdown headings, property lists,
and description prose. The objects can be mapped to nested sections
("complex" format) or compact bullet point lists ("concise" and
"group" format).
-
Wiki-Style Object Linking:
Objects can hierarchically reference each other through Wiki-style
[[xxx]] references, which are resolved against the locally unique
ids and names of all objects. In the HTML and PDF exports they become
navigable links onto precise anchors.
-
Strict Validation with Custom Schema:
The YAML schema configuration strictly 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 and 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, while the reference coverage an object kind
demands is reported as a warning only. A bundled standard schema
configuration applies if no particular one is given.
-
Object Model Diagram Visualization:
Object kinds can declare one or more "graph", "hub", "grid", "state",
"layer", "slice", "tree", "matrix", "sequence", "petri", or "gantt" diagrams in
the schema, whose nodes and edges are automatically derived from the
object model and its references. The diagrams are rendered with the
sibling project Gradia, which is
specialized in rendering object models.
-
CLI, MCP, and API Interface:
All commands are implemented once in the API class SpecBook, on
which both the CLI and the MCP service are just thin wrappers.
This way, humans, scripts, and AI agents use exactly the same
functionality.
-
AST Exports for AI/LLMs:
The parsed specification Abstract Syntax Tree (AST) can be exported in
JSON, JSON5, YAML, or TOON format for machine consumption, with the
derived diagram of an object attached to it as a textual Gradia spec
and the reference coverage it reports attached as its counts.
Together with the describe command, which explains the models and
formats, this enables LLMs to both read and write specifications.