Skip to content

rulecast

rulecast

Your project's conventions, checked while your coding agent works.

rulecast runs as your coding agent's hooks. When an edit breaks one of your project's rules, the agent is told in the same turn, along with the part of your docs the rule comes from, so it can fix the code before it moves on.

A rule is a check, such as a regex, an ast-grep pattern, a linter or a command, together with a message and a section of your docs. The same rules run in git hooks and CI.

It also works when nobody is watching, in a /goal run, under claude -p or in CI. There rulecast holds the agent at each stop, up to a limit, until its findings are fixed or written into its final report. rulecast run also gives the loop an exit code to stop on. You still decide which conventions become rules. Agent loops guide

Ask your agent about Rulecast today.

1 Your docs say it

conventions/backend.md

Errors

Services raise domain exceptions. app/api/errors.py maps each one to a status code.

2 A rule checks for it, and cites it

.rulecast-config.yaml

- id: backend/no-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"

3 An edit breaks it, and your agent hears both, in the same turn

Edit app/services/users.py
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.
Edit app/services/users.py
(nothing new: rulecast stays quiet)
Bash python scripts/scaffold_service.py users
rulecast: 1 rule violated in app/services/users.py, changed by your Bash command
 
error backend/no-httpexception
app/services/users.py:3 raises HTTPException(500). Raise a domain exception.

Around the tools it already uses.

rulecast runs as your agent's hooks. Nothing to start, no daemon.

Session startsstart
rulecast records the working tree, so it can tell later what changed.
Reads a filetouch
The conventions for that file arrive once, with their doc sections.
Edits a fileguard · edit
A protected file is refused before the write. Anything else is checked after it, and new findings come back in the same turn.
Runs a commandshell-before · shell-after
What the command wrote is checked like an edit. A protected file it touched must be reverted.
Tries to stopverify
It is held back while a new error stands: once per prompt by default, or up to ten times in an unattended run, after which what's left goes into the agent's final report. Changes no tool call explains are reported and never block.

Let your agent set it up.

Paste this into your coding agent. It installs rulecast, then shows you every file it changed.

Set up rulecast in this project. Read
https://syv-ai.github.io/rulecast/agents/SETUP.md
and follow it. Show me every file it creates or changes before I commit anything.