This is the full developer documentation for Ashlar
# Overview
> Ashlar is the rules for designing and building software with agents, for TypeScript repositories. It checks every change against rules that came from corrections, and keeps what agents need to know.
Ashlar is the rules for designing and building software with agents. It lints a TypeScript repository and reads its import graph, and it keeps a baseline of each file's breaks that may only shrink: old code stays as it is, and no file gets worse. Every rule comes from a correction a person made, and each tells the agent what to do instead. Ashlar also keeps the knowledge an agent needs before it changes a part of the code: who owns it, what people decided about it, and what nobody has written down yet.
## What it looks like
[Section titled “What it looks like”](#what-it-looks-like)
An agent adds a comment to `src/total.ts`, and the check fails:
Terminal
```console
$ pnpm exec ashlar check
Ashlar checked 1 file in 0.1 s: 1 count rose.
no-comment in src/total.ts: 1, up from 0
src/total.ts:1:1
Comments go stale and nothing checks them. Rename it, or write a test. Git leads from any line to the item or task that wrote it.
```
The check exits with 1. The last line is the message the agent reads, and it says what to do instead.
## What's inside
[Section titled “What's inside”](#whats-inside)
| Feature | What it does |
| ----------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
| [Rules](/concepts/rules/) | Twelve rules, from no comments and short files to which folder may import which, each with the message an agent reads when it fires. |
| [The ratchet](/concepts/ratchet/) | A baseline of each file's breaks per rule, which `ashlar check` holds every change to and `--shrink` only ever lowers. |
| [The ledger](/concepts/corrections/) | Each rule, the correction it came from, the test that holds its case, and the prose it replaced. |
| Affected tests | `ashlar affected` lists the tests a change reaches, through imports, stylesheets, setup files and builds. |
| [The feature map](/concepts/feature-map/) | Each feature folder with its name, its reach script (the way a person gets to it in the app) and its tests. |
| Drive | `ashlar drive` walks a feature's reach script through `rehearse drive`, or the project's own drive command, and stops at the first step that fails. |
| [Rehearse](/guides/rehearse/) | `ashlar dependents` tells Rehearse what a change reaches, and each reach script becomes a flow Rehearse runs (from Rehearse 0.3.0). |
| [Onboarding](/concepts/onboarding/) | A guide written from the code, `DECISIONS.md` and folder rules, with every unknown turned into a question for its owner. |
| [Briefs](/guides/brief/) | `ashlar brief` prints only what an agent needs before it changes some files: the rules there, the decisions and the open questions. |
| Snapshot | `ashlar snapshot` prints where things stand today, and keeps nothing. |
| [Agent skill](/agent-skill/) | Two skills for coding agents: check your own work in the running app, and read your brief and keep decisions. |
| [JSON contract](/reference/json/) | Every command but `skill` prints one JSON value with `--json`, with a version and a JSON Schema. |
## What it runs on
[Section titled “What it runs on”](#what-it-runs-on)
Ashlar checks TypeScript. A repository can be any folder of TypeScript code. An app in it names its stack, and the stack says where its two sides live:
| Stack | Main side | Renderer side | Shared |
| ---------- | ---------------- | -------------------- | --------- |
| `electron` | `electron-main/` | `electron-renderer/` | `shared/` |
| `tauri` | `src-tauri/` | `src/` | `shared/` |
| `web` | `server/` | `client/` | `shared/` |
Python comes in v2. Ashlar needs Node 22.18 or later and Git.
Ashlar is not published to npm: you build a tarball from its repository and install that. [Get started](/get-started/) shows how.
[Kurvball](https://www.kurvball.ca), where a team agrees on what to build, runs Ashlar on its Tauri desktop app, its API and its worker. See [Kurvball](/examples/kurvball/) for its config and what each command printed there. Other tools, such as [Rehearse](/guides/rehearse/), read Ashlar only through the commands that print JSON.
Ashlar is open source under the [MIT licence](https://github.com/kurvball/ashlar/blob/main/LICENSE), copyright 2026 Kurvball. Questions and ideas go to [Discussions](https://github.com/kurvball/ashlar/discussions), and bugs to [issues](https://github.com/kurvball/ashlar/issues/new/choose).
## Next steps
[Section titled “Next steps”](#next-steps)
[Get started](/get-started/)Install Ashlar from a tarball, check a small project, and see a rule fail with its message.
[Rules](/concepts/rules/)What each rule checks, where it applies, and how a project turns one off or rewords it.
[Adopt Ashlar in an existing repository](/guides/adopt/)Take a baseline of the breaks you have, then keep every file from getting worse.
[CLI reference](/reference/cli/)Every command and its flags, generated from the usage text Ashlar prints.
# Not found
> This page isn't in Ashlar's docs. Start from the overview, or search above.
# Agent skill
> The two skills Ashlar writes for coding agents. The verify skill checks work in the running app; the onboard skill reads the brief first and keeps what people decide.
Ashlar serves agents the same facts it serves people. Besides the skills below, the whole site is text for an agent at [`llms.txt`](/llms.txt): a summary and the pages, grouped as in the sidebar, with the complete text in [`llms-full.txt`](/llms-full.txt) and a shorter one in [`llms-small.txt`](/llms-small.txt). The [JSON contract](/reference/json/) describes what every command prints with `--json`.
## In a repository
[Section titled “In a repository”](#in-a-repository)
Ashlar prints two skills for coding agents, written for the project it runs in. `--write` puts each where Claude Code finds it:
Terminal
```console
$ pnpm exec ashlar skill verify --write
Wrote .claude/skills/verify/SKILL.md.
$ pnpm exec ashlar skill onboard --write
Wrote .claude/skills/onboard/SKILL.md.
```
Each file opens with the skill's name and the description an agent matches its task against:
.claude/skills/verify/SKILL.md
```markdown
---
name: verify
description: Check your own work in the running app before you report it finished. Use it when your item or task changes what the developer sees or does. Find the features it changes on the feature map, drive the running work through them, and show what you saw: screens and a short video.
---
# Verify your work
Tests say the code does what they check. This says the work does what the developer will see. Drive the
running app the way the developer reaches it, then show what you saw, so the review reads proof, not
prose.
```
## Why skills
[Section titled “Why skills”](#why-skills)
Rules catch what an agent did wrong after it wrote it. Some work has to be done right before then: checking a change in the running app, or learning what an area needs before changing it. A skill is where an agent reads how.
Ashlar writes each skill from the project's config, so it names commands that work in that repository: the way to run Ashlar, the project's drive command, and the project's own way to attach proof. Writing it again after an upgrade keeps it in step with the Ashlar the project runs.
## The verify skill
[Section titled “The verify skill”](#the-verify-skill)
`ashlar skill verify` tells an agent to check its own work before it reports it finished:
1. **Find the features your work changes.** Run `ashlar map`, and say each feature by its name on the map.
2. **Drive the running work.** Walk each changed feature's reach with `ashlar drive `, then drive through what the work changed and read the snapshot. If a reach stops, fix the work, not the reach.
3. **Take screens and a short video.** A screen of each state the work changed, in the light scheme and the dark one, and a video under a minute of the developer's way through the change.
4. **Name them in your report.** For each file, the feature it shows and one line on what it shows.
When the config names a drive command, or the project has a `rehearse.yaml` (then the command is `rehearse drive`, and the skill adds how Rehearse runs each reach as a flow), step 2 spells out its commands:
.claude/skills/verify/SKILL.md
```markdown
The project drives its running app with `pnpm drive`. The first command starts the app on a scratch home
with a seeded scenario, and the app stays up between commands until `pnpm drive stop`:
- `pnpm drive click --name "Save"` clicks the one element with that accessible name. Add
`--role button` when more than one element has it.
- `pnpm drive type "A first note"` types into what has focus.
```
Without one, it says so, and asks the agent to use the project's own tooling:
.claude/skills/verify/SKILL.md
```markdown
This project has no drive command yet, so `pnpm exec ashlar drive` can’t walk its features. Run the work with the
project’s own tooling, and take the screens and the video with it.
```
It also tells the agent how to write a reach script when it adds a feature folder, since `ashlar check` counts a feature with none. See [The feature map](/concepts/feature-map/).
### Your own attach section
[Section titled “Your own attach section”](#your-own-attach-section)
Step 4 is where a project's tools differ: one attaches proof to a pull request, another to a task in its own app. `skills.verify.attach` names a Markdown file whose text replaces step 4:
ashlar.config.ts
```diff
import { defineConfig } from '@kurvball/ashlar';
export default defineConfig({
include: ['desktop'],
apps: [{ root: 'desktop', stack: 'tauri' }],
drive: 'pnpm drive',
+ skills: { verify: { attach: 'docs/attach.md' } },
});
```
docs/attach.md
```markdown
## 4. Attach them to the pull request
Attach each screen and the video to the pull request, with one line saying what it shows.
```
The skill then ends with that section, after "Save them in your worktree, and don’t commit them." A path with no file behind it stops the command:
Terminal
```console
$ pnpm exec ashlar skill verify
skills.verify.attach names docs/attach.md, and there is no such file.
```
An attach section can name the tool an agent hands its screens to, or ask for more when a change touches a state machine.
## The onboard skill
[Section titled “The onboard skill”](#the-onboard-skill)
`ashlar skill onboard` tells an agent to learn an area before it changes it, and to keep what people decide:
* Before changing files, run `ashlar brief` on them, and follow what it says.
* When a person says how something should be done, and it should outlive the task, add one line to `DECISIONS.md` with the date, their handle, the area and the kind. Only on a person's word, never on a guess.
* A rule for one folder can go in `.claude/rules/.md` instead, with `paths:` in its frontmatter, and `gotcha:` when it guards against a mistake made before.
* Never put a secret, a credential, a token or an account detail in the repository, and never edit the generated guide.
An excerpt:
.claude/skills/onboard/SKILL.md
````markdown
# Know the area before you change it
Before you change files, run `pnpm exec ashlar brief `. It prints only what that area needs:
the data rules, the rules that apply there, the folder rules and their gotchas, the decisions people made
about it, the features it touches and the questions still open there. Follow what it says. It never holds
access or account details, and you never ask for them.
## When a person decides something
When a person tells you how something should be done, and it should outlive your task, add one line to
`DECISIONS.md` with today's date, their handle, the area and the kind:
```markdown
- 2026-12-03 @their-handle [src/area] rule: What they decided, in their words.
```
````
It names the file `onboard.decisions` sets, `DECISIONS.md` unless the config says otherwise. See [Onboarding](/concepts/onboarding/).
## Print, write and replace
[Section titled “Print, write and replace”](#print-write-and-replace)
Without `--write`, `ashlar skill verify` and `ashlar skill onboard` print the skill. `skill` is the one command that takes no `--json`.
`--write` writes `.claude/skills/verify/SKILL.md` or `.claude/skills/onboard/SKILL.md`. It writes nothing when the file already holds Ashlar's skill, and refuses to replace a file that differs unless you give `--force`:
Terminal
```console
$ pnpm exec ashlar skill verify --write
.claude/skills/verify/SKILL.md is already Ashlar's skill.
$ pnpm exec ashlar skill verify --write
.claude/skills/verify/SKILL.md differs from Ashlar's verify skill: give `--force` to replace it with Ashlar's.
$ pnpm exec ashlar skill verify --write --force
Replaced .claude/skills/verify/SKILL.md with Ashlar's skill.
```
The refusal exits with 2. Keep a project's own words in the attach file, not in `SKILL.md`, so writing the skill again after an upgrade loses nothing. Ashlar writes skills only inside the project, and refuses a path that leads out of it through a link.
## How the skills run Ashlar
[Section titled “How the skills run Ashlar”](#how-the-skills-run-ashlar)
The skills name the way to run Ashlar that fits the project's lockfile, found in the project's folder or the folders above it, up to the repository's root:
| Lockfile | Command |
| ------------------------- | ------------------------- |
| `pnpm-lock.yaml` | `pnpm exec ashlar` |
| `yarn.lock` | `yarn ashlar` |
| `bun.lock` or `bun.lockb` | `bun run ashlar` |
| any other, or none | `npx --no-install ashlar` |
They never say a bare `npx ashlar`, which would fetch an unrelated package from npm.
## Related
[Section titled “Related”](#related)
* [The feature map](/concepts/feature-map/): what the verify skill drives.
* [Onboarding](/concepts/onboarding/): the brief and the decisions the onboard skill keeps.
* [CLI reference](/reference/cli/)
# Changelog
> What changed in each version of Ashlar, copied from CHANGELOG.md.
Ashlar follows [semantic versioning](https://semver.org/spec/v2.0.0.html), and this page is `CHANGELOG.md`.
## 1.2.1
[Section titled “1.2.1”](#121)
*Released 2026-12-04.*
### Patch Changes
[Section titled “Patch Changes”](#patch-changes)
* The docs gain Recipes (run the check in GitHub Actions, give a library or a CLI its areas, keep fetch calls in the client), a title on every code block, and samples that a test runs. CI checks the docs' voice rules, and fails a major change that has no upgrade-guide entry.
* The docs follow Kurvball's docs standard: a sidebar in five groups (Start, Learn, Do, Look up, For agents), a short Get started and a Tutorial, an Agent skill page with llms.txt for agents, an Edit page link on every page, the documented version in the header, and a type on every page that the docs build checks.
* Every reference entry in the docs says the version it arrived in: each command, config key, JSON output and later JSON field. A new one reads "unreleased" until the release that ships it.
## 1.2.0
[Section titled “1.2.0”](#120)
*Released 2026-12-04.*
### Minor Changes
[Section titled “Minor Changes”](#minor-changes)
* `ashlar --version` prints the version that runs. `ashlar check` warns on stderr when an app's main side has files but none sits in a service area, where public-api-only used to count zero in silence (for example `main: ['.']` with the default areas). The adoption guide installs from the release's address and covers libraries and CLIs, a `fetch` bridge, counts and breaks, which branch a change is compared with, retaking the baseline, and the onboarding guide.
## 1.1.3
[Section titled “1.1.3”](#113)
*Released 2026-12-04.*
### Patch Changes
[Section titled “Patch Changes”](#patch-changes-1)
* The docs moved to , and package.json's homepage points there.
## 1.1.2
[Section titled “1.1.2”](#112)
*Released 2026-12-03.*
### Patch Changes
[Section titled “Patch Changes”](#patch-changes-2)
* Ashlar is MIT-licensed, copyright Kurvball. Contributing says what is likely to be accepted and where each request goes (questions and ideas to Discussions), with an AI policy, reply times, a private address for security and conduct reports (), and a supported-versions rule.
## 1.1.1
[Section titled “1.1.1”](#111)
*Released 2026-12-03.*
### Patch Changes
[Section titled “Patch Changes”](#patch-changes-3)
* The docs are on GitHub Pages at , and package.json's homepage points there. Every docs build checks each internal link and anchor of the built site.
## 1.1.0
[Section titled “1.1.0”](#110)
*Released 2026-12-03.*
### Minor Changes
[Section titled “Minor Changes”](#minor-changes-1)
* The package is now `@kurvball/ashlar`, made by Kurvball (), and its repository is . Import from `@kurvball/ashlar` and `@kurvball/ashlar/reach`, and install the tarball `kurvball-ashlar-.tgz`. The command stays `ashlar`.
### Patch Changes
[Section titled “Patch Changes”](#patch-changes-4)
* The docs, examples and changelog no longer name the private app Ashlar was first built in, and lead with Kurvball (). CI fails when a file names a private project.
## 1.0.2
[Section titled “1.0.2”](#102)
*Released 2026-12-03.*
### Patch Changes
[Section titled “Patch Changes”](#patch-changes-5)
* A release pipeline: Changesets, a release workflow that tags, writes the GitHub Release and attaches the packed tarball, and RELEASING.md for releases and hotfixes.
## \[1.0.1] - 2026-12-03
[Section titled “\[1.0.1\] - 2026-12-03”](#101---2026-12-03)
### Fixed
[Section titled “Fixed”](#fixed)
* `ashlar drive` through Rehearse sends `rehearse drive start` after its first `stop`, as Rehearse's drive needs, and takes a first `stop` that finds nothing driven (`not_running`) as nothing to stop, not as a drive Rehearse lacks. A failed `start` says what Rehearse said, gives it three minutes, and stops anything it left; a first `stop` that Rehearse answers at all lets the walk go on.
* Checked against Rehearse 0.3.0's own `drive`: a reach walked to its end, a step that failed stopped with Rehearse's words, and a project with no service said why `start` couldn't start it.
## \[1.0.0] - 2026-12-03
[Section titled “\[1.0.0\] - 2026-12-03”](#100---2026-12-03)
Ashlar fills Rehearse's blocks, and driving moves to Rehearse. Kurvball and a second, private app both run on this version from scratch clones.
### Added
[Section titled “Added”](#added)
* `ashlar dependents --json`: every file that reaches each file through imports, and the reach script of each feature those files sit in, in Rehearse's `dependents` contract. Rehearse runs it for `rehearse list --affected` whenever a project has `ashlar.config.*` and an `ashlar` binary.
* `ashlar affected --json` lists the features a change reaches (`features`), each with the reach script Rehearse runs as its flow.
* `ashlar rehearse [--json]`: the blocks of `rehearse.yaml` Ashlar fills. Each feature's reach script is a flow that covers its feature's folder; `--json` adds each flow as Rehearse's flow schema reads it.
* Gotchas guarded by Rehearse: a scenario named `*.guard.flow.yaml` or `*.guard.rehearse.yaml` is a gotcha of its folder in the guide and in briefs (`onboard.guards` names other patterns), and a folder rule can point at its guard with `guard:` in its frontmatter.
* `onboard.guards` in the config, and `guard` on each folder rule in the `onboard` and `brief` JSON (null when there is none).
* `schema/dependents.v1.json` and `schema/rehearse.v1.json`, for the two commands that answer to Rehearse.
* Rehearse's v1 schemas, vendored in `test/fixtures/rehearse/`, and tests that validate both commands' output against them.
* A guide, "Use Ashlar with Rehearse".
### Changed
[Section titled “Changed”](#changed)
* Driving moves to Rehearse. With a `rehearse.yaml` and no `drive` in the config, `ashlar drive` walks a reach through `rehearse drive`, and says plainly when Rehearse can't answer yet; the verify skill gives a project that rehearses Rehearse's own drive steps. A `drive` in the config still wins, so a project keeps its own until it chooses Rehearse's. Rehearse reads flows and answers `drive` from its 0.3.0; today it reads Ashlar's graph for `list --affected`.
* Both examples' `prove.sh` run the adapter and validate its output against Rehearse's schemas, and every other answer against Ashlar's own.
## \[0.4.0] - 2026-12-03
[Section titled “\[0.4.0\] - 2026-12-03”](#040---2026-12-03)
Kurvball and a second, private app, run on Ashlar and documented.
### Added
[Section titled “Added”](#added-1)
* The private app's example says what that app changes to take this version: its imports, its dependency, its framework detection, its rule messages, its verify skill's attach section and its onboarding owner.
* `examples/kurvball/README.md` says what the map, `onboard` and briefs show for an API and a worker with no renderer, and how Ashlar sits beside Kurvball's own architecture gate.
* The docs' example pages give every command's answer on each clone, onboarding included.
* Both `prove.sh` validate every answer against Ashlar's own schemas (`examples/validate.mjs`), and the private app's fails if any rule's count is above zero, as that app keeps no baseline.
* Kurvball's config leaves generated code out (`generated` in `ignore`).
## \[0.3.0] - 2026-12-03
[Section titled “\[0.3.0\] - 2026-12-03”](#030---2026-12-03)
The docs site, and the JSON contract every command prints.
### Added
[Section titled “Added”](#added-2)
* A docs site in `docs/`, built with Astro Starlight: an overview, a quickstart, concepts (rules, the ratchet, the feature map, corrections, onboarding), guides, a reference (the CLI, the config, the JSON outputs), the examples, the agent skills and this changelog. `pnpm docs:build` fails on any warning or broken link, and CI runs it.
* A JSON Schema for each command's `--json` output in `schema/`, shipped in the package as `/schema/.v1.json`. A test runs each command and validates what it prints.
* The CLI reference, the JSON reference and the changelog page are generated from the usage text, the schemas and this file, so they can't drift. A test checks that the config reference names every key.
### Changed
[Section titled “Changed”](#changed-1)
* `check`, `affected`, `move` and `drive` now print a `version`, as `ledger` and `map` did. The field is new; nothing else in their output changed.
## \[0.2.0] - 2026-12-03
[Section titled “\[0.2.0\] - 2026-12-03”](#020---2026-12-03)
Onboarding: the knowledge people and agents need about a codebase, from one source.
### Added
[Section titled “Added”](#added-3)
* `DECISIONS.md`: one line per decision a person made, with its date, owner, areas and kind (`decision`, `rule`, `trust`, `access`, `owner` or `setup`). A line that doesn't parse is an error naming its line.
* Folder rules in `.claude/rules/*.md`, scoped by Claude Code's `paths:` frontmatter, with an optional `gotcha`, `owner` and `date`.
* `ashlar onboard` writes a guide from the map, the decisions and the rules: what the system is, a page per area, and every unknown as a `TODO(@owner)` question routed to its owner. `--check` fails when the guide is stale or was edited by hand; `--json` prints its model, questions included.
* `ashlar brief ` prints only what an agent needs for those files: the data rules, the rules that apply there, the folder rules and gotchas, the decisions (never `access` lines), the features and the open questions.
* `ashlar snapshot` prints where things stand today. It writes nothing.
* `ashlar skill onboard`: read your brief before you change files, and keep what people decide.
* `onboard` in the config: `out`, `decisions`, `rules`, `owner`, `owners`, `areas`, `documents` and `dataRules`.
* A knowledge file that holds something shaped like a secret is refused, naming its file and line.
* Ashlar onboards itself: its `DECISIONS.md`, two folder rules and its guide in `onboarding/`, checked by `pnpm lint`. Both examples onboard their clones.
## \[0.1.0] - 2026-12-03
[Section titled “\[0.1.0\] - 2026-12-03”](#010---2026-12-03)
Ashlar installs and runs on its own, from a packed tarball.
### Added
[Section titled “Added”](#added-4)
* The config is checked as it loads: an unknown key or a value of the wrong type gets one line naming the key, and every problem is listed at once.
* Ashlar also reads `ashlar.config.mts`, `ashlar.config.js` and `ashlar.config.mjs`.
* `rules` in the config turns a rule off for the whole project, as in `rules: { 'no-comment': 'off' }`. No comment in code can.
* `messages` in the config replaces the message a rule prints.
* Each stack names the packages that reach the other side, and `client-only` and `shared-is-pure` use them: `electron` for Electron, `@tauri-apps/api` and `@tauri-apps/plugin-*` for Tauri, none for web. An app's `bridge.packages` replaces them.
* An app may have no renderer (`renderer: []`), as an API has none.
* `skills.verify.attach` in the config names a file whose text becomes the verify skill's attach section. Without one, the skill asks the agent to name its screens and video in its report.
* Ashlar checks its own source with its own rules (`pnpm lint`), and a test keeps the names of the projects that use it out of its source.
* A test pins the names each entry point exports.
* `examples/`: two projects' `ashlar.config.ts`, each with a `prove.sh` that runs Ashlar on a scratch clone of it. One also seeds one break per rule and checks each fires.
* A smoke test (`pnpm smoke`) packs Ashlar, installs the tarball in a fresh project and runs its commands there.
* Open-source files: this changelog, a README, CONTRIBUTING, a Code of Conduct, a security policy, issue templates and a pull request template.
* CI on GitHub Actions.
### Changed
[Section titled “Changed”](#changed-2)
* The package is renamed from its name inside the app it came from to `ashlarjs`. The command stays `ashlar`. Imports read `from 'ashlarjs'` and `from 'ashlarjs/reach'`.
* Ashlar builds to `dist/`, JavaScript with type declarations, and the `ashlar` bin and the exports point there.
* `ledger.json` moved to the package root, and the package exports it as `/ledger.json`.
* Rule messages no longer name the hooks of the app Ashlar came from.
* The verify skill ends at screens and a video. That app's own attach section moved to its example.
* Where a project has no lockfile Ashlar knows, the skill runs `npx --no-install ashlar`, never a bare `npx ashlar`, which would fetch an unrelated package. With Bun it runs `bun run ashlar`.
### Removed
[Section titled “Removed”](#removed)
* The Electron stack's default builds (`test/ui/**` and `*.electron.test.ts`). A config states its builds.
## \[0.0.0] - 2026-12-03
[Section titled “\[0.0.0\] - 2026-12-03”](#000---2026-12-03)
Extracted, with its history, from the app it was first built in.
# Corrections
> Every Ashlar rule comes from a correction a person made. The ledger records each one, with the case it came from as a test, the prose it replaced and the message agents read.
## In a repository
[Section titled “In a repository”](#in-a-repository)
Ashlar ships its ledger, `ledger.json`. Each entry is a rule, or a check Ashlar makes from the import graph, and the correction it came from:
ledger.json
```json
{
"id": "no-timer",
"rule": true,
"says": "No timers in features: a hook from primitives/, named for what it waits on, instead",
"applies": "features",
"corrected": "A setTimeout(…, 0) added for one flicker grew to 183 timers, and six places moved focus after a render, each in its own way",
"by": "developer",
"replaces": null,
"case": {
"file": "src/plugin/features.test.ts",
"test": "the column's sheet focused two frames later"
},
"message": "A timer patches over a render you don't control. Use a hook from `primitives/`, named for what it waits on."
}
```
`ashlar ledger` prints it for a person to read:
Terminal
```console
$ pnpm exec ashlar ledger
…
no-timer: No timers in features: a hook from primitives/, named for what it waits on, instead, in features.
It corrected: A setTimeout(…, 0) added for one flicker grew to 183 timers, and six places moved focus after a render, each in its own way.
Its case: src/plugin/features.test.ts, “the column's sheet focused two frames later”.
A timer patches over a render you don't control. Use a hook from `primitives/`, named for what it waits on.
…
```
## Why rules come from corrections
[Section titled “Why rules come from corrections”](#why-rules-come-from-corrections)
An agent's mistake that a person corrects once will come back in the next task, and in the next agent. Prose doesn't stop it: a line in `CLAUDE.md` or a review comment goes stale, and nothing checks that anyone read it. The `no-comment` rule came from 15,875 comment lines, 1,611 of them citing a decision, and agents writing down why a quick fix was justified.
So a correction becomes a rule, and a rule holds four things:
* **The correction.** A person corrected an agent's work and didn't want to do it again. A rule with no correction behind it isn't taken.
* **What to do instead.** The message names the replacement, not only the mistake, in one or two sentences. It is what the agent reads when the rule fires.
* **Its case, as a test.** The code that went wrong becomes a test named after what went wrong, and the rule fires on it. The ledger names that test, and a test checks that it is there to run.
* **A person's yes.** The developer agrees to each rule before it is added.
A rule also replaces the prose it came from, so the instruction lives in one place, where it is checked.
## What an entry holds
[Section titled “What an entry holds”](#what-an-entry-holds)
| Field | What it holds |
| ----------- | ----------------------------------------------------------------------------------------- |
| `id` | The rule's name, as `check` prints it. |
| `rule` | `true` for a rule `check` counts; `false` for a check Ashlar makes from the import graph. |
| `says` | The rule in one line. |
| `applies` | Where it holds, such as `features` or `all code`. |
| `corrected` | What went wrong, with counts when there are some. |
| `by` | Who corrected it: `developer`, `lead` or `gate`. |
| `replaces` | The prose instruction it replaced, or `null`. |
| `case` | The test that holds its case: its file and its name. |
| `message` | What an agent reads when it fires. |
Two entries aren't rules. `affected` lists the tests a change reaches through the import graph, and `builds` leaves a screen or Electron test out when the change doesn't touch its build's inputs. `affected` replaced a line agents were given in prose, and `ashlar ledger` says so:
Terminal
```console
affected: A builder and the item gate run the tests the import graph says a change reaches, in every change.
It corrected: Decisions 161 and 163: builders ran whole suites, eleven of them spending 394 of their 439 minutes of commands in test runs, and their prompts then told them in prose to pick the tests that cover their change.
Its case: src/affected.test.ts, “lists every test that reaches a changed file through the graph”.
It replaced: “Run only the test files you wrote or changed, each named by its path, never the whole test suite or a whole package's tests.”
A builder and the item gate run the tests the import graph says a change reaches.
```
`ashlar ledger` prints the messages your project's config sets, so it shows what your agents read. `ashlar ledger --json` prints the same entries for tools.
## When you correct an agent
[Section titled “When you correct an agent”](#when-you-correct-an-agent)
A correction can land in one of three places, depending on whose it is:
* **A rule for every project.** Open a "Rule from a correction" issue on Ashlar's repository with the case: what the agent did, the file and the code that show it, and what the rule should say. It becomes a test, a rule and a ledger entry. See [Add a rule from a correction](/guides/rule-from-a-correction/).
* **A name only one folder may use.** A `confined` entry in your config, with its message, holds it with the `named-only-in` rule. See [Rules](/concepts/rules/).
* **Something to know about one area.** A line in `DECISIONS.md` or a folder rule in `.claude/rules/`. An agent reads it in its brief before it changes that area. See [Onboarding](/concepts/onboarding/).
The same holds for turning a rule off. No comment in code can do it. If a rule is wrong for a case, change the rule and record why in the ledger, or turn it off for the whole project in the config.
## Related
[Section titled “Related”](#related)
* [Rules](/concepts/rules/): every rule and where it applies.
* [Add a rule from a correction](/guides/rule-from-a-correction/)
* [Answer questions and record decisions](/guides/decisions/)
* [CLI reference](/reference/cli/)
# The feature map
> Each feature folder with its name, its reach script (the steps a person takes to get to it in the running app) and its tests, and how ashlar drive walks a reach.
## In a repository
[Section titled “In a repository”](#in-a-repository)
A Tauri app keeps each feature in its own folder under `desktop/src/features/`. The Notes feature holds a reach script, `reach.ts`: the steps a person takes to get to it in the running app.
desktop/src/features/notes/reach.ts
```ts
import type { ReachScript } from '@kurvball/ashlar/reach';
export default {
name: 'Notes',
steps: [
{ click: 'Notes', role: 'link' },
{ click: 'New note', role: 'button' },
{ type: 'Buy bread' },
{ key: 'Enter' },
{ snapshot: 'Buy bread', role: 'listitem' },
],
} satisfies ReachScript;
```
`ashlar map` lists every feature, its reach and its proofs, the tests in its folder:
Terminal
```console
$ pnpm exec ashlar map
Notes desktop/src/features/notes
Notes › New note › “Buy bread” › Enter › Buy bread
1 proof
Settings desktop/src/features/settings
no reach script yet
0 proofs
```
Settings has no reach script yet, and `ashlar check` counts that as a break:
Terminal
```console
$ pnpm exec ashlar check
Ashlar checked 5 files in 0.2 s: 1 count rose.
feature-reach in desktop/src/features/settings/reach.ts: 1, up from 0
desktop/src/features/settings/reach.ts:1:1
Every feature folder holds a reach script, `reach.ts`: the developer's way to the feature as drive steps, ending on a snapshot of what it reaches. It is plain data that imports only types. Write one, then run it with `ashlar drive `.
```
## Why a map
[Section titled “Why a map”](#why-a-map)
An agent told to "fix the notes screen" has to guess which code that is, and how to get there to see its work. A feature on the map has one name that the developer and every agent use for the same folder, and a way to it that a run proves.
The [verify skill](/agent-skill/) builds on it. An agent finds the features its work changes on the map, walks each one's reach in the running app, and shows screens of what it saw, named by the feature's name.
## Feature folders
[Section titled “Feature folders”](#feature-folders)
A feature is a folder in an app's `features`: by default each folder in `features/` inside the renderer, such as `desktop/src/features/*` for a Tauri app at `desktop`. A repository with no `apps` has no features. See [Rules](/concepts/rules/) for how an app's layout is set.
A feature's name is the `name` its reach script gives. Until it has one, the name comes from its folder: `settings` is Settings, and `saved-searches` is Saved searches. Each feature's name is its own. A reach script whose name another feature already has, in any case, doesn't read.
A feature's proofs are the test files in its folder. A test file is one whose name ends with a suffix in the config's `tests`, which are `.test.ts` and `.test.tsx` unless it says otherwise.
## Reach scripts
[Section titled “Reach scripts”](#reach-scripts)
A reach script is `reach.ts` in the feature's folder. Its default export is `{ name, steps }`, and it imports only types. Node loads it as it is, so it imports no component and runs nothing.
Each step does one thing:
| Step | What it does |
| ----------------------------------- | --------------------------------------------------------------------------------------------------------------------- |
| `{ click: 'Save' }` | Clicks the one element with that accessible name. |
| `{ click: 'Save', role: 'button' }` | Clicks the one button with that name, when more than one element has it. |
| `{ type: 'Buy bread' }` | Types the text into what has focus. |
| `{ key: 'Meta+k' }` | Presses a key, named as Playwright names it, such as `Enter`, `Escape` or `ControlOrMeta+j`. |
| `{ snapshot: 'Buy bread' }` | Reads the element with that name from the accessibility tree, and fails when there is none. It may take a `role` too. |
The last step is a snapshot of what the reach gets to, so a run proves it got there, and no other step is one. A reach has at most 40 steps, a feature's name at most 60 characters, and an element's name at most 120. Steps name elements by the words on screen, as a snapshot shows them.
A role is one of the ARIA roles drive knows, such as `button`, `link`, `heading`, `listitem`, `dialog`, `tab` or `textbox`.
`ashlar map --json` prints each step with the drive command line it runs. See [JSON contract](/reference/json/).
## Drive a reach
[Section titled “Drive a reach”](#drive-a-reach)
Reach scripts are Ashlar's data, and [Rehearse](/guides/rehearse/) runs them: from its 0.3.0 it reads each one as a flow, runs it on the base and on your work, and compares them. When the project has a `rehearse.yaml` and names no drive command, `ashlar drive` starts Rehearse's drive and walks a reach through it, one step at a time.
A project without Rehearse names its own drive command in the config instead:
ashlar.config.ts
```diff
import { defineConfig } from '@kurvball/ashlar';
export default defineConfig({
include: ['desktop'],
apps: [{ root: 'desktop', stack: 'tauri' }],
+ drive: 'pnpm drive',
});
```
Terminal
```console
$ pnpm exec ashlar drive notes
Notes: reached in 5 steps.
```
Ashlar stops any app left running, runs each step through the drive command, and stops the app again after. It stops at the first step that fails and says which and why:
Terminal
```console
$ pnpm exec ashlar drive notes
Notes: its reach stopped at “New note”, step 2 of 5. Nothing on screen is named “New note”.
```
`--all` walks every feature, and `--scheme dark` walks in the dark colour scheme:
Terminal
```console
$ pnpm exec ashlar drive --all
Notes: reached in 5 steps.
Settings has no reach script yet: write desktop/src/features/settings/reach.ts.
1 of 2 features reached.
```
`drive` exits with 0 when every reach got there, and 1 when one didn't.
The drive command is the project's own. It starts the app on a scratch home with a seeded scenario, and it takes `click --name [--role ]`, `type `, `key `, `snapshot [--name ]`, `screenshot `, `record ` and `stop`. With `--json`, each prints its result as one JSON object. A project with no drive command still has a map: its reach scripts are data the map shows, and nothing walks them.
## Related
[Section titled “Related”](#related)
* [Write a reach script](/guides/reach-scripts/)
* [Use Ashlar with Rehearse](/guides/rehearse/): each reach becomes a flow Rehearse runs.
* [Agent skill](/agent-skill/): the verify skill drives the map.
* [Kurvball's reach scripts](/examples/kurvball/), for a project with no drive command yet.
* [CLI reference](/reference/cli/)
# Onboarding
> The knowledge people and agents need about a codebase, each kind in one home. Ashlar writes a guide from it, turns every unknown into a question for its owner, and gives each agent a brief of its area.
## In a repository
[Section titled “In a repository”](#in-a-repository)
A Tauri app has two features, Notes and Settings. Its config names the person who gets every question nobody else owns:
ashlar.config.ts
```diff
import { defineConfig } from '@kurvball/ashlar';
export default defineConfig({
include: ['desktop'],
apps: [{ root: 'desktop', stack: 'tauri' }],
+ onboard: { owner: '@ana' },
});
```
Nobody has written anything down yet, and its `package.json` has `dev` and `test` scripts. `ashlar onboard` writes the guide, and finds four things it can't answer:
Terminal
```console
$ pnpm exec ashlar onboard
Wrote the guide in docs/onboarding: 4 written, 0 removed.
2 areas, 0 decisions, 0 rules, 4 open questions: @ana 4.
```
docs/onboarding/questions.md
```markdown
## @ana
- [ ] TODO(@ana) What must an agent know before changing Notes (`desktop/src/features/notes`)? Answered by a line in DECISIONS.md: `- @you [desktop/src/features/notes] rule: what to know`, or a rule in `.claude/rules/` whose paths cover it. `know:desktop/src/features/notes`
- [ ] TODO(@ana) What must an agent know before changing Settings (`desktop/src/features/settings`)? Answered by a line in DECISIONS.md: `- @you [desktop/src/features/settings] rule: what to know`, or a rule in `.claude/rules/` whose paths cover it. `know:desktop/src/features/settings`
- [ ] TODO(@ana) Who owns what? No area names its owner yet, so every question goes to @ana. Answered by a line in DECISIONS.md: `- @you [] owner: @handle` for each area, or one for `*`. `owner:*`
- [ ] TODO(@ana) Is `README.md` current, and who keeps it? Answered by a line in DECISIONS.md: `- @you [README.md] trust: what holds`. `trust:README.md`
```
Ana answers them with lines in `DECISIONS.md`, one per decision:
DECISIONS.md
```markdown
# Decisions
- 2026-12-01 @ana [*] owner: @ana
- 2026-12-01 @ana [desktop/src/features/notes] owner: @ben
- 2026-12-02 @ben [desktop/src/features/notes] Notes are plain text: no Markdown, no rich text.
- 2026-12-02 @ana [README.md] trust: It says what the app is and how to run it.
- 2026-12-03 @ana [desktop/src/features/settings] access: @ana grants access to the signing keys.
```
and with a rule for each feature's folder, such as:
.claude/rules/desktop-src-features-settings.md
```markdown
---
paths:
- 'desktop/src/features/settings/**'
owner: '@ana'
date: 2026-12-03
gotcha: scheme-reset
---
# The scheme is saved before the window reloads
Save the colour scheme through `client/`, and wait for it, before the window reloads. A reload that came
first once reset every user's scheme to light.
```
Terminal
```console
$ pnpm exec ashlar onboard
Wrote the guide in docs/onboarding: 4 written, 0 removed.
2 areas, 4 decisions, 2 rules, 0 open questions.
```
The `access` line says who to ask, never the credential itself, and no brief shows it.
## Why onboarding
[Section titled “Why onboarding”](#why-onboarding)
What a team knows about its code lives in people's heads, in chat threads and in documents nobody keeps current. A person can ask. An agent can't, so it guesses, and a person corrects the guess.
Ashlar gives each kind of knowledge one home in the repository, where people write it and Git keeps its history. What nobody has written down becomes a question, sent to the person who owns that part of the code, instead of a guess. An agent then reads only what the files it will change need, in its brief, not a long document about everything.
The guide is generated and deterministic: it holds no dates but the decisions' own, and no owner guessed from Git. So `ashlar onboard --check` can tell when it is stale.
## The kinds of knowledge and their homes
[Section titled “The kinds of knowledge and their homes”](#the-kinds-of-knowledge-and-their-homes)
| Kind | Its home | Who writes it |
| ----------------------- | -------------------------------------------------------------------------- | ------------------------------------- |
| What the system is | The map, the layout, the workspace and package scripts | Generated by `ashlar onboard` |
| Decisions people made | `DECISIONS.md`: one line per decision, with its date, owner, area and kind | People |
| Rules scoped to folders | `.claude/rules/.md`, scoped by Claude Code's `paths:` frontmatter | People, and agents on a person's word |
| Gotchas | A folder rule marked `gotcha: ` in its frontmatter | People and agents |
| Where things stand | `ashlar snapshot`, printed for one date | Generated, never kept |
## Decisions
[Section titled “Decisions”](#decisions)
A decision is one list line in `DECISIONS.md`:
DECISIONS.md
```markdown
- 2026-12-03 @robin [src/plugin] rule: Every rule ships with the case it came from as a test.
```
* The date the decision was made, then the handle of the person who made it.
* The areas in brackets: folders or files from the repository's root, separated by commas, or `*` for the whole project.
* The kind, when it isn't a plain `decision`: `rule`, `trust` (a document is current), `access` (who grants access to what, never a credential), `owner` (the text is the owner's handle) or `setup` (how to run something).
* What was decided, in the person's words.
Add a line only on a person's word. To change a decision, edit or delete its line: Git keeps the history. Headings and paragraphs in the file are left alone, but a list line that doesn't parse stops the command and names its line:
Terminal
```console
$ pnpm exec ashlar onboard
DECISIONS.md:8 isn't a decision line: - 2026-12-03 @owner [area, another/area] kind: what was decided
```
## Folder rules
[Section titled “Folder rules”](#folder-rules)
A folder rule is a Markdown file in `.claude/rules/`, named after the folder it covers with its slashes as dashes. Its frontmatter is optional, and Ashlar reads these keys:
| Key | What it holds |
| ------------- | ------------------------------------------------------------------------------- |
| `paths` | The globs the rule covers. Without it, the rule covers every folder. |
| `gotcha` | A ticket or a short name, for a rule that guards against a mistake made before. |
| `owner` | The handle of the person who keeps it. |
| `date` | When it was written. |
| `description` | A line about it. |
Claude Code reads the same `paths:`, so an agent meets the rule when it opens those files, and Ashlar puts it in the guide and the brief for those folders.
## Areas and owners
[Section titled “Areas and owners”](#areas-and-owners)
An area is a part of the code an owner answers for: each feature and service area in an app's layout. A repository with no `apps` uses the folders `onboard.areas` names, or else each folder directly inside the `include` folders.
Each area's owner comes from the first of these that names one:
1. `onboard.owners` in the config: a folder to a handle.
2. An `owner` line in `DECISIONS.md`. The line for the deepest folder wins, and a later line wins over an earlier one for the same folder.
3. `onboard.owner`, the project's default owner, who gets every question nobody else owns.
`ashlar onboard` needs a default owner, and says so:
Terminal
```console
$ pnpm exec ashlar onboard
Name the project’s default owner, who gets every question nobody else owns: `onboard: { owner: "@handle" }` in ashlar.config.ts.
```
## Questions
[Section titled “Questions”](#questions)
Each gap becomes a question with an id, made of its kind and its area (`setup:tests` is the one exception), that stays the same from run to run:
| Id | Asked when | Answered by |
| ------------------ | ------------------------------------------------------------------------ | --------------------------------------------------------------------------------- |
| `owner:*` | No area names its owner yet. Asked once, for the whole project. | An `owner` line for each area, or one for `*` |
| `owner:` | Some areas name an owner, and this one doesn't. | An `owner` line, or `onboard.owners` |
| `reach:` | A feature folder has no reach script. | The feature's `reach.ts` |
| `know:` | No decision or folder rule covers the area. | A line for the area, such as a `rule` line, or a folder rule whose paths cover it |
| `setup:` | The app's `package.json`, or the root's, has no `dev` or `start` script. | A `setup` line, or the script |
| `setup:tests` | The root `package.json` has no `test` script. | A `setup` line, or the script |
| `trust:` | A document has no `trust` line. | A `trust` line |
The documents are the root `README.md` and each app's, unless `onboard.documents` names others.
## The guide
[Section titled “The guide”](#the-guide)
`ashlar onboard` writes the guide into `docs/onboarding/`, or the folder `onboard.out` names:
* `README.md`: what the system is (its apps, stacks and sides, its packages), how to run and check it, each area with its owner, the rules that apply where, the data rules and the decisions for the whole project.
* `areas/.md`: a page per area, named after its folder with the slashes as dashes, with its owner, its reach and proofs, its folder rules, gotchas, decisions and open questions.
* `questions.md`: every open question, grouped by its owner.
Each file opens with a line saying it is generated. Don't edit it: change the code, the decisions or the rules, then run `ashlar onboard` again. `--check` writes nothing, and fails when a file is stale or was edited by hand:
Terminal
```console
$ pnpm exec ashlar onboard --check
The guide in docs/onboarding is out of date:
docs/onboarding/README.md is stale or was edited by hand.
Run `ashlar onboard` to write it again.
```
Put `ashlar onboard --check` in your lint script, as Ashlar does for its own guide.
## Briefs
[Section titled “Briefs”](#briefs)
Before it changes files, an agent runs `ashlar brief` on them. It prints only what that area needs: the data rules, the rules that apply there, the folder rules and gotchas, the decisions, the features and the open questions.
Terminal
```console
$ pnpm exec ashlar brief desktop/src/features/settings/index.ts
# Brief for `desktop/src/features/settings/index.ts`
## Areas
- Settings (`desktop/src/features/settings`), owned by @ana
## Data rules
- Real data never enters the repository: not in code, tests, fixtures or documents.
- Secrets are never printed, logged or written into the repository.
## Ashlar’s rules here
- **no-cross-process-import**: `src/` and `src-tauri/` never import each other, not even types. Put the contract in `shared/`.
- **public-api-only**: Import another feature or area through its `index.ts`. If you need something inside it, it belongs in its index or in `shared/`.
…
## Folder rules
### The scheme is saved before the window reloads (gotcha: scheme-reset)
Save the colour scheme through `client/`, and wait for it, before the window reloads. A reload that came
first once reset every user's scheme to light.
## Features
- Settings: Settings › Colour scheme
```
A brief never holds an `access` line or an `owner` line, and nothing about other areas. The [onboard skill](/agent-skill/) tells an agent to read its brief first. See [Give an agent its brief](/guides/brief/).
## Snapshot
[Section titled “Snapshot”](#snapshot)
`ashlar snapshot` prints where things stand today, and writes nothing:
Terminal
```console
$ pnpm exec ashlar snapshot
Where things stand on 2026-12-03, at 8761e34 on main.
The ratchet holds 0 breaks in its baseline.
The map has 2 features, 2 with a reach script.
5 decisions and 2 folder rules are kept; 0 questions are open.
Areas, busiest in the last 30 days first:
desktop/src/features/notes: 1 commit, last 2026-12-03
desktop/src/features/settings: 1 commit, last 2026-12-03
This is printed for today and never kept: run it again when you need it.
```
## Secrets
[Section titled “Secrets”](#secrets)
Secrets never enter knowledge files. Every command that reads `DECISIONS.md` and the folder rules refuses a line shaped like a key, a token, a password or a private key, and names its file and line:
Terminal
```console
$ pnpm exec ashlar onboard
Secrets never enter knowledge files, and these lines look like one:
DECISIONS.md:8:45 holds what looks like a password or token.
Take the value out. Say who grants access instead, as an `access` line, never the credential.
```
The data rules at the top of the guide and of every brief say the same for code: real data never enters the repository, and secrets are never printed, logged or written into it. `onboard.dataRules` replaces them.
## Related
[Section titled “Related”](#related)
* [Answer questions and record decisions](/guides/decisions/)
* [Give an agent its brief](/guides/brief/)
* [Agent skill](/agent-skill/): the onboard skill.
* [Config reference](/reference/config/): every `onboard` key.
# The ratchet
> How Ashlar's baseline holds each file's breaks as they are today, fails any change that adds one, and only ever shrinks.
## In a repository
[Section titled “In a repository”](#in-a-repository)
A repository keeps its baseline at its root, beside `ashlar.config.ts`:
ashlar.baseline.json
```json
{
"no-comment": {
"src/cart.ts": 2,
"src/total.ts": 1
}
}
```
It holds three old comments: two in `src/cart.ts` and one in `src/total.ts`. On a branch, an agent adds `src/discount.ts`, with a comment of its own:
Terminal
```console
$ pnpm exec ashlar check
Ashlar checked 3 files in 0.1 s: 1 count rose.
no-comment in src/discount.ts: 1, up from 0
src/discount.ts:3:1
Comments go stale and nothing checks them. Rename it, or write a test. Git leads from any line to the item or task that wrote it.
```
The three old comments pass. The new one fails, because the baseline holds no comment for `src/discount.ts`.
## Why a ratchet
[Section titled “Why a ratchet”](#why-a-ratchet)
Most repositories already break some rules. Fixing every break before turning a rule on would stop all other work, and leaving the rule off lets every file get worse.
The baseline holds what is there today, file by file and rule by rule. Old code stays as it is, and no file gets worse. Each fix lowers the baseline, and it never goes back up, the way a ratchet turns one way only.
Counts are held per file, so a fix in one file can't pay for a new break in another. The baseline is a file in the repository, so a review sees it shrink.
## Take the baseline
[Section titled “Take the baseline”](#take-the-baseline)
The first `check --shrink` takes the baseline from the breaks there are:
Terminal
```console
$ pnpm exec ashlar check --shrink
Ashlar checked 2 files in 0.1 s and took the baseline: 3 breaks in ashlar.baseline.json.
$ pnpm exec ashlar check
Ashlar checked 2 files in 0.1 s: no count rose.
```
Commit `ashlar.baseline.json`. Without one, every count must stay at zero, and `check` says so.
## What `check` holds
[Section titled “What check holds”](#what-check-holds)
`ashlar check` runs the rules and reads the import graph, counts each file's breaks per rule, and fails when a count rises above what the baseline holds for that file. A file the baseline doesn't name holds none. It exits with 1 when a count rose, and 0 when none did.
Comments are held tighter. `no-comment` and `no-disable` let no new one in on the lines a branch changed, even where the file's count stays within its baseline. Here the agent took out one old comment in `src/cart.ts` and wrote a new one:
Terminal
```console
$ pnpm exec ashlar check
Ashlar checked 2 files in 0.1 s: 1 count rose.
no-comment in src/cart.ts: 1 new one on lines changed since main. None may be added, even where others went.
src/cart.ts:9:3
(1 other was there before)
Comments go stale and nothing checks them. Rename it, or write a test. Git leads from any line to the item or task that wrote it.
```
"Since main" means since the branch left `main`, `origin/main`, `master` or `origin/master`, whichever is closest. A file Git doesn't track yet counts as changed throughout.
## Lower it
[Section titled “Lower it”](#lower-it)
When a change fixes breaks, `check` notices the baseline holds more than the code has. Run `check --shrink` and commit the baseline with the fix:
Terminal
```console
$ pnpm exec ashlar check --shrink
Ashlar checked 2 files in 0.1 s: no count rose.
The baseline now holds 2 breaks.
```
`--shrink` only ever lowers each file's counts. A file that is gone drops out, and a file Git saw renamed takes its counts to its new name. When nothing is left, the baseline file is removed.
## Move a file
[Section titled “Move a file”](#move-a-file)
A file that moves arrives under its new name, while the baseline still holds its counts under the old one. `check` fails on it, and says which move takes the counts along:
Terminal
```console
$ pnpm exec ashlar check
Ashlar checked 2 files in 0.1 s: 1 count rose.
src/money/total.ts moved from src/total.ts: `ashlar move src/total.ts src/money/total.ts` takes its counts with it.
no-comment in src/money/total.ts: 1, up from 0
src/money/total.ts:1:1
Comments go stale and nothing checks them. Rename it, or write a test. Git leads from any line to the item or task that wrote it.
$ pnpm exec ashlar move src/total.ts src/money/total.ts
src/total.ts → src/money/total.ts: 1 break moved.
```
`ashlar move` takes a file or a whole folder. Each file keeps what it holds now, up to what the baseline held for it, and a move that takes in new breaks is refused. See [Move files](/guides/move-files/).
## Accept a rise
[Section titled “Accept a rise”](#accept-a-rise)
`check --accept-rise` takes each count that rose into the baseline, and says what it took in. It still lets no new comment through on changed lines, so on the branch with `src/discount.ts` it takes the count in and fails all the same:
Terminal
```console
$ pnpm exec ashlar check --accept-rise
Ashlar checked 3 files in 0.1 s: 1 count rose.
no-comment rose to 1, up from 0, in src/discount.ts: taken in with --accept-rise.
The baseline now holds 4 breaks.
no-comment in src/discount.ts: 1 new one on lines changed since main. None may be added, even where others went.
src/discount.ts:3:1
Comments go stale and nothing checks them. Rename it, or write a test. Git leads from any line to the item or task that wrote it.
```
Keep `--accept-rise` for a rise a person agreed to. Ashlar's own pull requests never use it to make a check pass.
## Where the baseline lives
[Section titled “Where the baseline lives”](#where-the-baseline-lives)
The baseline is `ashlar.baseline.json` beside the config, or the file the config's `baseline` key names. It holds a count per rule per file, with paths from the config's folder.
`pnpm exec ashlar snapshot` prints the baseline's total for each rule, and `pnpm exec ashlar check --json` prints each rule's count beside what the baseline holds. See [JSON contract](/reference/json/).
## Related
[Section titled “Related”](#related)
* [Rules](/concepts/rules/): what each count counts.
* [Adopt Ashlar in an existing repository](/guides/adopt/)
* [Move files](/guides/move-files/)
* [CLI reference](/reference/cli/)
# Rules
> What each of Ashlar's twelve rules checks, where it applies, the message an agent reads when it fires, and how a project turns a rule off or rewords it.
## In a repository
[Section titled “In a repository”](#in-a-repository)
A Tauri app keeps its features in `desktop/src/features/`. Its config names the app and its stack:
ashlar.config.ts
```ts
import { defineConfig } from '@kurvball/ashlar';
export default defineConfig({
include: ['desktop'],
apps: [{ root: 'desktop', stack: 'tauri' }],
});
```
An agent working on the Settings feature calls Rust straight from it:
desktop/src/features/settings/index.ts
```ts
import { invoke } from '@tauri-apps/api/core';
export async function saveScheme(scheme: string): Promise {
await invoke('save_scheme', { scheme });
}
```
Terminal
```console
$ pnpm exec ashlar check
Ashlar checked 6 files in 0.2 s: 1 count rose.
client-only in desktop/src/features/settings/index.ts: 1, up from 0
desktop/src/features/settings/index.ts:1:24
Only `client/` talks to the services.
```
The check exits with 1. The rule is `client-only`, and its message tells the agent where that call belongs.
## Why rules
[Section titled “Why rules”](#why-rules)
A line in `CLAUDE.md` or a review comment asks an agent to do something, and nothing checks that it did. A rule is checked on every change, and the change fails until it holds.
Each rule exists because a person corrected an agent's work and didn't want to correct it again. Its message is what the agent reads when the rule fires, so it says what to do instead, not only what went wrong. See [Corrections](/concepts/corrections/) for where each rule came from.
The rules about layout keep the parts of an app apart: two processes that never import each other, features that reach each other only through their `index.ts`, and one folder that talks to the other side. An agent can then change one feature without reading the rest.
## The twelve rules
[Section titled “The twelve rules”](#the-twelve-rules)
| Rule | Where it applies | What it says |
| ------------------------- | -------------------------------- | --------------------------------------------------------------------------------- |
| `no-comment` | All code, tests included | No comments: a name or a test says it, and Git leads to the change that wrote it. |
| `no-disable` | All code | No comment turns a rule off. |
| `max-lines` | All code | No file over its line limit, 600 lines unless the config says otherwise. |
| `named-only-in` | The folders the config names | A name the config confines appears only where it allows. |
| `no-cross-process-import` | An app's main and renderer sides | The two sides never import each other, not even types. |
| `shared-is-pure` | An app's `shared/` | Shared code holds types and pure functions. |
| `public-api-only` | Features and service areas | Another feature or area is imported through its `index.ts`. |
| `client-only` | Features and primitives | Only `client/` talks to the services. |
| `no-effect` | Features | No `useEffect`: a hook from `primitives/`, named for what it does, instead. |
| `no-timer` | Features | No timers: a hook from `primitives/`, named for what it waits on, instead. |
| `no-dom-query` | Features | A feature reaches an element by its ref, not by a selector. |
| `feature-reach` | Feature folders | Every feature folder holds a reach script that reads. |
`pnpm exec ashlar ledger` prints each rule with its message, and `pnpm exec ashlar brief ` prints only the rules that apply to those paths.
## What each rule counts
[Section titled “What each rule counts”](#what-each-rule-counts)
* `no-comment` counts every comment but a shebang and a triple-slash directive such as `/// `. A comment that turns a rule off counts under `no-disable` instead. A comment over several lines counts once per line.
* `no-disable` counts `eslint-disable` and `oxlint-disable` comments, `biome-ignore`, `@ts-ignore`, `@ts-nocheck` and `@ts-expect-error`.
* `max-lines` counts the lines over the limit, so a file 12 lines too long counts 12.
* `named-only-in` counts each string, template, regular expression or JSX text that holds a confined word, matched as a whole word in any case. Import paths don't count.
* `no-cross-process-import` counts each import from the other side of the same app, type imports included.
* `shared-is-pure` counts imports of `node:` and built-in modules, React, the packages that reach the other side, imports run only for their effect, imports from either side, statements that run on import, and globals such as `window`, `document` and `process`.
* `public-api-only` counts each import that reaches past another feature's or area's `index.ts`.
* `client-only` counts imports of the packages that reach the other side, and uses of the app's bridge.
* `no-effect` counts calls to `useEffect`, `useLayoutEffect` and `useInsertionEffect`.
* `no-timer` counts calls to `setTimeout`, `setInterval`, `requestAnimationFrame` and `requestIdleCallback`.
* `no-dom-query` counts calls to `querySelector`, `querySelectorAll`, `closest` and the `getElementById` family.
* `feature-reach` counts one break for each feature folder whose `reach.ts` is missing or doesn't read. See [The feature map](/concepts/feature-map/).
Test files are left out of the feature rules, `client-only`, `shared-is-pure` and `named-only-in`, and `named-only-in` also skips any folder named `test`. `no-comment` holds in tests too.
## Where the layout comes from
[Section titled “Where the layout comes from”](#where-the-layout-comes-from)
`no-comment`, `no-disable` and `max-lines` hold in every file under `include`, and `named-only-in` wherever `confined` says. The other rules need to know where an app's parts are, so they apply only inside an app named in `apps`.
Each app names its folder and its stack. The stack says where its sides are, and which packages reach the other side:
| Stack | Main | Renderer | Shared | Packages that reach the other side |
| ---------- | --------------- | ------------------- | -------- | ----------------------------------------- |
| `electron` | `electron-main` | `electron-renderer` | `shared` | `electron` |
| `tauri` | `src-tauri` | `src` | `shared` | `@tauri-apps/api`, `@tauri-apps/plugin-*` |
| `web` | `server` | `client` | `shared` | none |
Inside the renderer, features are each folder in `features/`, and `client/` and `primitives/` sit beside them. Service areas are each folder in the main side. For the Tauri app above, that makes:
| Part | Folder |
| ------------- | ------------------------ |
| Features | `desktop/src/features/*` |
| Client | `desktop/src/client` |
| Primitives | `desktop/src/primitives` |
| Service areas | `desktop/src-tauri/*` |
An app's config can name other folders for any of these. An app with no renderer, such as an API, sets `renderer: []`. See [the config reference](/reference/config/) for each key.
## Turn a rule off
[Section titled “Turn a rule off”](#turn-a-rule-off)
A project can turn a rule off for all its code in its config:
ashlar.config.ts
```diff
import { defineConfig } from '@kurvball/ashlar';
export default defineConfig({
include: ['desktop'],
apps: [{ root: 'desktop', stack: 'tauri' }],
+ rules: { 'no-dom-query': 'off' },
});
```
No comment in code can turn a rule off, for one line or one file: that is what `no-disable` counts. If a rule is wrong for a case, change the rule. A rule name Ashlar doesn't know stops every command, with exit code 2:
Terminal
```console
$ pnpm exec ashlar check
ashlar.config.ts doesn't read:
`rules.no-comments` names no rule: no-cross-process-import, shared-is-pure, public-api-only, no-effect, no-timer, no-dom-query, client-only, no-comment, no-disable, max-lines, named-only-in, feature-reach.
```
## Reword a message
[Section titled “Reword a message”](#reword-a-message)
`messages` replaces the words an agent reads for a rule. Name the project's own folders and functions, so the agent knows exactly what to use:
ashlar.config.ts
```diff
import { defineConfig } from '@kurvball/ashlar';
export default defineConfig({
include: ['desktop'],
apps: [{ root: 'desktop', stack: 'tauri' }],
+ messages: {
+'client-only': 'Only `client/` calls Rust. Add a function to `client/commands.ts` and call that.',
+ },
});
```
Terminal
```console
$ pnpm exec ashlar check
Ashlar checked 6 files in 0.2 s: 1 count rose.
client-only in desktop/src/features/settings/index.ts: 1, up from 0
desktop/src/features/settings/index.ts:1:24
Only `client/` calls Rust. Add a function to `client/commands.ts` and call that.
```
## Confine a name
[Section titled “Confine a name”](#confine-a-name)
`confined` keeps a word to the places allowed to say it. Each entry gives its words, the files or folders that may name them (`only`), where to look (`within`, everywhere when left out), and the message:
ashlar.config.ts
```diff
import { defineConfig } from '@kurvball/ashlar';
export default defineConfig({
include: ['desktop'],
apps: [{ root: 'desktop', stack: 'tauri' }],
+ confined: [
+ {
+ words: ['stripe'],
+ only: ['desktop/src/client/payments.ts'],
+ message: 'Only `client/payments.ts` names the payment provider. Call `pay()` from it instead.',
+ },
+ ],
});
```
Terminal
```console
$ pnpm exec ashlar check
Ashlar checked 7 files in 0.2 s: 1 count rose.
named-only-in in desktop/src/features/notes/upgrade.ts: 1, up from 0
desktop/src/features/notes/upgrade.ts:1:29
Only `client/payments.ts` names the payment provider. Call `pay()` from it instead.
```
The message lives in each entry, not in `messages`. An app that detects the framework a project is built on can use an entry to keep that framework's name inside the one folder that detects it.
## Change the line limit
[Section titled “Change the line limit”](#change-the-line-limit)
`maxLines` sets the limit `max-lines` holds files to. It is 600 when the config doesn't say.
## Related
[Section titled “Related”](#related)
* [The ratchet](/concepts/ratchet/): how counts are held against a baseline.
* [Corrections](/concepts/corrections/): where each rule came from, and how a new one is added.
* [Add a rule from a correction](/guides/rule-from-a-correction/)
* [Config reference](/reference/config/)
* [CLI reference](/reference/cli/)
# Kurvball
> A Tauri desktop app, a Fastify API and a worker, with Ashlar beside their own architecture gate.
[Kurvball](https://www.kurvball.ca) is where a team agrees on what to build. Its repository holds a Tauri desktop app (`apps/desktop`), a Fastify API (`apps/api`), a worker (`apps/worker`) and shared packages. It has its own architecture gate, so here Ashlar runs beside it, as a proof that it fits a repository it wasn't built in.
The config, two reach scripts and the script live in [`examples/kurvball/`](https://github.com/kurvball/ashlar/tree/main/examples/kurvball). Kurvball's repository is private, so the script runs only with access to it. [What it shows](#what-it-shows) is what it printed.
## Run it
[Section titled “Run it”](#run-it)
Terminal
```sh
examples/kurvball/prove.sh
```
## Its config
[Section titled “Its config”](#its-config)
ashlar.config.ts
```ts
import { defineConfig } from '@kurvball/ashlar';
export default defineConfig({
include: ['apps', 'packages'],
ignore: ['node_modules', 'dist', 'out', 'target', 'coverage', 'storybook-static', '.turbo', 'generated'],
onboard: {
owner: '@daguenette',
areas: ['packages/*', 'packages/modules/*'],
},
apps: [
{
root: 'apps/desktop',
stack: 'tauri',
main: ['src-tauri'],
renderer: ['src'],
shared: [],
features: ['src/features/*'],
client: ['src/platform'],
primitives: ['src/ui'],
areas: [],
},
{ root: 'apps/api', stack: 'web', main: ['src'], renderer: [], shared: [], areas: ['src/*'] },
{ root: 'apps/worker', stack: 'web', main: ['src'], renderer: [], shared: [], areas: [] },
],
});
```
* The desktop is a `tauri` app. Its main process is Rust, which Ashlar doesn't read, so its rules watch the TypeScript renderer: features in `src/features/*`, the client in `src/platform`, primitives in `src/ui`. `client-only` and `shared-is-pure` know Tauri's packages, `@tauri-apps/api` and its plugins.
* The API and the worker are `web` apps with no renderer (`renderer: []`), so they have areas but no features.
* Kurvball's domain modules become onboarding areas through `onboard.areas`.
## The API and the worker
[Section titled “The API and the worker”](#the-api-and-the-worker)
They are `web` apps with `renderer: []`: one process, no features, no client and no primitives.
* `ashlar map` lists no feature of theirs; the map is the desktop's.
* The rules about two processes or about features don't apply to them. A brief for an API file carries `public-api-only`, `no-comment`, `no-disable` and `max-lines`, never `no-cross-process-import`.
* `ashlar onboard` takes each folder under `apps/api/src` as an area. The worker names no areas (`areas: []`), so it has none. The domain modules in `packages/modules/*` are areas through `onboard.areas`.
## Beside Kurvball's own gate
[Section titled “Beside Kurvball's own gate”](#beside-kurvballs-own-gate)
Kurvball's gate allows what Ashlar counts, so Ashlar takes a baseline first and holds every file to it. Its first `check` fails, as it should; after `check --shrink` it passes, and from then on no file may get worse. Here Ashlar's findings are a second opinion, not a gate Kurvball runs.
## What it shows
[Section titled “What it shows”](#what-it-shows)
At Kurvball's commit `b4a57d57`:
| Command | On Kurvball |
| -------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
| `ashlar check`, first run | fails, as it should: Kurvball has no baseline yet |
| `ashlar check --shrink`, then `check` | 3,316 files in about 2.3 s; the baseline holds about 439,000 counts, mostly `max-lines` and `no-comment`, and the check passes |
| `ashlar affected` on a desktop feature's file and an API route | 179 tests |
| `ashlar map` | 18 features, 2 with the reach scripts the example adds, 274 proofs |
| `ashlar onboard` | 53 areas and 71 questions: what to know before changing each area, how to reach 16 features, who owns what, and whether the README is current |
The baseline is large. That is the point of the [ratchet](/concepts/ratchet/): nothing is cleaned up in a sweep, and no file may get worse.
The two reach scripts, for the Ideas and Settings features, are written from the labels in Kurvball's code. Kurvball has no drive command, so the map shows them as data; nothing walks them.
# Get started
> Install Ashlar in your repository from its latest release, then take the tutorial, a guide or the reference.
Ashlar checks a TypeScript repository against rules that came from corrections, and holds every file to a baseline that only shrinks. Install it as a dev dependency, from its latest release.
* pnpm
Terminal
```sh
pnpm add -D https://github.com/kurvball/ashlar/releases/download/v1.2.1/kurvball-ashlar-1.2.1.tgz
```
* npm
Terminal
```sh
npm install -D https://github.com/kurvball/ashlar/releases/download/v1.2.1/kurvball-ashlar-1.2.1.tgz
```
* Yarn
Terminal
```sh
yarn add -D https://github.com/kurvball/ashlar/releases/download/v1.2.1/kurvball-ashlar-1.2.1.tgz
```
[Tutorial](/tutorial/check-a-project/)Check a small project, watch a rule fail, and fix what it found.
[Guides](/guides/adopt/)Adopt Ashlar in an existing repository, write reach scripts, and move files.
[Reference](/reference/cli/)Every command, config key and JSON output, with the version each arrived in.
# Adopt Ashlar in an existing repository
> Install Ashlar from a release, lay out your apps, take a baseline of today's breaks, fail CI only when a file gets worse, and keep the onboarding guide current.
At the end of this guide, `ashlar check` runs in CI and fails only when a file gets worse than it is today.
The examples come from a small repository: a Tauri desktop app in `apps/desktop`, an API in `apps/api`, and a package in `packages/money`. The outputs are what Ashlar printed there.
1. Install Ashlar as a dev dependency. Ashlar is not on npm: each [release](https://github.com/kurvball/ashlar/releases) attaches its packed tarball, `kurvball-ashlar-.tgz`, and you install it by its address:
Terminal
```sh
pnpm add -D https://github.com/kurvball/ashlar/releases/download/v1.2.0/kurvball-ashlar-1.2.0.tgz
```
With npm, `npm install -D` and the same address. Your lockfile records the address and the tarball's checksum, so CI installs the same file with no token and nothing kept in your repository. To upgrade, install the newer release's address.
To run a change that isn't released yet, build the tarball from Ashlar's repository instead (`git clone https://github.com/kurvball/ashlar.git`, then `pnpm install` and `pnpm pack` there), copy it into your repository, for example as `vendor/kurvball-ashlar-.tgz`, commit it, and install it from there: `pnpm add -D ./vendor/kurvball-ashlar-.tgz`. Installing from `../ashlar/` instead would leave a path in your lockfile that CI doesn't have.
Ashlar needs Node 22.18 or later, and Git. Run it with `pnpm exec ashlar`, `yarn ashlar` or `npx --no-install ashlar`. Never run a bare `npx ashlar`: a package named `ashlar` on npm is someone else's, and `npx` would download and run it. Check which version you have:
Terminal
```console
$ pnpm exec ashlar --version
1.2.0
```
2. Write `ashlar.config.ts` at the root. `no-comment`, `no-disable` and `max-lines` hold in every file under `include`; every other rule needs to know where an app's parts are, so it applies only inside an app named in `apps`. Name one app for each app in the repository:
ashlar.config.ts
```ts
import { defineConfig } from '@kurvball/ashlar';
export default defineConfig({
include: ['apps', 'packages'],
apps: [
{ root: 'apps/desktop', stack: 'tauri' },
{ root: 'apps/api', stack: 'web', main: ['src'], renderer: [], shared: [], areas: ['src/*'] },
],
});
```
`include` names the folders Ashlar checks. Each app names its stack, `electron`, `tauri` or `web`, and the stack says where its sides live: for Tauri, the screens in `src/`, the host in `src-tauri/`, features in `src/features/*`. The API has no screens, so it has no renderer, and each folder in its `src/` is an area. [Config](/reference/config/) lists every key and its default.
**A library or a CLI** has no screens either: give it one `web` app whose main side is its source folder, with no renderer, and make each folder of it an area:
ashlar.config.ts
```ts
import { defineConfig } from '@kurvball/ashlar';
export default defineConfig({
include: ['src'],
apps: [{ root: 'src', stack: 'web', main: ['.'], renderer: [], areas: ['*'] }],
});
```
`areas` matters here. A stack's default areas sit in its usual main folder (`server/*` for `web`), which a repository whose main side is its root doesn't have, and an app with no area has nothing for `public-api-only` to count. Ashlar says so rather than count zero:
Terminal
```console
$ pnpm exec ashlar check
Ashlar checked 3 files in 0.1 s: no count rose.
There is no baseline, so every count must stay at zero.
Warning: apps[0] (src): none of its 3 main-side files is in a service area, so public-api-only counts nothing there. Its areas, `src/server/*`, match none of them. Name them in `areas`, such as `areas: ['*']` for each folder of the app's root, or give `areas: []` to say it has none.
```
With `areas: ['*']`, the same files show what the warning hid:
Terminal
```console
$ pnpm exec ashlar check
Ashlar checked 3 files in 0.1 s: 2 counts rose.
public-api-only in src/cli.ts: 1, up from 0
src/cli.ts:1:21
Import another feature or area through its `index.ts`. If you need something inside it, it belongs in its index or in `shared/`.
public-api-only in src/run/run.ts: 1, up from 0
src/run/run.ts:1:22
Import another feature or area through its `index.ts`. If you need something inside it, it belongs in its index or in `shared/`.
```
**A web client that calls its server with `fetch`:** name `fetch` as the app's bridge, and `client-only` counts every `fetch` outside `client/`, as it counts Electron's or Tauri's packages. Without it, Ashlar doesn't know `fetch` reaches the other side:
ashlar.config.ts
```ts
{ root: 'apps/web', stack: 'web', bridge: { global: 'fetch' } }
```
3. Run the check once, to see what is there:
Terminal
```console
$ pnpm exec ashlar check
Ashlar checked 9 files in 0.2 s: 6 counts rose.
no-comment in apps/api/src/orders/index.ts: 1, up from 0
apps/api/src/orders/index.ts:3:1
Comments go stale and nothing checks them. Rename it, or write a test. Git leads from any line to the item or task that wrote it.
no-effect in apps/desktop/src/features/cart/Cart.tsx: 1, up from 0
apps/desktop/src/features/cart/Cart.tsx:6:3
`useEffect` belongs to `client/` and `primitives/`. A feature that needs one needs a hook in `primitives/`, named for what it does, instead.
no-timer in apps/desktop/src/features/cart/Cart.tsx: 1, up from 0
apps/desktop/src/features/cart/Cart.tsx:8:19
A timer patches over a render you don't control. Use a hook from `primitives/`, named for what it waits on.
feature-reach in apps/desktop/src/features/cart/reach.ts: 1, up from 0
apps/desktop/src/features/cart/reach.ts:1:1
Every feature folder holds a reach script, `reach.ts`: the developer's way to the feature as drive steps, ending on a snapshot of what it reaches. It is plain data that imports only types. Write one, then run it with `ashlar drive `.
feature-reach in apps/desktop/src/features/search/reach.ts: 1, up from 0
apps/desktop/src/features/search/reach.ts:1:1
Every feature folder holds a reach script, `reach.ts`: the developer's way to the feature as drive steps, ending on a snapshot of what it reaches. It is plain data that imports only types. Write one, then run it with `ashlar drive `.
no-comment in packages/money/src/total.ts: 1, up from 0
packages/money/src/total.ts:1:1
Comments go stale and nothing checks them. Rename it, or write a test. Git leads from any line to the item or task that wrote it.
```
It exits with 1. With no baseline, every count must stay at zero, and an existing repository has breaks. If a break is in the wrong place, the layout is wrong: fix the app's folders in the config and run it again.
Two words: a **count** is one rule's number in one file, and **breaks** are what it counts. "6 counts rose" means six pairs of a file and a rule went up; the baseline below holds 6 breaks in all. Most rules count each place they fire, so a file with three comments holds 3 `no-comment` breaks; `max-lines` counts the lines a file has over the limit, so a file of 724 lines holds 124.
4. Take the baseline:
Terminal
```console
$ pnpm exec ashlar check --shrink
Ashlar checked 9 files in 0.2 s and took the baseline: 6 breaks in ashlar.baseline.json.
```
The baseline holds each file's count for each rule:
ashlar.baseline.json
```json
{
"feature-reach": {
"apps/desktop/src/features/cart/reach.ts": 1,
"apps/desktop/src/features/search/reach.ts": 1
},
"no-comment": {
"apps/api/src/orders/index.ts": 1,
"packages/money/src/total.ts": 1
},
"no-effect": {
"apps/desktop/src/features/cart/Cart.tsx": 1
},
"no-timer": {
"apps/desktop/src/features/cart/Cart.tsx": 1
}
}
```
Commit `ashlar.baseline.json`. From now on, `check` passes while no file's count rises above it:
Terminal
```console
$ pnpm exec ashlar check
Ashlar checked 9 files in 0.1 s: no count rose.
```
5. Run the check in CI. Give it a script in `package.json`:
package.json
```json
{
"scripts": {
"check": "ashlar check"
}
}
```
Then run `pnpm check` in your CI job. On GitHub Actions, this workflow runs it on every pull request and on `main`.
.github/workflows/check.yml
```yaml
name: Check
on:
pull_request:
push:
branches: [main]
jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version: 22
cache: pnpm
- run: pnpm install --frozen-lockfile
- run: pnpm check
```
Ashlar compares with your main branch to tell which lines a change wrote: of `main`, `origin/main`, `master` and `origin/master`, it takes the one whose merge base with `HEAD` is closest. A pull request's checkout has no local `main`, so it uses `origin/main`, which `fetch-depth: 0` fetches. A comment on a written line fails even when another comment in the file went, so the count stayed the same. Editing a line that holds a comment writes it too: fixing a path inside an old comment counts as a new comment. A comment can't be kept current, only replaced by a name or a test.
Terminal
```console
$ pnpm check
Ashlar checked 12 files in 0.2 s: 1 count rose.
no-comment in apps/api/src/sales/index.ts: 1 new one on lines changed since main. None may be added, even where others went.
apps/api/src/sales/index.ts:4:3
Comments go stale and nothing checks them. Rename it, or write a test. Git leads from any line to the item or task that wrote it.
```
A change that adds a break fails the same way, with the message the agent reads:
Terminal
```console
$ pnpm check
Ashlar checked 9 files in 0.2 s: 1 count rose.
no-comment in apps/api/src/db/index.ts: 1, up from 0
apps/api/src/db/index.ts:2:3
Comments go stale and nothing checks them. Rename it, or write a test. Git leads from any line to the item or task that wrote it.
```
6. Lower the baseline as breaks go. When a fix takes a count down, as a reach script for the cart feature does here, `check` says so:
Terminal
```console
$ pnpm check
Ashlar checked 10 files in 0.2 s: no count rose.
1 break in the baseline is gone: `ashlar check --shrink` lowers it.
```
Terminal
```console
$ pnpm check --shrink
Ashlar checked 10 files in 0.2 s: no count rose.
The baseline now holds 5 breaks.
```
`--shrink` only ever lowers a count. Commit the baseline with the fix.
When the layout grows later, a wider `include`, a new app or new areas, new counts appear that `--shrink` won't take in. Take them in on purpose with `ashlar check --accept-rise`, which says what it took, or delete `ashlar.baseline.json` and take it again with `--shrink`.
7. Turn a rule off, if it is wrong for the whole project. No comment in code can turn a rule off, so it goes in the config:
ashlar.config.ts
```ts
import { defineConfig } from '@kurvball/ashlar';
export default defineConfig({
include: ['apps', 'packages'],
apps: [
{ root: 'apps/desktop', stack: 'tauri' },
{ root: 'apps/api', stack: 'web', main: ['src'], renderer: [], shared: [], areas: ['src/*'] },
],
rules: { 'no-timer': 'off' },
});
```
Terminal
```console
$ pnpm check
Ashlar checked 9 files in 0.2 s: no count rose.
1 break in the baseline is gone: `ashlar check --shrink` lowers it.
```
The rule's counts in the baseline are now gone, and `pnpm check --shrink` takes them out.
8. Replace a rule's message with your own words, such as the name of your own hook:
ashlar.config.ts
```ts
import { defineConfig } from '@kurvball/ashlar';
export default defineConfig({
include: ['apps', 'packages'],
apps: [
{ root: 'apps/desktop', stack: 'tauri' },
{ root: 'apps/api', stack: 'web', main: ['src'], renderer: [], shared: [], areas: ['src/*'] },
],
messages: {
'no-timer':
'A timer patches over a render you don’t control. Wait with `useDebounced` from `primitives/`.',
},
});
```
Terminal
```console
$ pnpm check
Ashlar checked 9 files in 0.2 s: 1 count rose.
no-timer in apps/desktop/src/features/search/Search.tsx: 1, up from 0
apps/desktop/src/features/search/Search.tsx:4:36
A timer patches over a render you don’t control. Wait with `useDebounced` from `primitives/`.
```
The same words reach `ashlar ledger`, `ashlar brief` and the onboarding guide.
9. Write the onboarding guide, and keep it current. `ashlar onboard` writes it into `docs/onboarding/` (or where `onboard.out` says): what the system is, each area, its decisions and rules, and the questions only a person can answer. `ashlar onboard --check` fails when it is out of date, so run it with the check:
package.json
```json
{
"scripts": {
"check": "ashlar check && ashlar onboard --check"
}
}
```
The guide is generated, so leave it as Ashlar writes it:
* Keep formatters off it. Prettier would rewrite its Markdown, and `--check` would call it stale. Add the folder to `.prettierignore`:
.prettierignore
```text
docs/onboarding/
```
* Run `ashlar onboard` again after a change it describes, and commit the result. The guide lists your `package.json` scripts, your areas, `DECISIONS.md` and `.claude/rules/`, so changing a script makes `--check` fail until it is written again.
[Onboarding](/concepts/onboarding/) says what the guide holds.
## Related
[Section titled “Related”](#related)
* [The ratchet](/concepts/ratchet/)
* [Rules](/concepts/rules/)
* [Onboarding](/concepts/onboarding/)
* [Config](/reference/config/)
* [Write a reach script](/guides/reach-scripts/), for the `feature-reach` breaks the baseline now holds
* [Move files without losing the ratchet](/guides/move-files/)
* [Kurvball](/examples/kurvball/), a real repository that took its baseline this way
# Give an agent its brief
> Print only what an agent needs before it changes some files with ashlar brief, and give it the onboard skill so it reads its brief and keeps what people decide.
At the end of this guide, an agent reads its brief before it changes files, and the onboard skill tells it when to.
The examples come from the repository in [Answer questions and record decisions](/guides/decisions/), with its `DECISIONS.md` and its folder rule.
1. Print the brief for the files the agent will change:
Terminal
```console
$ pnpm exec ashlar brief apps/api/src/db/index.ts
# Brief for `apps/api/src/db/index.ts`
## Areas
- Db (`apps/api/src/db`), owned by @lee
## Data rules
- Real data never enters the repository: not in code, tests, fixtures or documents.
- Secrets are never printed, logged or written into the repository.
## Ashlar’s rules here
- **public-api-only**: Import another feature or area through its `index.ts`. If you need something inside it, it belongs in its index or in `shared/`.
- **no-comment**: Comments go stale and nothing checks them. Rename it, or write a test. Git leads from any line to the item or task that wrote it.
- **no-disable**: No comment turns a rule off. If a rule is wrong for a case, change the rule and record why in the ledger.
- **max-lines**: A file over 600 lines costs every agent that reads it. Split it along what it does.
## Decisions
- 2026-12-01 @sam [apps/api] setup: `pnpm --filter api dev` starts it on port 3000, on the seeded database.
- 2026-12-02 @lee [apps/api/src/db] rule: Every query goes through `rows`, so a test can swap the database.
```
Name files or folders, as many as the work touches. The brief is Markdown, so it can go straight into the agent's prompt.
2. Read what it holds. The same command on a feature's file carries more, because more applies there:
Terminal
```console
$ pnpm exec ashlar brief apps/desktop/src/features/cart/Cart.tsx
# Brief for `apps/desktop/src/features/cart/Cart.tsx`
## Areas
- Cart (`apps/desktop/src/features/cart`), owned by @sam
## Data rules
- Real data never enters the repository: not in code, tests, fixtures or documents.
- Secrets are never printed, logged or written into the repository.
## Ashlar’s rules here
- **no-cross-process-import**: `src/` and `src-tauri/` never import each other, not even types. Put the contract in `shared/`.
- **public-api-only**: Import another feature or area through its `index.ts`. If you need something inside it, it belongs in its index or in `shared/`.
- **no-effect**: `useEffect` belongs to `client/` and `primitives/`. A feature that needs one needs a hook in `primitives/`, named for what it does, instead.
- **no-timer**: A timer patches over a render you don't control. Use a hook from `primitives/`, named for what it waits on.
- **no-dom-query**: Reach an element by its ref, not by `querySelector`.
- **client-only**: Only `client/` talks to the services.
- **no-comment**: Comments go stale and nothing checks them. Rename it, or write a test. Git leads from any line to the item or task that wrote it.
- **no-disable**: No comment turns a rule off. If a rule is wrong for a case, change the rule and record why in the ledger.
- **max-lines**: A file over 600 lines costs every agent that reads it. Split it along what it does.
- **feature-reach**: Every feature folder holds a reach script, `reach.ts`: the developer's way to the feature as drive steps, ending on a snapshot of what it reaches. It is plain data that imports only types. Write one, then run it with `ashlar drive `.
## Folder rules
### Prices are cents (gotcha: SHOP-142)
Every price in a feature is a whole number of cents. Show it with `formatPrice` from `packages/money`, never by
dividing by 100 in the feature.
## Features
- Cart: Open cart › Cart
```
| Section | What it holds |
| ------------------- | ------------------------------------------------------------------------------------------------------------- |
| Areas | The areas the paths touch, each with its owner. |
| Owners | The owner of each path that lies in no area, when there is one. |
| Data rules | `onboard.dataRules`, or the two defaults. Every brief has them. |
| Ashlar’s rules here | The rules the config leaves on that apply at those places, in the config's own words. |
| Folder rules | Each rule in `.claude/rules/` whose `paths` match, and each rule with no `paths`, marked when it is a gotcha. |
| Decisions | The lines whose area covers the paths, and the lines for `*`. |
| Features | The features the paths touch, each with its reach. |
| Open questions here | The questions still open in those areas, each with who to ask. Only when `onboard.owner` is set. |
3. Know what it never holds. A brief carries no `access` line and no `owner` line: the owner shows in Areas instead. It carries nothing about other areas: the API's brief above has no rule for features and no cart. And it never holds a secret. When a knowledge file holds something shaped like one, the brief refuses to run:
Terminal
```console
$ pnpm exec ashlar brief apps/api/src/db
Secrets never enter knowledge files, and these lines look like one:
DECISIONS.md:9:57 holds what looks like a password or token.
Take the value out. Say who grants access instead, as an `access` line, never the credential.
```
It exits with 2. A brief covers files in the project only, and refuses paths none of which exist:
Terminal
```console
$ pnpm exec ashlar brief apps/nothing.ts
None of these is in the project: apps/nothing.ts.
```
4. Give a tool the JSON. `--json` prints the same brief as one object, for a tool that reads it:
Terminal
```json
{
"version": 1,
"paths": ["apps/api/src/db/index.ts"],
"areas": [{ "path": "apps/api/src/db", "name": "Db", "owner": "@lee" }],
"owners": [{ "path": "apps/api/src/db/index.ts", "owner": "@lee" }],
"dataRules": [
"Real data never enters the repository: not in code, tests, fixtures or documents.",
"Secrets are never printed, logged or written into the repository."
],
"rules": [
{
"id": "public-api-only",
"message": "Import another feature or area through its `index.ts`. If you need something inside it, it belongs in its index or in `shared/`."
}
],
"folderRules": [],
"decisions": [
{
"date": "2026-12-02",
"owner": "@lee",
"areas": ["apps/api/src/db"],
"kind": "rule",
"text": "Every query goes through `rows`, so a test can swap the database."
}
],
"features": [],
"questions": []
}
```
This is shortened: the real output lists every rule and decision the text shows. [JSON outputs](/reference/json/) gives every field.
5. Give the agent the onboard skill, so it reads its brief without being told:
Terminal
```console
$ pnpm exec ashlar skill onboard --write
Wrote .claude/skills/onboard/SKILL.md.
```
The skill tells the agent to run `ashlar brief` before it changes files, to add a line to `DECISIONS.md` only on a person's word, and never to put a secret or an account detail in the repository. It runs Ashlar the way your lockfile says, here with pnpm:
.claude/skills/onboard/SKILL.md
```markdown
# Know the area before you change it
Before you change files, run `pnpm exec ashlar brief `. It prints only what that area needs:
the data rules, the rules that apply there, the folder rules and their gotchas, the decisions people made
about it, the features it touches and the questions still open there. Follow what it says. It never holds
access or account details, and you never ask for them.
```
Without `--write`, the command prints the skill. A skill file you changed is kept:
Terminal
```console
$ pnpm exec ashlar skill onboard --write
.claude/skills/onboard/SKILL.md differs from Ashlar's onboard skill: give `--force` to replace it with Ashlar's.
```
`--force` replaces it with Ashlar's.
## Related
[Section titled “Related”](#related)
* [Onboarding](/concepts/onboarding/)
* [Answer questions and record decisions](/guides/decisions/)
* [Agent skill](/agent-skill/)
* [CLI](/reference/cli/), for `ashlar brief` and `ashlar skill`
# Answer questions and record decisions
> Write the onboarding guide, answer its questions with lines in DECISIONS.md and folder rules in .claude/rules, and keep the guide current with ashlar onboard --check.
At the end of this guide, the onboarding guide's questions are answered by decisions and folder rules, each sent to its owner, and `ashlar onboard --check` keeps the guide current.
The examples come from a repository with a Tauri desktop app in `apps/desktop` and an API in `apps/api`.
1. Name the project's default owner in `ashlar.config.ts`. Every question nobody else owns goes to them:
ashlar.config.ts
```ts
import { defineConfig } from '@kurvball/ashlar';
export default defineConfig({
include: ['apps', 'packages'],
apps: [
{ root: 'apps/desktop', stack: 'tauri' },
{ root: 'apps/api', stack: 'web', main: ['src'], renderer: [], shared: [], areas: ['src/*'] },
],
onboard: { owner: '@sam' },
});
```
Without it, `ashlar onboard` stops and says what to add:
Terminal
```console
$ pnpm exec ashlar onboard
Name the project’s default owner, who gets every question nobody else owns: `onboard: { owner: "@handle" }` in ashlar.config.ts.
```
2. Write the guide:
Terminal
```console
$ pnpm exec ashlar onboard
Wrote the guide in docs/onboarding: 7 written, 0 removed.
5 areas, 0 decisions, 0 rules, 8 open questions: @sam 8.
```
The guide is a `README.md` that says what the system is, a page per area in `areas/`, and `questions.md`, every unknown as a question for its owner. Four of its eight:
docs/onboarding/questions.md
```markdown
## @sam
- [ ] TODO(@sam) What must an agent know before changing Db (`apps/api/src/db`)? Answered by a line in DECISIONS.md: `- @you [apps/api/src/db] rule: what to know`, or a rule in `.claude/rules/` whose paths cover it. `know:apps/api/src/db`
- [ ] TODO(@sam) Who owns what? No area names its owner yet, so every question goes to @sam. Answered by a line in DECISIONS.md: `- @you [] owner: @handle` for each area, or one for `*`. `owner:*`
- [ ] TODO(@sam) How do you run `apps/api` locally? Answered by a `dev` or `start` script, or a line in DECISIONS.md: `- @you [apps/api] setup: how`. `setup:apps/api`
- [ ] TODO(@sam) Is `README.md` current, and who keeps it? Answered by a line in DECISIONS.md: `- @you [README.md] trust: what holds`. `trust:README.md`
```
Each question says the line that answers it, and ends with its id, made of its kind and its area. The guide is generated: don't edit it, change its sources and run `ashlar onboard` again.
3. Answer with lines in `DECISIONS.md`, at the root. One line is one decision a person made:
DECISIONS.md
```markdown
# Decisions
- 2026-12-01 @sam [*] owner: @sam
- 2026-12-01 @sam [apps/api] owner: @lee
- 2026-12-01 @sam [apps/api] setup: `pnpm --filter api dev` starts it on port 3000, on the seeded database.
- 2026-12-02 @lee [apps/api/src/db] rule: Every query goes through `rows`, so a test can swap the database.
- 2026-12-02 @lee [apps/api/src/db] access: @lee grants access to the staging database.
- 2026-12-02 @sam [README.md] trust: Current, and @sam keeps it.
```
A line holds the date, the handle of the person who decided, the areas in brackets, the kind, and what was decided. An area is a folder or a file from the root, several separated by commas, or `*` for the whole project. Every line that starts with `- `is a decision, except inside a code fence. Headings and other text are left alone. To change a decision, edit or delete its line: Git keeps the history.
| Kind | The line says |
| ---------- | ------------------------------------------------------------------------------------------ |
| `decision` | A plain decision. A line with no kind is one. |
| `rule` | What an agent must do there. |
| `trust` | A document is current, and who keeps it. |
| `access` | Who grants access to what: a person and a system, never a credential. No brief carries it. |
| `owner` | Who owns the area. The text is the owner's handle. |
| `setup` | How to run something. |
A word before a colon that isn't one of these kinds stays part of the text of a plain decision.
4. Name the owners. An area's owner comes from the first of these that names one:
* `onboard.owners` in the config, folder to handle, such as `{ 'apps/api': '@lee' }`, where the longest folder that holds the area wins;
* an `owner` line, where the line for the deepest folder that holds the area wins, a `*` line counts last, and the later date wins between two lines for the same folder;
* `onboard.owner`, the default owner.
No owner is ever guessed from Git. Each question goes to its area's owner.
5. Write a folder rule for what an agent must know in a folder. It is a Markdown file in `.claude/rules/`, named after the folder, slashes as dashes:
.claude/rules/apps-desktop-src-features.md
```markdown
---
paths:
- 'apps/desktop/src/features/**'
owner: '@sam'
date: 2026-12-02
gotcha: SHOP-142
---
# Prices are cents
Every price in a feature is a whole number of cents. Show it with `formatPrice` from `packages/money`, never by
dividing by 100 in the feature.
```
Ashlar reads five frontmatter keys: `paths` (a list of globs, as Claude Code reads them), `gotcha`, `owner`, `date` and `description`. Any other key is an error. Without `paths`, or with paths that start with a glob such as `**/*.ts`, the rule is for every folder, and answers no one area's question. The first heading is its title. `gotcha` marks a rule that guards against a mistake made before, with its ticket or a short name, and the guide lists it under the area's gotchas.
6. Write the guide again:
Terminal
```console
$ pnpm exec ashlar onboard
Wrote the guide in docs/onboarding: 6 written, 0 removed.
5 areas, 5 decisions, 1 rule, 1 open question: @sam 1.
```
Seven questions are gone. The cart's page now shows its owner, its reach and its gotcha:
docs/onboarding/areas/apps--desktop--src--features--cart.md
```markdown
# Cart
> Generated by `ashlar onboard` from the code, its decisions and its rules. Don’t edit it: change those, then run `ashlar onboard` again.
- Folder: `apps/desktop/src/features/cart`
- Kind: feature
- Owner: @sam
- Reach: Open cart › Cart
## Proofs
None yet.
## Gotchas
### Prices are cents (SHOP-142)
From `.claude/rules/apps-desktop-src-features.md`.
Every price in a feature is a whole number of cents. Show it with `formatPrice` from `packages/money`, never by
dividing by 100 in the feature.
```
Its count of five decisions leaves out the `access` line. The area's page shows that line to people, and no brief carries it. Commit `DECISIONS.md`, the rule and the guide together.
7. Keep the guide current. `--check` writes nothing, and fails when a file is stale or was edited by hand:
Terminal
```console
$ pnpm exec ashlar onboard --check
The guide in docs/onboarding is current: 1 open question.
```
Terminal
```console
$ pnpm exec ashlar onboard --check
The guide in docs/onboarding is out of date:
docs/onboarding/areas/apps--api--src--db.md is stale or was edited by hand.
Run `ashlar onboard` to write it again.
```
It exits with 1 then. Run it next to `ashlar check` in your lint script or in CI.
## How each question is answered
[Section titled “How each question is answered”](#how-each-question-is-answered)
| Id | Asks | Asked when | Answered by |
| ------------------ | --------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- |
| `owner:*` | Who owns what? | No area has an owner but the default owner. | An `owner` line for each area, one for `*`, or `onboard.owners`. |
| `owner:` | Who owns this area? | Some areas name an owner, and this one doesn't. | An `owner` line for the area, or `onboard.owners`. |
| `reach:` | How does a person reach this feature from the app's home? | A feature folder has no `reach.ts`. | Its reach script. See [Write a reach script](/guides/reach-scripts/). |
| `know:` | What must an agent know before changing this area? | No line names the area, a folder that holds it or a folder inside it, and no folder rule's `paths` cover it. `owner` lines and `*` lines don't count. | A `rule` line, or any other line for the area, or a folder rule whose `paths` cover it. |
| `setup:tests` | How are the tests run? | The root `package.json` has no `test` script. | A `test` script, or a `setup` line for `*`. |
| `setup:` | How do you run this app locally? | The app's `package.json` has no `dev` or `start` script, or the root's, when the app has none. | A `dev` or `start` script, or a `setup` line for the app. |
| `trust:` | Is this document current, and who keeps it? | A document in `onboard.documents` has no `trust` line. | A `trust` line for the document, or for a folder that holds it. |
## What Ashlar refuses
[Section titled “What Ashlar refuses”](#what-ashlar-refuses)
`ashlar onboard`, `ashlar brief` and `ashlar snapshot` read the same files, and each stops with exit code 2 on one of these.
A line that doesn't parse, so a typo never hides a decision:
Terminal
```console
$ pnpm exec ashlar onboard
DECISIONS.md:9 isn't a decision line: - 2026-12-03 @owner [area, another/area] kind: what was decided
```
That line had no `@` before its handle. A line whose brackets name no area is refused too.
A value shaped like a secret, in `DECISIONS.md` or a folder rule:
Terminal
```console
$ pnpm exec ashlar onboard
Secrets never enter knowledge files, and these lines look like one:
DECISIONS.md:9:57 holds what looks like a password or token.
Take the value out. Say who grants access instead, as an `access` line, never the credential.
```
A folder rule with a frontmatter key Ashlar doesn't read, or frontmatter that opens with `---` and never closes, names its file and line.
## Related
[Section titled “Related”](#related)
* [Onboarding](/concepts/onboarding/)
* [Give an agent its brief](/guides/brief/)
* [Config](/reference/config/), for every `onboard` key
* [Agent skill](/agent-skill/): the onboard skill tells an agent when to add a line
# Move files without losing the ratchet
> Rename a file or a folder and take its counts in the baseline with it, with ashlar move or with the renames git sees.
At the end of this guide, a file or folder you moved keeps its counts in the baseline under its new name, and `ashlar check` passes.
The baseline holds counts by file path. A moved file has a new path that the baseline doesn't name, and a path the baseline doesn't name holds none, so every break the file carried counts as a rise.
1. Move the file, and run the check:
Terminal
```sh
git mv packages/money/src/total.ts packages/money/src/sum.ts
```
Terminal
```console
$ pnpm exec ashlar check
Ashlar checked 9 files in 0.2 s: 1 count rose.
packages/money/src/sum.ts moved from packages/money/src/total.ts: `ashlar move packages/money/src/total.ts packages/money/src/sum.ts` takes its counts with it.
no-comment in packages/money/src/sum.ts: 1, up from 0
packages/money/src/sum.ts:1:1
Comments go stale and nothing checks them. Rename it, or write a test. Git leads from any line to the item or task that wrote it.
```
The comment was there before the move. Ashlar sees that git renamed the file, and says which command takes its counts along.
2. Take the counts to the new name with `ashlar move`:
Terminal
```console
$ pnpm exec ashlar move packages/money/src/total.ts packages/money/src/sum.ts
packages/money/src/total.ts → packages/money/src/sum.ts: 1 break moved.
```
ashlar.baseline.json
```diff
"no-comment": {
"apps/api/src/orders/index.ts": 1,
"packages/money/src/total.ts": 1
"packages/money/src/sum.ts": 1
},
```
Terminal
```console
$ pnpm exec ashlar check
Ashlar checked 9 files in 0.2 s: no count rose.
```
Commit the baseline with the move. `ashlar move` works before or after you move the files, as long as exactly one of the two paths exists. Give it several pairs at once: `ashlar move `.
3. Or let `check --shrink` take the renames git sees. On the same move, instead of `ashlar move`:
Terminal
```console
$ pnpm exec ashlar check --shrink
Ashlar checked 9 files in 0.2 s: no count rose.
The baseline now holds 6 breaks.
```
`--shrink` gives each file git saw renamed the counts of its old name, then lowers counts as it always does. Git sees a rename between the branch's start on `main` and your working tree when the move is committed or staged (`git mv` stages it) and the file kept enough of its content. A file moved with a plain `mv` and not added, or changed too much on the way, looks like a file deleted and another added: use `ashlar move` for it.
4. Move a folder the same way. Every file in it keeps its counts:
Terminal
```sh
git mv apps/api/src/orders apps/api/src/sales
```
Terminal
```console
$ pnpm exec ashlar move apps/api/src/orders apps/api/src/sales
apps/api/src/orders → apps/api/src/sales: 1 break moved.
```
5. Fix a move that takes in new breaks. Each file keeps what it holds now, up to what the baseline held for it, so a moved file can't carry more breaks than before. If someone added one on the way, the move is refused, and the baseline stays as it was:
Terminal
```console
$ pnpm exec ashlar move packages/money/src/total.ts packages/money/src/sum.ts
Ashlar moved no counts: the move would take in new breaks.
packages/money/src/total.ts → packages/money/src/sum.ts: no-comment rose to 2, up from 1
Fix the moved code, or give `--accept-rise` to take the rise into the baseline.
```
It exits with 2. Take the new break out and move again. If a person accepts the rise, `--accept-rise` takes it in and says so:
Terminal
```console
$ pnpm exec ashlar move packages/money/src/total.ts packages/money/src/sum.ts --accept-rise
packages/money/src/total.ts → packages/money/src/sum.ts: 2 breaks moved.
no-comment rose to 2, up from 1: taken in with --accept-rise.
```
## When it refuses
[Section titled “When it refuses”](#when-it-refuses)
| Ashlar says | Why |
| ------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- |
| There is no baseline to move counts in yet: take it first with `ashlar check --shrink`. | The project has no baseline, so there are no counts to move. |
| Ashlar can't tell where packages/money/src/a.ts's counts go: exactly one of packages/money/src/a.ts and packages/money/src/b.ts must exist. | Both paths are files on disk, or neither is on disk and the baseline holds no file under the first. |
| Ashlar moved no counts: the move would take in new breaks. | The moved code holds more breaks than the baseline held for it. |
`ashlar move --json` prints each move: its `from`, its `to`, its `kind` (`file` or `folder`), the `breaks` it moved and the `rises` it took in.
## Related
[Section titled “Related”](#related)
* [The ratchet](/concepts/ratchet/)
* [Adopt Ashlar in an existing repository](/guides/adopt/)
* [CLI](/reference/cli/), for `ashlar move` and `ashlar check`
* [JSON contract](/reference/json/), for `ashlar move --json`
# Write a reach script
> Give a feature folder its reach.ts, the steps a person takes to reach the feature in the running app, then read it on the map and walk it with ashlar drive.
At the end of this guide, a feature folder holds a `reach.ts` that `ashlar map` shows and `ashlar drive` walks.
The examples come from a Tauri app in `apps/desktop`, whose features live in `apps/desktop/src/features/*`.
1. Find the feature folders that have no reach script yet:
Terminal
```console
$ pnpm exec ashlar map
Cart apps/desktop/src/features/cart
Open cart › Cart
0 proofs
Search apps/desktop/src/features/search
no reach script yet
1 proof
```
Every folder in an app's `features` is a feature folder, and the `feature-reach` rule counts one break in each that has no reach script that reads. `ashlar check` names the file to write:
Terminal
```console
$ pnpm exec ashlar check
Ashlar checked 11 files in 0.2 s: 1 count rose.
feature-reach in apps/desktop/src/features/search/reach.ts: 1, up from 0
apps/desktop/src/features/search/reach.ts:1:1
Every feature folder holds a reach script, `reach.ts`: the developer's way to the feature as drive steps, ending on a snapshot of what it reaches. It is plain data that imports only types. Write one, then run it with `ashlar drive `.
```
It exits with 1 here because the folder is new. If you took the baseline before the features had reach scripts, the baseline holds these breaks and the check passes until you write them.
2. Write `reach.ts` in the feature's folder:
apps/desktop/src/features/search/reach.ts
```ts
import type { ReachScript } from '@kurvball/ashlar/reach';
export default {
name: 'Search',
steps: [
{ key: 'ControlOrMeta+k' },
{ type: 'red shoes' },
{ key: 'Enter' },
{ snapshot: 'Results', role: 'list' },
],
} satisfies ReachScript;
```
The default export is the feature's `name` and its `steps`, the way a person reaches it from the app's home. It is plain data. Node loads it as it is, so it imports only types: no component, no other module and nothing that runs.
The `name` is what the developer and the agents call the feature. No two features may share one, and it is at most 60 characters.
Each step is one of four:
| Step | Does | Takes |
| ---------------------------- | ------------------------------------------------------------------------ | ----------------------------------------------- |
| `{ click: 'Open cart' }` | Clicks the one element with that accessible name. | `role`, when more than one element has the name |
| `{ type: 'red shoes' }` | Types the text into what has focus. | nothing more |
| `{ key: 'ControlOrMeta+k' }` | Presses a key. | nothing more |
| `{ snapshot: 'Results' }` | Reads the element with that name, and fails if nothing on screen has it. | `role`, when more than one element has the name |
The last step is a snapshot of what the reach gets to, so a run proves it got there, and only the last step is one. A script holds at most 40 steps. A name in a `click` or a `snapshot` is the words on screen, as a snapshot shows them, and at most 120 characters.
A `role` is one of `alertdialog`, `article`, `button`, `checkbox`, `combobox`, `complementary`, `dialog`, `grid`, `gridcell`, `group`, `heading`, `link`, `list`, `listitem`, `main`, `menu`, `menuitem`, `menuitemcheckbox`, `menuitemradio`, `navigation`, `option`, `radio`, `region`, `row`, `searchbox`, `status`, `switch`, `tab`, `tablist`, `tabpanel`, `textbox`, `toolbar`, `tree` or `treeitem`.
A `key` is named as Playwright names it: `Enter`, `Escape`, `Tab`, `Backspace`, `Delete`, `Space`, `ArrowUp`, `ArrowDown`, `ArrowLeft`, `ArrowRight`, `Home`, `End`, `PageUp`, `PageDown`, `F1` to `F12`, a lower-case letter or a digit, or one of ``, . / ; ' ` [ ] \ = -``. Put modifiers in front, joined by `+`: `ControlOrMeta`, `Meta`, `Control`, `Alt` and `Shift`. `ControlOrMeta+k` is ⌘K on a Mac and Ctrl+K elsewhere.
3. Read it on the map:
Terminal
```console
$ pnpm exec ashlar map
Cart apps/desktop/src/features/cart
Open cart › Cart
0 proofs
Search apps/desktop/src/features/search
ControlOrMeta+k › “red shoes” › Enter › Results
1 proof
```
A proof is a test in the feature's folder. `ashlar map --json` gives each step the drive command it runs:
Terminal
```json
{
"says": "Results",
"run": ["snapshot", "--name", "Results", "--role", "list"]
}
```
The `feature-reach` break for the folder is gone, and `ashlar check --shrink` lowers the baseline.
4. Fix a script that doesn't read. Ashlar says which step is wrong and why:
Terminal
```console
$ pnpm exec ashlar map
Cart apps/desktop/src/features/cart
Open cart › Cart
0 proofs
Search apps/desktop/src/features/search
its reach script doesn’t read: see below
1 proof
Search’s reach script doesn’t read. Step 1 presses a key drive doesn't know: name it as Playwright does, such as Meta+k.
```
That script pressed `Cmd+k`. A script that doesn't read still counts as a `feature-reach` break. Each refusal says one of these:
| Refusal | What Ashlar says |
| ------------------------ | ------------------------------------------------------------------------------------------ |
| `not_a_script` | A reach script's default export is an object: its name and its steps. |
| `no_name` | Give the reach script the name the developer and the agents say the feature by. |
| `long_name` | A feature's name is at most 60 characters. |
| `no_steps` | Give the reach script its steps, ending on a snapshot of what it reaches. |
| `too_many_steps` | A reach is at most 40 steps. |
| `bad_step` | Step n isn't a drive step: one of click (with a role, if it helps), type, key or snapshot. |
| `bad_key` | Step n presses a key drive doesn't know: name it as Playwright does, such as Meta+k. |
| `bad_role` | Step n names a role drive doesn't know. |
| `not_ending_on_snapshot` | A reach ends on a snapshot of what it reaches, so a run proves it got there. |
| `snapshot_midway` | Step n is a snapshot: only the last step is. |
A script that Node can't load, or that takes another feature's name, doesn't read either, and Ashlar says why in the same place.
5. Name your drive command in the config. It is the command that drives your running app:
ashlar.config.ts
```ts
import { defineConfig } from '@kurvball/ashlar';
export default defineConfig({
include: ['apps', 'packages'],
drive: 'pnpm drive',
apps: [{ root: 'apps/desktop', stack: 'tauri' }],
});
```
Ashlar runs it from the root, once for each step, with the step's arguments and `--json`:
Terminal
```sh
pnpm drive click --name 'Open cart' --role button --json
pnpm drive type 'red shoes' --json
pnpm drive key ControlOrMeta+k --json
pnpm drive snapshot --name Results --role list --json
```
It runs `stop` before the first step and after the last, so each walk starts the app afresh. The command answers with one JSON object on its last line of output: `{ "ok": true }` when the step worked, or `ok: false` with a `failure` (`not_found`, `ambiguous`, `not_running`, `timed_out` or `crashed`) and what it `says`. A command that prints no JSON is taken at its exit code. Each step has 60 seconds.
A drive command written in TypeScript can read these arguments with `parseDrive` from `@kurvball/ashlar/drive`. Without a drive command, a reach script is still data: the map, the brief and the onboarding guide show it, and `ashlar drive` says the config names none.
6. Walk the reach:
Terminal
```console
$ pnpm exec ashlar drive search
Search: reached in 4 steps.
```
Name the feature by its name or its folder. `--scheme dark` asks for the dark colour scheme: Ashlar runs each step with `DRIVE_SCHEME=dark`. `--all` walks every feature:
Terminal
```console
$ pnpm exec ashlar drive --all
Cart: reached in 2 steps.
Search: its reach stopped at “Results”, step 4 of 4. Nothing on screen is named “Results”.
1 of 2 features reached.
```
It exits with 1 when a reach stops. If the work broke the way in, fix the work. Change the reach script only when the way in itself changed. `--json` prints each walk as an object:
Terminal
```json
{
"version": 1,
"feature": "Cart",
"folder": "apps/desktop/src/features/cart",
"stoppedAt": 1,
"step": "Open cart",
"ms": 60,
"outcome": "stopped",
"steps": 2,
"says": "Nothing on screen is named “Open cart”."
}
```
## Related
[Section titled “Related”](#related)
* [The feature map](/concepts/feature-map/)
* [Agent skill](/agent-skill/): the verify skill walks the reach of each feature an agent's work changes
* [CLI](/reference/cli/), for `ashlar map` and `ashlar drive`
* [JSON contract](/reference/json/), for the map's and drive's JSON
* [Kurvball](/examples/kurvball/), two reach scripts written from a real app's labels
# Use Ashlar with Rehearse
> Let Rehearse run each feature's reach script as a flow, and answer rehearse list --affected from Ashlar's import graph.
At the end of this guide, Rehearse runs your features' reach scripts as flows, and knows which of them a change reaches through Ashlar's import graph.
Rehearse tries changes: it brings the product up, runs scenarios on the base and on your work, and compares them. It never needs Ashlar. When a project uses Ashlar, Ashlar fills two of its blocks:
| Rehearse needs | Ashlar gives it |
| ----------------------------------------------------- | ------------------------------------------ |
| Flows: steps by accessible name | each feature's reach script, as it is |
| What a change reaches, for `rehearse list --affected` | `ashlar dependents`, from the import graph |
Reach scripts stay Ashlar's data. Rehearse runs them.
Which Rehearse
Rehearse reads flows and answers `rehearse drive` from its 0.3.0. With 0.2.0 it reads Ashlar's graph for `rehearse list --affected`, but lists each flow as refused ("no reader for flow scenarios yet"), and `ashlar drive` needs the project's own drive command.
1. Print the blocks Ashlar fills:
Terminal
```console
$ pnpm exec ashlar rehearse
# Ashlar fills these blocks of rehearse.yaml: each feature’s reach script is a flow, and it
# covers its feature’s folder. rehearse list --affected asks `ashlar dependents` for the rest.
scenarios:
flows:
- path: 'desktop/electron-renderer/features/board/reach.ts'
covers: ['desktop/electron-renderer/features/board/**']
```
Each feature with a reach script becomes a flow, and it covers its feature's folder: a change anywhere in that folder reaches the flow. `--json` prints the same block in Rehearse's manifest schema, with each flow as Rehearse reads it.
2. Copy the block into `rehearse.yaml`, beside what your project already declares there.
3. Ask what a change reaches. Rehearse runs this itself when it finds `ashlar.config.ts` and an `ashlar` binary:
Terminal
```console
$ pnpm exec ashlar dependents desktop/electron-renderer/client/ideas.ts --json
```
Terminal
```json
{
"v": 1,
"dependents": {
"desktop/electron-renderer/client/ideas.ts": [
"desktop/electron-renderer/features/board/Board.test.tsx",
"desktop/electron-renderer/features/board/Board.tsx",
"desktop/electron-renderer/features/board/reach.ts"
]
},
"unknown": []
}
```
Each file lists every file that reaches it through imports, directly or not, and the reach script of each feature those files sit in. A reach script imports only types, so the graph alone would never lead to it. A file the graph doesn't hold, such as `README.md`, goes in `unknown`. The shape is Rehearse's own contract, `v` its version.
4. See which features a change reaches. `ashlar affected --json` lists them beside the tests, each with the reach script Rehearse runs as its flow:
Terminal
```json
"features": [
{
"folder": "desktop/electron-renderer/features/board",
"reach": "desktop/electron-renderer/features/board/reach.ts"
}
]
```
5. Walk a feature. With a `rehearse.yaml` and no `drive` in `ashlar.config.ts`, `ashlar drive ` walks its reach through `rehearse drive`: it stops anything left driven, starts the flows' service with `rehearse drive start`, takes each step, then stops again. A `drive` in the config wins: a project keeps its own drive command until it chooses Rehearse's. Rehearse's own browser shows the light colour scheme whatever `--scheme` asks; a service that names its own driver gets `DRIVE_SCHEME` and can honour it.
## Gotchas Rehearse guards
[Section titled “Gotchas Rehearse guards”](#gotchas-rehearse-guards)
A gotcha can be a rule in `.claude/rules/`, or a Rehearse scenario that tries it on every change. Name the scenario file `*.guard.flow.yaml` or `*.guard.rehearse.yaml`, and `ashlar onboard` lists it as a gotcha of its folder, with its `name` and `describe`:
apps/api/src/orders/cutoff.guard.rehearse.yaml
```yaml
name: A Toronto order at 16:59 still ships today
describe: The 17:00 cutoff once acted at noon.
```
Guards are found anywhere in the repository but the ignored folders, and `onboard.guards` in the config names other patterns. A rule in `.claude/rules/` can point at its guard too, with `guard: ` in its frontmatter; the guide and briefs then say "Guarded by" that file. Rehearse itself has no notion of a guard: the name is Ashlar's convention, and the scenario is an ordinary Rehearse scenario.
## Related
[Section titled “Related”](#related)
* [The feature map](/concepts/feature-map/)
* [Write a reach script](/guides/reach-scripts/)
* [Onboarding](/concepts/onboarding/)
* [CLI reference](/reference/cli/)
# Add a rule from a correction
> Turn a correction a person made into an Ashlar rule, with its case as a test, its ledger entry and the message the agent reads.
At the end of this guide, Ashlar has a new rule: its case is a test, `ledger.json` says what it corrected, and its message tells the agent what to do instead.
A rule exists because a person corrected an agent's work and didn't want to correct it again. A rule with no correction behind it isn't taken. The example below is `max-lines`, as it went in.
1. Write the correction down. Open a "Rule from a correction" issue on Ashlar's repository. It asks for:
* what the agent did wrong, with counts when there are some, such as "19 files over 1,000 lines";
* the case: the file, from the repository's root, and the smallest piece of code that shows it;
* what the rule should say instead, as the agent will read it;
* the prose it replaces: a line in `AGENTS.md`, `CLAUDE.md`, a skill or a review comment that people keep writing, or none;
* where it applies: everywhere, or which kind of folder.
Leave out anything private: the case becomes a test in Ashlar's source.
2. Get the developer's yes. Ashlar's `DECISIONS.md` holds the rule for rules:
DECISIONS.md
```markdown
- 2026-11-16 @daguenette [src/plugin, ledger.json] Every rule comes from a correction, names its replacement, ships with its case as a test, and needs the developer's yes.
```
Every project that uses Ashlar runs every rule its config doesn't turn off, so no rule goes in on an agent's word alone.
3. Write the case as a test, before the rule. Name the test after what went wrong, and put it in the rule's test file in `src/plugin/`:
src/plugin/text.test.ts
```ts
testRule('max-lines', maxLines, app, {
valid: [{ name: 'a file of 600 lines', file: 'desktop/src/services/cards/short.ts', code: lines(600) }],
invalid: [
{
name: 'WaitCard grew to 2,265 lines: one line over is already too long',
file: 'desktop/src/renderer/shell/WaitCard.tsx',
code: lines(601),
},
],
});
```
`invalid` holds the case: the rule fires on it, with its message. `valid` holds what the rule must leave alone.
4. Write the rule in `src/plugin/`. Add its name to `LINT_RULES` and its message to `MESSAGES` in `src/plugin/messages.ts`, and the rule to `rules` in `src/plugin/index.ts`. If it applies only in some places, say where in `APPLIES` in `src/onboard/applies.ts`, so a brief and the onboarding guide name it only there.
A rule reports each break through `found`, which prints the message from the project's `messages` when the config gives one.
5. Write the message. It tells the agent what to do instead, in one or two sentences:
ledger.json
```text
A file over 600 lines costs every agent that reads it. Split it along what it does.
```
Say what to do, not only what not to do. A project can replace it with its own words through `messages` in its config, so name no project's own hooks or folders.
6. Add its entry to `ledger.json`, in the same order as `LINT_RULES`:
ledger.json
```json
{
"id": "max-lines",
"rule": true,
"says": "No file over its line limit",
"applies": "all code",
"corrected": "19 files over 1,000 lines, sessions/adapter.ts at 2,382 and WaitCard.tsx at 2,265",
"by": "developer",
"replaces": null,
"case": {
"file": "src/plugin/text.test.ts",
"test": "WaitCard grew to 2,265 lines: one line over is already too long"
},
"message": "A file over 600 lines costs every agent that reads it. Split it along what it does."
}
```
| Field | Type | What it holds |
| ----------- | ----------------------------- | -------------------------------------------------------------------------------------------------------- |
| `id` | string | The rule's name, as `rules` and `messages` in a config name it. |
| `rule` | boolean | `true` for a rule `ashlar check` counts; `false` for a check the import graph makes, such as `affected`. |
| `says` | string | What the rule says, in one sentence with no full stop. |
| `applies` | string | Where it applies, read after "in": `all code`, `features`, `shared/`. |
| `corrected` | string | What the correction was, with its counts, with no full stop. |
| `by` | `developer`, `lead` or `gate` | Who made the correction. |
| `replaces` | string or `null` | The prose the rule replaces, word for word, or `null`. |
| `case.file` | string | The test file that holds the case, from Ashlar's root. |
| `case.test` | string | The case's test name, exactly as the test says it. |
| `message` | string | The message agents read under the default config. |
Tests check that the entries follow the rules' order, that each case is a test that is there to run, and that each `message` is the one the rule prints.
7. Read the entry as an agent would:
Terminal
```console
$ node src/cli.ts ledger
max-lines: No file over its line limit, in all code.
It corrected: 19 files over 1,000 lines, sessions/adapter.ts at 2,382 and WaitCard.tsx at 2,265.
Its case: src/plugin/text.test.ts, “WaitCard grew to 2,265 lines: one line over is already too long”.
A file over 600 lines costs every agent that reads it. Split it along what it does.
```
An entry that replaced prose says so on a line of its own:
Terminal
```console
$ node src/cli.ts ledger
affected: A builder and the item gate run the tests the import graph says a change reaches, in every change.
It corrected: Decisions 161 and 163: builders ran whole suites, eleven of them spending 394 of their 439 minutes of commands in test runs, and their prompts then told them in prose to pick the tests that cover their change.
Its case: src/affected.test.ts, “lists every test that reaches a changed file through the graph”.
It replaced: “Run only the test files you wrote or changed, each named by its path, never the whole test suite or a whole package's tests.”
A builder and the item gate run the tests the import graph says a change reaches.
```
In a project, `pnpm exec ashlar ledger` prints the same entries, with the messages the project's config gives.
## In your own project
[Section titled “In your own project”](#in-your-own-project)
Ashlar's rules hold for every project. A correction that belongs to one project goes in that project:
* A name only some folders may say, such as a provider's: a `confined` entry in the config, with its message. See [Config](/reference/config/).
* Better words for a rule, naming your own hooks: `messages` in the config.
* A rule no check can hold: a line in `DECISIONS.md` or a folder rule in `.claude/rules/`, which every brief for that folder carries. See [Answer questions and record decisions](/guides/decisions/).
When a rule is wrong for a case, change the rule and record why in the ledger. No comment in code turns a rule off, and a project turns one off for all its code with `rules` in its config.
## Related
[Section titled “Related”](#related)
* [Corrections](/concepts/corrections/)
* [Rules](/concepts/rules/)
* [CLI](/reference/cli/), for `ashlar ledger`
* [JSON contract](/reference/json/), for `ashlar ledger --json`
# Give a library or a CLI its areas
> Make each folder of a library or a CLI a service area, so public-api-only counts imports that reach past an area's index.
Make each folder of a library or a CLI a service area, so another folder imports it only through its `index.ts`.
Name one `web` app whose main side is the source folder, with no renderer, and `areas: ['*']`.
ashlar.config.ts
```ts
import { defineConfig } from '@kurvball/ashlar';
export default defineConfig({
include: ['src'],
apps: [{ root: 'src', stack: 'web', main: ['.'], renderer: [], areas: ['*'] }],
});
```
Ashlar now counts each import that reaches past an area's `index.ts`.
Terminal
```console
$ pnpm exec ashlar check
Ashlar checked 3 files in 0.1 s: 2 counts rose.
public-api-only in src/cli.ts: 1, up from 0
src/cli.ts:1:21
Import another feature or area through its `index.ts`. If you need something inside it, it belongs in its index or in `shared/`.
public-api-only in src/run/run.ts: 1, up from 0
src/run/run.ts:1:22
Import another feature or area through its `index.ts`. If you need something inside it, it belongs in its index or in `shared/`.
```
Without `areas`, the app's default areas match no folder, and `ashlar check` warns that `public-api-only` counts nothing there.
See every app key in the [config reference](/reference/config/#apps).
# Run the check in GitHub Actions
> Fail a pull request on GitHub when it makes a file worse than the baseline holds.
Fail a pull request when it makes a file worse than the baseline holds.
Give the check a script in `package.json`.
package.json
```json
{
"scripts": {
"check": "ashlar check"
}
}
```
Run that script on every pull request. Ashlar compares with `origin/main` to tell which lines a change wrote, so the checkout fetches the whole history.
.github/workflows/check.yml
```yaml
name: Check
on:
pull_request:
push:
branches: [main]
jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version: 22
cache: pnpm
- run: pnpm install --frozen-lockfile
- run: pnpm check
```
A pull request that adds a comment to `src/run/run.ts` now fails its check.
Terminal
```console
$ pnpm check
Ashlar checked 3 files in 0.1 s: 1 count rose.
no-comment in src/run/run.ts: 1, up from 0
src/run/run.ts:3:1
Comments go stale and nothing checks them. Rename it, or write a test. Git leads from any line to the item or task that wrote it.
```
Take the baseline first, as [Adopt Ashlar in an existing repository](/guides/adopt/) shows.
# Keep fetch calls in the client
> Make client-only count every fetch call outside a web app's client folder.
Keep every call a web app makes to its server in `client/`, where one module owns each endpoint.
Name `fetch` as the app's bridge.
ashlar.config.ts
```ts
import { defineConfig } from '@kurvball/ashlar';
export default defineConfig({
include: ['apps'],
apps: [{ root: 'apps/web', stack: 'web', bridge: { global: 'fetch' } }],
});
```
A feature that calls `fetch` itself now breaks `client-only`.
apps/web/client/features/cart/load.ts
```ts
export const loadCart = () => fetch('/api/cart');
```
Terminal
```console
$ pnpm exec ashlar check
Ashlar checked 3 files in 0.2 s: 1 count rose.
client-only in apps/web/client/features/cart/load.ts: 1, up from 0
apps/web/client/features/cart/load.ts:1:31
Only `client/` talks to the services.
```
The same call in `apps/web/client/client/cart.ts` passes.
See [Rules](/concepts/rules/) for where `client-only` applies.
# CLI
> Every ashlar command and its flags, generated from the usage text the command prints.
Run every command from inside the repository, through your package manager: `pnpm exec ashlar`, `yarn ashlar` or `npx --no-install ashlar`. Ashlar finds `ashlar.config.ts` in the folder you run it from or the nearest one above it.
| Exit code | Means |
| --------- | -------------------------------------------------------------------------------- |
| 0 | It did what it was asked, and nothing failed. |
| 1 | It ran, and something failed: a count rose, a reach stopped, the guide is stale. |
| 2 | It couldn’t run: the config or the command line is wrong. It says why on stderr. |
Every command that takes `--json` prints one JSON object (or, for `drive --all`, one array) with a `version`. See [JSON contract](/reference/json/).
## ashlar check
[Section titled “ashlar check”](#ashlar-check)
Added in: v0.1.0
Terminal
```sh
ashlar check [--shrink] [--accept-rise] [--json]
```
Runs the rules and the import graph, and fails when a file's count rises above what the baseline holds for that file. A file the baseline doesn't name holds none. `--shrink` writes the baseline: it takes it the first time, then only lowers each file's counts. A file that is gone drops out, and a file git saw renamed takes its counts to its new name. `--accept-rise` takes each count that rose into the baseline, and says what it took in.
## ashlar affected
[Section titled “ashlar affected”](#ashlar-affected)
Added in: v0.1.0
Terminal
```sh
ashlar affected [files...] [--since [] [--json]
```
Lists the tests that reach the files, or the files changed since `][`, through imports, stylesheets, setup files and builds. A deleted file lists the tests that imported it, and `--json` lists the deleted files apart.
## ashlar move
[Section titled “ashlar move”](#ashlar-move)
Added in: v0.1.0
Terminal
```sh
ashlar move [ ...] [--accept-rise] [--json]
```
Moves a file's counts in the baseline to its new name, or those of every file in a folder. Each file keeps what it holds now, up to what the baseline held for it. It refuses a move that takes in new breaks, unless `--accept-rise` is given.
## ashlar ledger
[Section titled “ashlar ledger”](#ashlar-ledger)
Added in: v0.1.0
Terminal
```sh
ashlar ledger [--json]
```
Lists Ashlar's ledger: each rule and each check from the import graph, what it corrected, the case it came from as a test, the prose it replaced and the message agents read.
## ashlar map
[Section titled “ashlar map”](#ashlar-map)
Added in: v0.1.0
Terminal
```sh
ashlar map [--json]
```
Lists each feature folder in the layout: its name, its reach and its proofs, the tests in it. `--json` prints it as JSON, in the feature map's schema.
## ashlar drive
[Section titled “ashlar drive”](#ashlar-drive)
Added in: v0.1.0
Terminal
```sh
ashlar drive [--scheme light|dark] [--json]
```
Terminal
```sh
ashlar drive --all [--scheme light|dark] [--json]
```
Walks a feature's reach script, step by step, through the config's drive command, or through rehearse drive when the project has a rehearse.yaml and names none. It stops at the first step that fails, saying which and why. `--all` walks every feature's.
## ashlar onboard
[Section titled “ashlar onboard”](#ashlar-onboard)
Added in: v0.2.0
Terminal
```sh
ashlar onboard [--check] [--json]
```
Writes the onboarding guide from the map, DECISIONS.md and `.claude/rules/:` what the system is, a page per area, and every unknown as a question routed to its owner. `--check` fails when the guide is stale or was edited by hand, and writes nothing.
## ashlar brief
[Section titled “ashlar brief”](#ashlar-brief)
Added in: v0.2.0
Terminal
```sh
ashlar brief [--json]
```
Prints what an agent needs before it changes those files: the data rules, the rules that apply there, the folder rules and gotchas, the decisions, the features and the open questions. Never access lines, and never a secret-shaped value.
## ashlar snapshot
[Section titled “ashlar snapshot”](#ashlar-snapshot)
Added in: v0.2.0
Terminal
```sh
ashlar snapshot [--json]
```
Prints where things stand today: the ratchet, the map, the decisions and questions, and each area's recent commits. It writes nothing.
## ashlar dependents
[Section titled “ashlar dependents”](#ashlar-dependents)
Added in: v1.0.0
Terminal
```sh
ashlar dependents [--json]
```
Lists every file that reaches each file through imports, directly or not, and the reach script of each feature whose folder they touch: what Rehearse reads for rehearse list `--affected`. `--json` prints it in Rehearse's dependents contract.
## ashlar rehearse
[Section titled “ashlar rehearse”](#ashlar-rehearse)
Added in: v1.0.0
Terminal
```sh
ashlar rehearse [--json]
```
Prints the blocks of rehearse.yaml Ashlar fills: each feature's reach script as a flow that covers its folder. `--json` adds each flow as Rehearse reads it.
## ashlar skill
[Section titled “ashlar skill”](#ashlar-skill)
Added in: v0.1.0
Terminal
```sh
ashlar skill verify|onboard [--write] [--force]
```
Prints a skill for agents. verify: how an agent checks its own work with the map and drive, and shows what it made, through the attach section the config names, if any. onboard: how an agent reads its brief before it changes files, and keeps what people decide. `--write` writes it into `.claude/skills//SKILL.md`, and `--force` replaces one that differs.
## ashlar --version
[Section titled “ashlar --version”](#ashlar---version)
Added in: v1.2.0
Terminal
```sh
ashlar --version
```
Prints the version of Ashlar that runs.
# Config
> Every key Ashlar reads from ashlar.config.ts, with its type, its default and what it means.
ashlar.config.ts
```ts
import { defineConfig } from '@kurvball/ashlar';
export default defineConfig({
include: ['src'],
});
```
That is a whole config. `include` is the only key Ashlar needs. Every other key has a default, given below.
Ashlar looks for `ashlar.config.ts` in the folder you run it from, then in each folder above it. It also reads `ashlar.config.mts`, `ashlar.config.js` and `ashlar.config.mjs`. The file's default export is the config, and `defineConfig` only gives it its type. The folder that holds the file is the project's root: every path in the config is a path from there, except the paths inside an app, which are paths from the app's `root`.
Ashlar checks the config as it loads it. A key it doesn't read, or a value of the wrong type, gets one line each, and the command exits with 2:
Terminal
```console
$ pnpm exec ashlar check
ashlar.config.ts doesn't read:
`maxLine` isn't a key Ashlar reads: include, ignore, apps, setups, tests, maxLines, baseline, drive, confined, rules, messages, skills, onboard.
`rules.no-timers` names no rule: no-cross-process-import, shared-is-pure, public-api-only, no-effect, no-timer, no-dom-query, client-only, no-comment, no-disable, max-lines, named-only-in, feature-reach.
`rules.no-dom-query` is 'on' or 'off'.
`messages.named-only-in` lives in each `confined` entry, as its `message`.
```
## The top level
[Section titled “The top level”](#the-top-level)
| Key | Type | Default | Meaning | Added in |
| ---------- | ---------------------- | -------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------- |
| `include` | list of strings | none: required | The folders Ashlar checks, from the root. Give at least one. | Added in: v0.1.0 |
| `ignore` | list of strings | `['node_modules', 'out', 'dist', 'release']` | Folder names skipped at any depth. Your list replaces the default, so name the defaults you still want. Folders whose names start with a dot are always skipped. | Added in: v0.1.0 |
| `apps` | list of apps | `[]` | Each app's layout: its stack and where its sides live. See [Apps](#apps). | Added in: v0.1.0 |
| `setups` | list of setups | `[]` | Setup files and the tests they run before, with paths from the root. See [Setups](#setups). | Added in: v0.1.0 |
| `tests` | list of strings | `['.test.ts', '.test.tsx']` | The endings that make a file a test. | Added in: v0.1.0 |
| `maxLines` | whole number above 0 | `600` | The most lines a file may hold before `max-lines` counts each line over. | Added in: v0.1.0 |
| `baseline` | string | `'ashlar.baseline.json'` | The baseline file, from the root. | Added in: v0.1.0 |
| `drive` | string | none | The shell command that drives the running app, such as `'pnpm drive'`, for a project without Rehearse. With a `rehearse.yaml` and no `drive`, `ashlar drive` goes through `rehearse drive`. | Added in: v0.1.0 |
| `confined` | list of confined names | `[]` | Words that may appear only in the folders you name. See [Confined names](#confined-names). | Added in: v0.1.0 |
| `rules` | object | every rule on | Turns a rule off for the whole project. See [Rules](#rules). | Added in: v0.1.0 |
| `messages` | object | each rule's own message | Replaces the message agents read for a rule. See [Messages](#messages). | Added in: v0.1.0 |
| `skills` | object | none | Settings for the skills Ashlar prints. See [Skills](#skills). | Added in: v0.1.0 |
| `onboard` | object | see [Onboard](#onboard) | Where onboarding reads and writes, and who owns what. | Added in: v0.2.0 |
A file is a test when its path ends with one of `tests`. `ashlar map` lists the tests in a feature's folder as its proofs, and `ashlar affected` lists tests. `shared-is-pure`, `client-only`, `no-effect`, `no-timer`, `no-dom-query` and `named-only-in` leave tests alone. `no-comment`, `no-disable` and `max-lines` check them too.
## Apps
[Section titled “Apps”](#apps)
ashlar.config.ts
```ts
apps: [
{ root: 'apps/desktop', stack: 'tauri' },
{ root: 'apps/api', stack: 'web', main: ['src'], renderer: [], shared: [], areas: ['src/*'] },
],
```
Each entry in `apps` is one app. Its `stack` gives every other key a default, so `root` and `stack` are often all an app needs. Every path in an app is from its `root`. A path that ends in `/*` means each folder directly inside it.
| Key | Type | Default | Meaning | Added in |
| ------------------------ | ---------------------------------- | --------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------- |
| `apps[].root` | string | none: required | The app's folder, from the project's root. | Added in: v0.1.0 |
| `apps[].stack` | `'electron'`, `'tauri'` or `'web'` | none: required | The app's stack. It names the default folders below. | Added in: v0.1.0 |
| `apps[].main` | list of strings | the stack's main folder | The folders of the main side: the services, the host or the server. | Added in: v0.1.0 |
| `apps[].renderer` | list of strings | the stack's renderer folder | The folders of the renderer side: the screens. `[]` for an app with no renderer, such as an API. | Added in: v0.1.0 |
| `apps[].shared` | list of strings | `['shared']` | The folders both sides may import: types and pure functions only. | Added in: v0.1.0 |
| `apps[].features` | list of strings | `['/features/*']` | The feature folders. Each one holds a reach script. None when `renderer` is `[]`. | Added in: v0.1.0 |
| `apps[].client` | list of strings | `['/client']` | The folders that talk to the services. None when `renderer` is `[]`. | Added in: v0.1.0 |
| `apps[].primitives` | list of strings | `['/primitives']` | The folders of hooks and small parts that features build on. None when `renderer` is `[]`. | Added in: v0.1.0 |
| `apps[].areas` | list of strings | `['/*']` | The service areas. Another area is imported only through its `index.ts`, and each area gets a page in the onboarding guide. | Added in: v0.1.0 |
| `apps[].bridge` | object | see below | How the renderer reaches the services. | Added in: v0.1.0 |
| `apps[].bridge.global` | string | none | The global the renderer reaches the services by, such as `api` for `window.api`. Features and primitives never use it. | Added in: v0.1.0 |
| `apps[].bridge.modules` | list of strings | `[]` | Modules that talk to the services. Features and primitives never import them. | Added in: v0.1.0 |
| `apps[].bridge.packages` | list of strings | the stack's packages | The packages that reach the other side. Features, primitives and shared code never import them. A name ending in `*` matches each package it starts. | Added in: v0.1.0 |
| `apps[].builds` | list of builds | `[]` | Tests that reach a change only through a build. See [Builds](#builds). | Added in: v0.1.0 |
| `apps[].setups` | list of setups | `[]` | The app's setup files, with paths from its `root`. See [Setups](#setups). | Added in: v0.1.0 |
`` and `` are the stack's own folder names, as below, whatever `main` and `renderer` say.
| Stack | `main` | `renderer` | `shared` | `features` | `client` | `primitives` | `areas` | `bridge.packages` |
| ---------- | --------------- | ------------------- | -------- | ------------------------------ | -------------------------- | ------------------------------ | ----------------- | ----------------------------------------- |
| `electron` | `electron-main` | `electron-renderer` | `shared` | `electron-renderer/features/*` | `electron-renderer/client` | `electron-renderer/primitives` | `electron-main/*` | `electron` |
| `tauri` | `src-tauri` | `src` | `shared` | `src/features/*` | `src/client` | `src/primitives` | `src-tauri/*` | `@tauri-apps/api`, `@tauri-apps/plugin-*` |
| `web` | `server` | `client` | `shared` | `client/features/*` | `client/client` | `client/primitives` | `server/*` | none |
### Builds
[Section titled “Builds”](#builds)
ashlar.config.ts
```ts
builds: [{ tests: ['e2e/**/*.e2e.test.ts'], reach: ['src', 'index.html', 'vite.config.ts'] }],
```
Some tests run against a built app, so no import leads from them to the code they test. A build names those tests and what goes into the build. When a change reaches anything in `reach`, `ashlar affected` lists every test in `tests`.
| Key | Type | Default | Meaning | Added in |
| ----------------------- | --------------- | -------------- | ---------------------------------------------------------------------- | ---------------- |
| `apps[].builds[].tests` | list of strings | none: required | Globs of the tests that run against the build, from the app's `root`. | Added in: v0.1.0 |
| `apps[].builds[].reach` | list of strings | none: required | The files, folders or globs the build takes in, from the app's `root`. | Added in: v0.1.0 |
### Setups
[Section titled “Setups”](#setups)
ashlar.config.ts
```ts
setups: [{ files: ['packages/ui/src/test/setup.ts'], tests: ['packages/ui/src/**/*.test.{ts,tsx}'] }],
```
A setup file runs before tests without any test importing it. A setup names those files and the tests they run before, so a change to a setup file reaches those tests. `setups` at the top level takes paths from the project's root; `apps[].setups` takes paths from the app's `root`.
| Key | Type | Default | Meaning | Added in |
| ------------------------- | --------------- | -------------- | ----------------------------------------------------------------------------- | ---------------- |
| `setups[].files` | list of strings | none: required | The setup files, or globs of them. | Added in: v0.1.0 |
| `setups[].tests` | list of strings | none: required | Globs of the tests they run before. | Added in: v0.1.0 |
| `setups[].exclude` | list of strings | `[]` | Globs of tests the setup files don't run before, though `tests` matches them. | Added in: v0.1.0 |
| `apps[].setups[].files` | list of strings | none: required | The same, from the app's `root`. | Added in: v0.1.0 |
| `apps[].setups[].tests` | list of strings | none: required | The same, from the app's `root`. | Added in: v0.1.0 |
| `apps[].setups[].exclude` | list of strings | `[]` | The same, from the app's `root`. | Added in: v0.1.0 |
## Confined names
[Section titled “Confined names”](#confined-names)
ashlar.config.ts
```ts
confined: [
{
words: ['stripe'],
only: ['apps/api/src/payments'],
within: ['apps'],
message: 'Only `apps/api/src/payments/` names the payment provider. Call `charge` from its index instead.',
},
],
```
A confined name is a word that only some folders may say, such as the name of a provider that one module wraps. The `named-only-in` rule counts each string, template text, regular expression or JSX text that holds one of `words` outside `only`. It matches whole words and ignores case. It never counts an import path, a test, or a file in a folder named `test`.
| Key | Type | Default | Meaning | Added in |
| -------------------- | --------------- | ---------------- | ------------------------------------------------------------ | ---------------- |
| `confined[].words` | list of strings | none: required | The words to confine. Give at least one. | Added in: v0.1.0 |
| `confined[].only` | list of strings | `[]` | The folders or files that may say them. | Added in: v0.1.0 |
| `confined[].within` | list of strings | `[]`, everywhere | Where the rule looks. Outside these folders it says nothing. | Added in: v0.1.0 |
| `confined[].message` | string | none: required | The message agents read when the rule counts one. | Added in: v0.1.0 |
## Rules
[Section titled “Rules”](#rules)
ashlar.config.ts
```ts
rules: { 'no-dom-query': 'off' },
```
`rules` turns a rule off for the whole project. No comment in code can, and `no-disable` counts any comment that tries. Each value is `'on'` or `'off'`, and every rule is on until you turn it off.
| Key | Type | Default | Meaning |
| -------------- | ----------------- | ------- | ----------------------------------------------------------- |
| `rules.` | `'on'` or `'off'` | `'on'` | Whether `ashlar check` runs the rule and counts its breaks. |
The rules are `no-cross-process-import`, `shared-is-pure`, `public-api-only`, `no-effect`, `no-timer`, `no-dom-query`, `client-only`, `no-comment`, `no-disable`, `max-lines`, `named-only-in` and `feature-reach`. [Rules](/concepts/rules/) says what each one counts.
## Messages
[Section titled “Messages”](#messages)
ashlar.config.ts
```ts
messages: {
'no-timer': 'A timer patches over a render you don’t control. Wait with `useDebounced` from `primitives/`.',
},
```
`messages` replaces the message agents read for a rule, in `ashlar check`, `ashlar ledger`, `ashlar brief` and the onboarding guide. Use it to name your own hooks and folders.
| Key | Type | Default | Meaning |
| ----------------- | ------ | ---------------------- | --------------------------------------------------- |
| `messages.` | string | the rule's own message | The words agents read when the rule counts a break. |
Any rule but `named-only-in` takes a message here. A confined name's message is its entry's `message`.
## Skills
[Section titled “Skills”](#skills)
ashlar.config.ts
```ts
skills: { verify: { attach: 'docs/attach.md' } },
```
| Key | Type | Default | Meaning | Added in |
| ---------------------- | ------ | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------- |
| `skills.verify` | object | none | Settings for the verify skill that `ashlar skill verify` prints. | Added in: v0.1.0 |
| `skills.verify.attach` | string | none | A Markdown file, from the root, whose text ends the verify skill: where the agent puts its screens and video. Without one, the skill asks the agent to name them in its report. | Added in: v0.1.0 |
`ashlar skill verify` fails when `skills.verify.attach` names a file that isn't there. See [Agent skill](/agent-skill/).
## Onboard
[Section titled “Onboard”](#onboard)
ashlar.config.ts
```ts
onboard: {
owner: '@sam',
owners: { 'apps/api': '@lee' },
},
```
`onboard` says where `ashlar onboard`, `ashlar brief` and `ashlar snapshot` read and write, and who owns what. `ashlar onboard` needs `onboard.owner`. Every other key has a default.
| Key | Type | Default | Meaning | Added in |
| ------------------- | --------------- | ------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- | ---------------- |
| `onboard.out` | string | `'docs/onboarding'` | The folder `ashlar onboard` writes the guide into. It must be a folder inside the project. | Added in: v0.2.0 |
| `onboard.decisions` | string | `'DECISIONS.md'` | The file of decisions, one line each. | Added in: v0.2.0 |
| `onboard.rules` | string | `'.claude/rules'` | The folder of folder rules: every `.md` file in it, at any depth. | Added in: v0.2.0 |
| `onboard.owner` | string | none | The project's default owner, as a handle such as `@sam`. Every question nobody else owns goes to them. | Added in: v0.2.0 |
| `onboard.owners` | object | `{}` | Owners by folder, such as `{ 'apps/api': '@lee' }`. The longest folder that holds an area wins, and it wins over `owner` lines. | Added in: v0.2.0 |
| `onboard.areas` | list of strings | with no apps, each folder directly inside an `include` folder | More areas: folders, or `folder/*` for each folder directly inside one. No other glob. The apps' features and areas are always areas too. | Added in: v0.2.0 |
| `onboard.documents` | list of strings | `README.md` and each app's `README.md` | The documents onboarding asks about: is each one current, and who keeps it? Files that aren't there are left out. | Added in: v0.2.0 |
| `onboard.dataRules` | list of strings | two rules, below | The data rules every brief and the guide carry. Your list replaces the default. | Added in: v0.2.0 |
| `onboard.guards` | list of strings | `**/*.guard.flow.yaml`, `**/*.guard.rehearse.yaml` | Rehearse scenario files that guard a gotcha, found anywhere but the ignored folders. Each is a gotcha of its folder, named by its `name`. | Added in: v1.0.0 |
The default data rules:
* Real data never enters the repository: not in code, tests, fixtures or documents.
* Secrets are never printed, logged or written into the repository.
[Answer questions and record decisions](/guides/decisions/) shows these keys at work.
## A full example
[Section titled “A full example”](#a-full-example)
Every key, in one config. Most projects need far less.
ashlar.config.ts
```ts
import { defineConfig } from '@kurvball/ashlar';
export default defineConfig({
include: ['apps', 'packages'],
ignore: ['node_modules', 'dist', 'out', 'coverage'],
tests: ['.test.ts', '.test.tsx'],
maxLines: 500,
baseline: 'ashlar.baseline.json',
drive: 'pnpm drive',
apps: [
{
root: 'apps/desktop',
stack: 'tauri',
main: ['src-tauri'],
renderer: ['src'],
shared: ['src/shared'],
features: ['src/features/*'],
client: ['src/client'],
primitives: ['src/primitives'],
areas: ['src-tauri/*'],
bridge: {
global: 'shop',
modules: ['src/client/ipc.ts'],
packages: ['@tauri-apps/api', '@tauri-apps/plugin-*'],
},
builds: [{ tests: ['e2e/**/*.e2e.test.ts'], reach: ['src', 'index.html', 'vite.config.ts'] }],
setups: [
{
files: ['src/test/setup.ts'],
tests: ['src/**/*.test.{ts,tsx}'],
exclude: ['src/theme/*.test.ts'],
},
],
},
{ root: 'apps/api', stack: 'web', main: ['src'], renderer: [], shared: [], areas: ['src/*'] },
],
setups: [{ files: ['packages/money/test/setup.ts'], tests: ['packages/money/src/**/*.test.ts'] }],
confined: [
{
words: ['stripe'],
only: ['apps/api/src/payments'],
within: ['apps'],
message:
'Only `apps/api/src/payments/` names the payment provider. Call `charge` from its index instead.',
},
],
rules: { 'no-dom-query': 'off' },
messages: {
'no-timer':
'A timer patches over a render you don’t control. Wait with `useDebounced` from `primitives/`.',
},
skills: { verify: { attach: 'docs/attach.md' } },
onboard: {
out: 'docs/onboarding',
decisions: 'DECISIONS.md',
rules: '.claude/rules',
owner: '@sam',
owners: { 'apps/api': '@lee' },
areas: ['packages/*'],
documents: ['README.md', 'apps/api/README.md'],
dataRules: [
'Real data never enters the repository: not in code, tests, fixtures or documents.',
'Secrets are never printed, logged or written into the repository.',
'A fixture’s email address ends in @example.com.',
],
},
});
```
## Related
[Section titled “Related”](#related)
* [Adopt Ashlar in an existing repository](/guides/adopt/)
* [Rules](/concepts/rules/)
* [The ratchet](/concepts/ratchet/)
* [CLI](/reference/cli/)
# JSON contract
> What each command prints with --json, generated from the JSON Schemas Ashlar ships.
Every command that takes `--json` prints one JSON value on stdout and nothing else. Each carries a `version` and has a JSON Schema in `schema/`, shipped in the package as `@kurvball/ashlar/schema/.v1.json`. Two answer to Rehearse rather than to Ashlar: `dependents` and `rehearse` carry Rehearse’s `v`, and follow its contract. A new field is added without a new version; a field that changes or goes raises the version. Tools such as Rehearse read these and nothing else.
## ashlar affected --json
[Section titled “ashlar affected --json”](#ashlar-affected---json)
Added in: v0.3.0
The tests a change reaches, the features it reaches with their reach scripts, the changed and deleted files, and the files no test reaches. Schema: `schema/affected.v1.json`.
| Field | Type | Added in |
| ------------------- | --------------- | ---------------- |
| `version` | `1` | Added in: v0.3.0 |
| `changed` | list of strings | Added in: v0.3.0 |
| `deleted` | list of strings | Added in: v0.3.0 |
| `tests` | list of strings | Added in: v0.3.0 |
| `features` | list of objects | Added in: v1.0.0 |
| `features[].folder` | string | Added in: v1.0.0 |
| `features[].reach` | string or null | Added in: v1.0.0 |
| `unreached` | list of strings | Added in: v0.3.0 |
| `seconds` | number | Added in: v0.3.0 |
## ashlar brief --json
[Section titled “ashlar brief --json”](#ashlar-brief---json)
Added in: v0.3.0
What an agent needs before it changes the files: never an access line. Schema: `schema/brief.v1.json`.
| Field | Type | Added in |
| ---------------------- | ------------------------------------------------------------ | ---------------- |
| `version` | `1` | Added in: v0.3.0 |
| `paths` | list of strings | Added in: v0.3.0 |
| `areas` | list of objects | Added in: v0.3.0 |
| `areas[].path` | string | Added in: v0.3.0 |
| `areas[].name` | string | Added in: v0.3.0 |
| `areas[].owner` | string or null | Added in: v0.3.0 |
| `owners` | list of objects | Added in: v0.3.0 |
| `owners[].path` | string | Added in: v0.3.0 |
| `owners[].owner` | string or null | Added in: v0.3.0 |
| `dataRules` | list of strings | Added in: v0.3.0 |
| `rules` | list of objects | Added in: v0.3.0 |
| `rules[].id` | string | Added in: v0.3.0 |
| `rules[].message` | string | Added in: v0.3.0 |
| `folderRules` | list of objects | Added in: v0.3.0 |
| `folderRules[].file` | string | Added in: v0.3.0 |
| `folderRules[].title` | string | Added in: v0.3.0 |
| `folderRules[].gotcha` | string or null | Added in: v0.3.0 |
| `folderRules[].text` | string | Added in: v0.3.0 |
| `folderRules[].guard` | string or null | Added in: v1.0.0 |
| `decisions` | list of objects | Added in: v0.3.0 |
| `decisions[].date` | string | Added in: v0.3.0 |
| `decisions[].owner` | string | Added in: v0.3.0 |
| `decisions[].areas` | list of strings | Added in: v0.3.0 |
| `decisions[].kind` | `"decision"` or `"rule"` or `"trust"` or `"setup"` | Added in: v0.3.0 |
| `decisions[].text` | string | Added in: v0.3.0 |
| `features` | list of objects | Added in: v0.3.0 |
| `features[].name` | string | Added in: v0.3.0 |
| `features[].folder` | string | Added in: v0.3.0 |
| `features[].reach` | string or null | Added in: v0.3.0 |
| `questions` | list of objects | Added in: v0.3.0 |
| `questions[].id` | string | Added in: v0.3.0 |
| `questions[].kind` | `"owner"` or `"reach"` or `"know"` or `"setup"` or `"trust"` | Added in: v0.3.0 |
| `questions[].area` | string | Added in: v0.3.0 |
| `questions[].owner` | string | Added in: v0.3.0 |
| `questions[].asks` | string | Added in: v0.3.0 |
| `questions[].answer` | string | Added in: v0.3.0 |
## ashlar check --json
[Section titled “ashlar check --json”](#ashlar-check---json)
Added in: v0.3.0
Whether any file's count rose above the baseline, each rule's totals, and every rise with its breaks. Schema: `schema/check.v1.json`.
| Field | Type | Added in |
| ------------------------- | ------------------------------------------------------------ | ---------------- |
| `version` | `1` | Added in: v0.3.0 |
| `ok` | boolean | Added in: v0.3.0 |
| `seconds` | number | Added in: v0.3.0 |
| `files` | integer | Added in: v0.3.0 |
| `baseline` | `"held"` or `"taken"` or `"shrunk"` or `"risen"` or `"none"` | Added in: v0.3.0 |
| `rules` | list of objects | Added in: v0.3.0 |
| `rules[].rule` | string | Added in: v0.3.0 |
| `rules[].count` | integer | Added in: v0.3.0 |
| `rules[].baseline` | integer | Added in: v0.3.0 |
| `rises` | list of objects | Added in: v0.3.0 |
| `rises[].rule` | string | Added in: v0.3.0 |
| `rises[].file` | string | Added in: v0.3.0 |
| `rises[].count` | integer | Added in: v0.3.0 |
| `rises[].baseline` | integer | Added in: v0.3.0 |
| `rises[].message` | string | Added in: v0.3.0 |
| `rises[].added` | integer | Added in: v0.3.0 |
| `rises[].breaks` | list of objects | Added in: v0.3.0 |
| `rises[].breaks[].file` | string | Added in: v0.3.0 |
| `rises[].breaks[].line` | integer | Added in: v0.3.0 |
| `rises[].breaks[].column` | integer | Added in: v0.3.0 |
| `rises[].breaks[].size` | integer | Added in: v0.3.0 |
| `rises[].breaks[].fresh` | boolean | Added in: v0.3.0 |
| `taken` | list of objects | Added in: v0.3.0 |
| `taken[].rule` | string | Added in: v0.3.0 |
| `taken[].file` | string | Added in: v0.3.0 |
| `taken[].count` | integer | Added in: v0.3.0 |
| `taken[].baseline` | integer | Added in: v0.3.0 |
| `slack` | integer | Added in: v0.3.0 |
| `moves` | list of objects | Added in: v0.3.0 |
| `moves[].from` | string | Added in: v0.3.0 |
| `moves[].to` | string | Added in: v0.3.0 |
## ashlar dependents --json
[Section titled “ashlar dependents --json”](#ashlar-dependents---json)
Added in: v1.0.0
For each file, every file that reaches it through imports and the reach script of each feature those files sit in; files the graph doesn't hold go in unknown. This is Rehearse's dependents contract (its schema/v1/dependents.schema.json); v is Rehearse's contract version. Schema: `schema/dependents.v1.json`.
| Field | Type | Added in |
| ------------ | --------------- | ---------------- |
| `v` | `1` | Added in: v1.0.0 |
| `dependents` | object | Added in: v1.0.0 |
| `unknown` | list of strings | Added in: v1.0.0 |
## ashlar drive --json
[Section titled “ashlar drive --json”](#ashlar-drive---json)
Added in: v0.3.0
One feature's walk, or every feature's with --all. Schema: `schema/drive.v1.json`.
It prints one of these objects, or a list of them with `--all`.
| Field | Type | Added in |
| ----------- | ------------------------------------------------------------ | ---------------- |
| `version` | `1` | Added in: v0.3.0 |
| `feature` | string | Added in: v0.3.0 |
| `folder` | string | Added in: v0.3.0 |
| `outcome` | `"reached"` or `"stopped"` or `"no_reach"` or `"unreadable"` | Added in: v0.3.0 |
| `steps` | integer | Added in: v0.3.0 |
| `stoppedAt` | integer or null | Added in: v0.3.0 |
| `step` | string or null | Added in: v0.3.0 |
| `says` | string or null | Added in: v0.3.0 |
| `ms` | integer | Added in: v0.3.0 |
## ashlar ledger --json
[Section titled “ashlar ledger --json”](#ashlar-ledger---json)
Added in: v0.3.0
Each rule and each check, the correction it came from, its case and the message agents read. Schema: `schema/ledger.v1.json`.
| Field | Type | Added in |
| --------------------- | ------------------------------------- | ---------------- |
| `version` | `1` | Added in: v0.3.0 |
| `entries` | list of objects | Added in: v0.3.0 |
| `entries[].id` | string | Added in: v0.3.0 |
| `entries[].rule` | boolean | Added in: v0.3.0 |
| `entries[].says` | string | Added in: v0.3.0 |
| `entries[].applies` | string | Added in: v0.3.0 |
| `entries[].corrected` | string | Added in: v0.3.0 |
| `entries[].by` | `"developer"` or `"lead"` or `"gate"` | Added in: v0.3.0 |
| `entries[].replaces` | string or null | Added in: v0.3.0 |
| `entries[].case` | object | Added in: v0.3.0 |
| `entries[].case.file` | string | Added in: v0.3.0 |
| `entries[].case.test` | string | Added in: v0.3.0 |
| `entries[].message` | string | Added in: v0.3.0 |
## ashlar map --json
[Section titled “ashlar map --json”](#ashlar-map---json)
Added in: v0.3.0
Each feature folder: its name, its reach as drive steps, and its proofs. Schema: `schema/map.v1.json`.
| Field | Type | Added in |
| -------------------------- | --------------- | ---------------- |
| `version` | `1` | Added in: v0.3.0 |
| `features` | list of objects | Added in: v0.3.0 |
| `features[].name` | string | Added in: v0.3.0 |
| `features[].folder` | string | Added in: v0.3.0 |
| `features[].reach` | list of objects | Added in: v0.3.0 |
| `features[].reach[].says` | string | Added in: v0.3.0 |
| `features[].reach[].run` | list of strings | Added in: v0.3.0 |
| `features[].proofs` | list of objects | Added in: v0.3.0 |
| `features[].proofs[].file` | string | Added in: v0.3.0 |
## ashlar move --json
[Section titled “ashlar move --json”](#ashlar-move---json)
Added in: v0.3.0
Each move: what moved, how many breaks it carried, and any rise it took in. Schema: `schema/move.v1.json`.
| Field | Type | Added in |
| ----------------------- | ---------------------- | ---------------- |
| `version` | `1` | Added in: v0.3.0 |
| `moves` | list of objects | Added in: v0.3.0 |
| `moves[].from` | string | Added in: v0.3.0 |
| `moves[].to` | string | Added in: v0.3.0 |
| `moves[].kind` | `"file"` or `"folder"` | Added in: v0.3.0 |
| `moves[].breaks` | integer | Added in: v0.3.0 |
| `moves[].rises` | list of objects | Added in: v0.3.0 |
| `moves[].rises[].rule` | string | Added in: v0.3.0 |
| `moves[].rises[].file` | string | Added in: v0.3.0 |
| `moves[].rises[].held` | integer | Added in: v0.3.0 |
| `moves[].rises[].count` | integer | Added in: v0.3.0 |
## ashlar onboard --json
[Section titled “ashlar onboard --json”](#ashlar-onboard---json)
Added in: v0.3.0
The guide's model: the areas, decisions, folder rules and questions, and what was written. Schema: `schema/onboard.v1.json`.
| Field | Type | Added in |
| -------------------- | --------------------------------------------------------------- | ---------------- |
| `version` | `1` | Added in: v0.3.0 |
| `project` | string | Added in: v0.3.0 |
| `out` | string | Added in: v0.3.0 |
| `ok` | boolean | Added in: v0.3.0 |
| `written` | list of strings | Added in: v0.3.0 |
| `stale` | list of strings | Added in: v0.3.0 |
| `removed` | list of strings | Added in: v0.3.0 |
| `areas` | list of objects | Added in: v0.3.0 |
| `areas[].path` | string | Added in: v0.3.0 |
| `areas[].name` | string | Added in: v0.3.0 |
| `areas[].kind` | `"feature"` or `"area"` or `"folder"` | Added in: v0.3.0 |
| `areas[].app` | string or null | Added in: v0.3.0 |
| `areas[].owner` | string or null | Added in: v0.3.0 |
| `areas[].page` | string | Added in: v0.3.0 |
| `decisions` | list of objects | Added in: v0.3.0 |
| `decisions[].line` | integer | Added in: v0.3.0 |
| `decisions[].date` | string | Added in: v0.3.0 |
| `decisions[].owner` | string | Added in: v0.3.0 |
| `decisions[].areas` | list of strings | Added in: v0.3.0 |
| `decisions[].kind` | `"decision"` or `"rule"` or `"trust"` or `"owner"` or `"setup"` | Added in: v0.3.0 |
| `decisions[].text` | string | Added in: v0.3.0 |
| `rules` | list of objects | Added in: v0.3.0 |
| `rules[].file` | string | Added in: v0.3.0 |
| `rules[].title` | string | Added in: v0.3.0 |
| `rules[].paths` | list of strings or null | Added in: v0.3.0 |
| `rules[].gotcha` | string or null | Added in: v0.3.0 |
| `rules[].owner` | string or null | Added in: v0.3.0 |
| `rules[].date` | string or null | Added in: v0.3.0 |
| `rules[].text` | string | Added in: v0.3.0 |
| `rules[].guard` | string or null | Added in: v1.0.0 |
| `questions` | list of objects | Added in: v0.3.0 |
| `questions[].id` | string | Added in: v0.3.0 |
| `questions[].kind` | `"owner"` or `"reach"` or `"know"` or `"setup"` or `"trust"` | Added in: v0.3.0 |
| `questions[].area` | string | Added in: v0.3.0 |
| `questions[].owner` | string | Added in: v0.3.0 |
| `questions[].asks` | string | Added in: v0.3.0 |
| `questions[].answer` | string | Added in: v0.3.0 |
## ashlar rehearse --json
[Section titled “ashlar rehearse --json”](#ashlar-rehearse---json)
Added in: v1.0.0
The blocks of rehearse.yaml Ashlar fills, each flow as Rehearse reads it, and the features with no flow. Its v is Rehearse's contract version; manifest follows Rehearse's manifest schema and each flow its flow schema. Schema: `schema/rehearse.v1.json`.
| Field | Type | Added in |
| ----------------------------------- | --------------- | ---------------- |
| `v` | `1` | Added in: v1.0.0 |
| `manifest` | object | Added in: v1.0.0 |
| `manifest.version` | `1` | Added in: v1.0.0 |
| `manifest.scenarios` | object | Added in: v1.0.0 |
| `manifest.scenarios.flows` | list of objects | Added in: v1.0.0 |
| `manifest.scenarios.flows[].path` | string | Added in: v1.0.0 |
| `manifest.scenarios.flows[].covers` | list of strings | Added in: v1.0.0 |
| `flows` | list of objects | Added in: v1.0.0 |
| `flows[].file` | string | Added in: v1.0.0 |
| `flows[].flow` | object | Added in: v1.0.0 |
| `flows[].flow.name` | string | Added in: v1.0.0 |
| `flows[].flow.covers` | list of strings | Added in: v1.0.0 |
| `flows[].flow.steps` | list of objects | Added in: v1.0.0 |
| `missing` | list of strings | Added in: v1.0.0 |
## ashlar snapshot --json
[Section titled “ashlar snapshot --json”](#ashlar-snapshot---json)
Added in: v0.3.0
Where things stand on one date. Never kept. Schema: `schema/snapshot.v1.json`.
| Field | Type | Added in |
| -------------------- | --------------- | ---------------- |
| `version` | `1` | Added in: v0.3.0 |
| `date` | string | Added in: v0.3.0 |
| `branch` | string or null | Added in: v0.3.0 |
| `commit` | string or null | Added in: v0.3.0 |
| `ratchet` | list of objects | Added in: v0.3.0 |
| `ratchet[].rule` | string | Added in: v0.3.0 |
| `ratchet[].baseline` | integer | Added in: v0.3.0 |
| `map` | object | Added in: v0.3.0 |
| `map.features` | integer | Added in: v0.3.0 |
| `map.withReach` | integer | Added in: v0.3.0 |
| `decisions` | integer | Added in: v0.3.0 |
| `rules` | integer | Added in: v0.3.0 |
| `questions` | integer or null | Added in: v0.3.0 |
| `areas` | list of objects | Added in: v0.3.0 |
| `areas[].path` | string | Added in: v0.3.0 |
| `areas[].name` | string | Added in: v0.3.0 |
| `areas[].lastChange` | string or null | Added in: v0.3.0 |
| `areas[].commits30` | integer | Added in: v0.3.0 |
# Versions and releases
> What Ashlar promises from one version to the next, what counts as breaking, and how to pin a release.
Ashlar follows [semantic versioning](https://semver.org/spec/v2.0.0.html). A version is `major.minor.patch`:
* a **patch** release fixes something and changes no shape or meaning;
* a **minor** release adds something: a command, a flag, a config key, an optional field in an output;
* a **major** release may break what worked: it says so in its changelog section.
## What counts as breaking
[Section titled “What counts as breaking”](#what-counts-as-breaking)
Tools such as Rehearse read Ashlar only through what it prints and how it exits. So these are Ashlar's public API, and changing any of them in a way that could break a reader is a major release:
| Public | Breaking |
| --------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------ |
| The commands and their flags ([CLI](/reference/cli/)) | a command or flag removed or renamed, or doing something else |
| The exit codes: 0, 1 and 2 | a code that means something else |
| The JSON outputs ([JSON contract](/reference/json/)) | a field removed, renamed, or of another type or meaning |
| The config ([Config](/reference/config/)) | a key removed or renamed, or meaning something else |
| The package's exports: `@kurvball/ashlar`, `@kurvball/ashlar/reach`, `@kurvball/ashlar/drive`, `@kurvball/ashlar/map` | a name removed, or of another type |
| The rules | a new rule on by default, since it can fail a check that passed the day before |
A new optional field in a JSON output is not breaking: readers ignore what they don't know.
### A JSON shape never changes inside its version
[Section titled “A JSON shape never changes inside its version”](#a-json-shape-never-changes-inside-its-version)
Each output has a schema, `schema/.v1.json`, and prints its `version` (or `v`). A shape that has to change gets a new file, `schema/.v2.json`, a raised `version`, and a major release. The v1 schema is never edited to describe another shape, so a tool that validates against v1 never sees v1 change under it.
## Pin a release
[Section titled “Pin a release”](#pin-a-release)
Each release is a tag, `vX.Y.Z`, and a GitHub Release with the package's tarball attached, `kurvball-ashlar-X.Y.Z.tgz`. Ashlar is not on npm yet, so pin a release by its tarball:
Terminal
```sh
pnpm add -D ./vendor/kurvball-ashlar-1.1.0.tgz
```
Download the tarball from the release's page into your repository (here `vendor/`), or build it from the tag:
Terminal
```sh
git clone --branch v1.1.0 https://github.com/kurvball/ashlar.git
cd ashlar
pnpm install
pnpm pack
```
Your `package.json` then names that exact file, so every install gets that exact version until you change it.
Once Ashlar is on npm, pin it as any package: `pnpm add -D @kurvball/ashlar@1.1.0` for one version, `@kurvball/ashlar@^1` for the 1.x line. A fix to an older line is published under that line's dist-tag, such as `@kurvball/ashlar@release-1.x`, never `latest`.
## Where to read what changed
[Section titled “Where to read what changed”](#where-to-read-what-changed)
Every version's section is in the [changelog](/changelog/), and in the notes of its GitHub Release.
## Related
[Section titled “Related”](#related)
* [CLI](/reference/cli/)
* [JSON contract](/reference/json/)
* [Config](/reference/config/)
* [Changelog](/changelog/)
# Check a project
> Tutorial unit 1: install Ashlar in a new project, run a check, see a rule fail with the message an agent reads, and fix what it found.
In this unit, you install Ashlar in a small TypeScript project, run `ashlar check`, watch a rule fail with the message an agent reads, and fix what it found. At the end, the check passes again:
Terminal
```console
$ pnpm exec ashlar check
Ashlar checked 1 file in 0.1 s: no count rose.
There is no baseline, so every count must stay at zero.
```
## Before you begin
[Section titled “Before you begin”](#before-you-begin)
* Node 22.18 or later. Ashlar loads `ashlar.config.ts` with Node's own type stripping, so the config needs no build step.
* Git.
* pnpm, npm or Yarn. Each command on this page shows all three.
Ashlar is not on npm
Each [release](https://github.com/kurvball/ashlar/releases) attaches its packed tarball, and you install that by its address. The package is `@kurvball/ashlar`, made by [Kurvball](https://www.kurvball.ca), and its command is `ashlar`.
Never run a bare npx ashlar
A package named `ashlar` on npm is someone else's, and `npx ashlar` would download and run it. Run Ashlar through your package manager: `pnpm exec ashlar`, `yarn ashlar` or `npx --no-install ashlar`.
## Check a project
[Section titled “Check a project”](#check-a-project)
1. Make a project with Git.
Terminal
```sh
mkdir shop
cd shop
git init
```
Give it a `package.json`, with `"type": "module"` so Node reads `ashlar.config.ts` as a module.
package.json
```json
{
"name": "shop",
"private": true,
"type": "module"
}
```
If a project can't have `"type": "module"`, name the config `ashlar.config.mts` instead.
Add one file of code.
src/total.ts
```ts
export function total(prices: number[]): number {
return prices.reduce((sum, price) => sum + price, 0);
}
```
2. Install Ashlar as a dev dependency, from its release.
* pnpm
Terminal
```sh
pnpm add -D https://github.com/kurvball/ashlar/releases/download/v1.2.1/kurvball-ashlar-1.2.1.tgz
```
* npm
Terminal
```sh
npm install -D https://github.com/kurvball/ashlar/releases/download/v1.2.1/kurvball-ashlar-1.2.1.tgz
```
* Yarn
Terminal
```sh
yarn add -D https://github.com/kurvball/ashlar/releases/download/v1.2.1/kurvball-ashlar-1.2.1.tgz
```
3. Write `ashlar.config.ts` at the root of the project.
ashlar.config.ts
```ts
import { defineConfig } from '@kurvball/ashlar';
export default defineConfig({
include: ['src'],
});
```
`include` names the folders Ashlar checks. It is the only key a config needs. The [config reference](/reference/config/) lists the others.
4. Run the check.
* pnpm
Terminal
```sh
pnpm exec ashlar check
```
* npm
Terminal
```sh
npx --no-install ashlar check
```
* Yarn
Terminal
```sh
yarn ashlar check
```
Ashlar prints what it checked, and exits with 0.
Terminal
```console
$ pnpm exec ashlar check
Ashlar checked 1 file in 0.1 s: no count rose.
There is no baseline, so every count must stay at zero.
```
A project with no baseline holds every rule at zero breaks.
5. Break a rule. Add a comment to `src/total.ts`, as an agent might.
src/total.ts
```diff
+// Adds up the prices in the cart.
export function total(prices: number[]): number {
return prices.reduce((sum, price) => sum + price, 0);
}
```
Run the check again. This time it fails, and exits with 1.
Terminal
```console
$ pnpm exec ashlar check
Ashlar checked 1 file in 0.1 s: 1 count rose.
no-comment in src/total.ts: 1, up from 0
src/total.ts:1:1
Comments go stale and nothing checks them. Rename it, or write a test. Git leads from any line to the item or task that wrote it.
```
The check names the rule, the file, its count against the baseline, and where each break is. The last line is the rule's message: what an agent reads, and what to do instead.
6. Do what the message says. The comment said what the function adds up, so let the name say it.
src/total.ts
```ts
export function cartTotal(prices: number[]): number {
return prices.reduce((sum, price) => sum + price, 0);
}
```
Run the check once more. It passes.
Terminal
```console
$ pnpm exec ashlar check
Ashlar checked 1 file in 0.1 s: no count rose.
There is no baseline, so every count must stay at zero.
```
## On a repository that already has breaks
[Section titled “On a repository that already has breaks”](#on-a-repository-that-already-has-breaks)
Most code isn't at zero. In a repository with breaks, take a baseline once.
Terminal
```console
$ pnpm exec ashlar check --shrink
Ashlar checked 2 files in 0.1 s and took the baseline: 3 breaks in ashlar.baseline.json.
```
Commit `ashlar.baseline.json`. From then on, `ashlar check` fails when a file's count rises above what the baseline holds for it, and `--shrink` only ever lowers it. [The ratchet](/concepts/ratchet/) explains how, and [Adopt Ashlar in an existing repository](/guides/adopt/) walks through it.
Ashlar exits with 0 when all is well, 1 when a check or a drive fails, and 2 when a command or the config is wrong. Every command but `skill` takes `--json`.
## Next steps
[Section titled “Next steps”](#next-steps)
[Rules](/concepts/rules/)Each rule, where it applies, and how an app's layout turns on the rules about imports and features.
[The ratchet](/concepts/ratchet/)How the baseline holds old code as it is and keeps every file from getting worse.
[Adopt Ashlar in an existing repository](/guides/adopt/)Take a baseline of the breaks you have, then keep every file from getting worse.
[Agent skill](/agent-skill/)Give your coding agents the skills to check their own work and read their brief.]