Skip to content

Custom Rules

llms.txt lists every page for an agent
Optional: hand this page to your coding agentThe steps work by hand too.
Show the whole prompt
Read https://intentius.io/chant/lint-rules/custom-rules/.
Write the project lint rule I describe as a `rule({...})` call with an id under our own prefix, such as `ORG001`, in a file under `lint-rules/`, and add the file to `lint.plugins` in `chant.config.ts`.
Run `npx chant lint`, show me what the rule reports, and open a pull request with the rule and no fixes to the code it flags.
Never deploy to a real cloud account or shared environment (with `chant run`, `chant components` or a platform's own CLI), approve (a pull request review, `chant approve` or `chant run approve`), override a policy denial (`chant approve policy-override`), or merge; never cut or publish a release (`chant release cut --yes` or `chant release publish`), push or delete a `ci/*` tag (`chant ci tick` pushes them), or change the value of an existing flag; never touch `.chant/allowed_signers` or `chant/lifecycle`.

Write project-specific lint rules as declarative rule({...}) calls.

Add your rule files to the plugins array in chant.config.ts:

export default {
lint: {
plugins: ["./lint-rules/org-standards.ts"],
},
};

Each rule is a top-level rule({...}) call:

rule({
id: "ORG001",
severity: "warning",
message: "Storage resources must have versioning enabled",
match: match.property("versioning").on(match.anyResource()),
pattern: "true",
});
FieldTypeDescription
idstringUnique rule identifier
severity"error" | "warning" | "info"Default severity level
messagestringDiagnostic message
matchselectorStructural selector for AST nodes
FieldTypeDescription
patternstringRegex pattern the matched value must satisfy
requirestringComma-separated list of required property names
maxnumberNumeric threshold
SelectorMatches
match.resource("ClassName")new ClassName({...}) expressions
match.anyResource()Any new expression
match.stringLiteral()String literal values
match.exportName()Exported declaration names
match.importSource()Import module specifiers
match.property("name")Object property with given key
match.exportedConst()export const declarations

Narrow a selector with .on():

match.property("tags").on(match.resource("StorageType"))

If a custom rule ID collides with a built-in rule, the linter reports an error at startup. Choose IDs namespaced to your organization (e.g., ORG001, ACME001).

chant