Skip to content

Rules

A Tauri app keeps its features in desktop/src/features/. Its config names the app and its stack:

ashlar.config.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
import { invoke } from '@tauri-apps/api/core';
export async function saveScheme(scheme: string): Promise<void> {
await invoke('save_scheme', { scheme });
}
Terminal window
$ 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.

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.

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.

  • no-comment counts every comment but a shebang and a triple-slash directive such as /// <reference types="vite/client" />. 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.

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.

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.

A project can turn a rule off for all its code in its config:

ashlar.config.ts
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 window
$ 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.

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
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 window
$ 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.

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
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 window
$ 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.

maxLines sets the limit max-lines holds files to. It is 600 when the config doesn't say.