rulebook

Your code already knows the business rules. Now everyone can read them.

rulebook gives your coding agent the skills to find every rule in a codebase, write it in plain words, and cite the exact lines that prove it. A small companion then notices when your edits change one.

npx skills add GregoryBabonaux/rulebook
Other ways to install

Works with Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Mistral Vibe and any agent that reads SKILL.md.

src/orders/refund.js

6// Customers have 30 days to ask for a refund.
7function canRequestRefund(order, now = Date.now()) {
8  if (!order.deliveredAt) return false;
9  return (now - order.deliveredAt) / DAY <= config.REFUND_WINDOW_DAYS;
10}

config/shop.json · "REFUND_WINDOW_DAYS": 14

ORD-R001 · timing

Refund only up to 14 days after delivery

The comment above the code announces 30 days; the code applies the configured 14. The rule follows the code.

Open question: is the comment a mistake to fix?

Point at a piece of evidence to see the line it cites.

One document for the whole team

The rulebook is a single HTML file: it opens offline, goes by e-mail and prints to PDF. Product owners read the rules; developers follow the evidence to the line.

The document: a refund rule with its context, edge cases, contradictory evidence and an open question
The interactive map of domains, policies and rules
A map you can unfold and rearrange, branch by branch.
The dashboard in dark mode: rules per domain coloured by confidence, decision points examined
A dashboard: confidence per domain, what changed, what to decide.

Screenshots from a fictional shop full of traps; the sample document is in French, yours speaks your project's language.

Three passes, each one checked

  1. Map the domains

    Orders, pricing, accounts: the capabilities your business talks about, with the folders where each one's code lives.

    rulebook-map
  2. Extract the rules

    Every decision point the scan finds is either a rule card or set aside with a reason. A blind audit then re-reads each card against the code it cites.

    rulebook-extract
  3. Find the edge cases

    What happens on the last day, at the exact limit, with a missing value: written as Given, when, then.

    rulebook-edge-cases

While you code, the companion runs after each edit and before each commit. When code behind a rule moves, one line appears: ORD-R001 may have changed (refund.js) → rulebook/inbox.md. rulebook-sync updates the cards, never silently.

When you share, rulebook-publish builds the document, and the OKF export hands the same rules to other tools.

Measured, not promised

The skills were rewritten after each measurement on a real Laravel project: the same domain, extracted again from scratch, then audited blind.

Cards failing the first audit
49 %16–19 %
Decision points examined
53196 of 196
Rules found on that domain
4362–67

Five runs, October 2026. Details and caveats in tests/skills/runs.

The data knows things the code doesn't

The first time a skill runs, it offers to read your data: a database your agent reaches through an MCP server, a SQL dump or a JSON export. It asks once and remembers. Read only, with limits, and never a name or an e-mail copied into the rulebook.

PRC-R005 · validation

Books use the reduced VAT rate

data — reference:products.vat_rate `category = 'book' AND vat_rate <> 0.055`

Open question: the book with id 2 is still at 20 %. Correct it?

Rules other tools can use

rulebook export okf writes the rulebook as an Open Knowledge Format bundle: one Markdown file per domain, policy and rule, with its sources, its audit and its history. Data catalogs, wikis and other agents read it without knowing rulebook.

---
type: Business Rule
title: "Refund only up to 14 days after delivery"
status: stable
verified: { by: process:rulebook-blind-audit, at: 2026-10-16T00:00:00Z }
sources:
  - id: e1
    resource: "src/orders/refund.js#L9"
---

Install

Skills for Codex, Cursor, Gemini CLI, Copilot, Mistral Vibe and the rest, in the project or globally with -g.

npx skills add GregoryBabonaux/rulebook

Then, in your project, turn on the companion. It shows what it will write and waits for --yes.

npx rulebook-cli init

And ask your agent: “Map the business domains of this codebase.”