How to add a lint rule
Extend internal/lint with a deterministic rule, its table-driven tests, and keep docs and templates green.
You want a new deterministic check inside agore-skill lint. The lint
engine is fixed at ten rules today; a new rule is a deliberate product
decision, and this page shows the mechanical path once that decision is
made.
Shape the rule first
Every rule has an ID, a severity, a trigger condition and an exact message
template. Keep the existing alphabet: prefixes group by concern
(SPEC-* specification, LAYOUT-*, TRIG-*, CTX-* context, SEC-*
security), numbers increment within the prefix.
Implement the rule
- Open
internal/lint/rules.go. Rules run in a fixed order — SPEC-001 … SEC-002 — and a rule is skipped when its ID is listed inskill.lint.ignore. - Add your check as part of the rule table. Rules receive
*skill.Skill, the*inspect.Reportand theconfig.LintConfig(with budgets); derive what you need from those inputs only. - Emit a
lint.Diagnosticwith the rule ID, severity, affected file and the message formatted from its template. Diagnostics must be deterministic: same input, same output, no I/O, no time, no randomness.
Test the rule
internal/lint/rules_test.go is table-driven. Add cases for:
- the exact trigger condition (positive),
- the boundary just below the trigger (negative),
- the message string, byte-for-byte against the template,
- interaction with
ignore(the rule skipped).
Then run the invariant tests: the lint package asserts that all three
embedded scaffold templates stay at 0 errors and 0 warnings. If your
rule would fire on a fresh agore-skill create output, either the templates
must be updated or the rule rethought — a rule that trips the happy path
breaks the tutorial contract.
mise run test
mise run coverKeep the docs in sync
- Lint rules reference — add the trigger logic and message template to the table and the rule's own section.
- If the rule has a known fix, add it to How to enforce lint in CI.
- Update the CLI's help facts if the flag surface changed (it usually should not).
Pass the gate
mise run checkRelated
- The existing rules and their exact templates: Lint rules reference
- Why rules are pure and deterministic: Deterministic offline-first design