Rules
In a repository
Section titled “In a repository”A Tauri app keeps its features in desktop/src/features/. Its config names the app and its stack:
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:
import { invoke } from '@tauri-apps/api/core';
export async function saveScheme(scheme: string): Promise<void> { await invoke('save_scheme', { scheme });}$ pnpm exec ashlar checkAshlar 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”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 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”| 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 <paths> prints only
the rules that apply to those paths.
What each rule counts
Section titled “What each rule counts”no-commentcounts every comment but a shebang and a triple-slash directive such as/// <reference types="vite/client" />. A comment that turns a rule off counts underno-disableinstead. A comment over several lines counts once per line.no-disablecountseslint-disableandoxlint-disablecomments,biome-ignore,@ts-ignore,@ts-nocheckand@ts-expect-error.max-linescounts the lines over the limit, so a file 12 lines too long counts 12.named-only-incounts 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-importcounts each import from the other side of the same app, type imports included.shared-is-purecounts imports ofnode: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 aswindow,documentandprocess.public-api-onlycounts each import that reaches past another feature's or area'sindex.ts.client-onlycounts imports of the packages that reach the other side, and uses of the app's bridge.no-effectcounts calls touseEffect,useLayoutEffectanduseInsertionEffect.no-timercounts calls tosetTimeout,setInterval,requestAnimationFrameandrequestIdleCallback.no-dom-querycounts calls toquerySelector,querySelectorAll,closestand thegetElementByIdfamily.feature-reachcounts one break for each feature folder whosereach.tsis missing or doesn't read. See The 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”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 for each key.
Turn a rule off
Section titled “Turn a rule off”A project can turn a rule off for all its code in its config:
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:
$ pnpm exec ashlar checkashlar.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”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:
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.', },});$ pnpm exec ashlar checkAshlar 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”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:
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.', }, ],});$ pnpm exec ashlar checkAshlar 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”maxLines sets the limit max-lines holds files to. It is 600 when the config doesn't say.
Related
Section titled “Related”- The ratchet: how counts are held against a baseline.
- Corrections: where each rule came from, and how a new one is added.
- Add a rule from a correction
- Config reference
- CLI reference