Your conventions are spread across AGENTS.md, agent memories, /docs, specs and linter configs. Your agent read some of it forty tool calls ago, and forgets. rulecast turns conventions into rules and checks them in your agent's hooks: when an edit breaks one, the agent gets the finding and the doc section it cites, in the same turn.
The same output as text
rulecast: 1 rule violated in app/services/users.py
error backend/no-httpexception
app/services/users.py:2 raises HTTPException(404) in the service layer. Raise a domain exception; the API layer maps it to a response.
--- conventions/backend.md#errors ---
## Errors
Services raise domain exceptions. `app/api/errors.py` maps each one to a status code.
Getting started
In Claude Code:
/plugin install rulecast --marketplace syv-ai/rulecast
/rulecast:setup
With another agent, paste this:
Set up rulecast in this project with me. Read
https://syv-ai.github.io/rulecast/agents/SETUP.md
and follow it.
The agent reads your repo, docs and agent memories, then shows you one page: the rules that fit (from your linters, your git hooks, generated code) and the few questions only you can answer. Nothing is written until you approve.
The agent hooks run in Claude Code today. Another agent can set up the same rules for git hooks and CI.
Most rules come later, one at a time: when the agent makes a mistake that shouldn't happen again, run /rulecast:add-rule.
A rule
Rules live in .rulecast-config.yaml:
repos:
- repo: local
rules:
- id: backend/no-httpexception
name: Services raise domain exceptions, not HTTPException
files: '^app/services/.*\.py$'
detect:
regex:
pattern: 'raise\s+HTTPException\((?<args>[^)]*)\)'
message: "{{file}}:{{line}} raises HTTPException({{args}}) in the service layer. Raise a domain exception; the API layer maps it to a response."
context:
- "@conventions/backend.md#errors"
files selects what the rule applies to; detect names a detector.
message is what the agent reads. Named capture groups become template variables.
context is the doc section delivered with the finding.
More in Writing rules: refusing a write, linters with their docs, turning a rule off.
Detectors
| Detector | Catches | Default stages |
|---|
linter | Errors from ruff, oxlint, eslint or gitleaks under the project's own config, each with its doc section | edit, verify; verify for eslint |
command | Whatever a tool or script reports (SARIF, JSON, checkstyle, file:line: lines…): type checkers, dead-code finders, scanners by config | edit, verify; verify with scope: project |
hook | A hook your .pre-commit-config.yaml or lefthook.yml already declares | verify |
ast-grep | Structure, not text: a call shape, a swallowed exception | edit, verify |
regex | A pattern in the file's text | edit, verify |
path | The file's path alone: "never edit src/client/" | edit, verify |
llm | Conventions nothing mechanical expresses, judged by a model. Opt-in | verify |
verify runs when the agent stops; a rule can opt into the edit hook with stages: [edit, verify]. See agents/reference/detectors.md.
Commands