Skip to content

Rules

A rule is a sentence you want the agent to obey. bee stores it, and the hooks deliver it — at session start, on every prompt, or on the file it is about.

Terminal window
bee hook rule add "never call GetCollection directly — use a DataSource"
bee hook rule list
bee hook rule rm <id>
Terminal window
bee hook rule add "<text>" --scope always|session|prompt|file
scope delivered
always (default) at session start and on every prompt
session once, at session start
prompt on every prompt
file only when a matching file is written — see below

A rule can name the files it is about:

Terminal window
bee hook rule add "a DataSource never calls GetCollection" --path '*DataSource.cs'
bee hook rule add "every component has a Vitest spec" --path 'src/**/*.vue'

--path implies file delivery. And this is the point: a rule that names files is excluded from the per-turn block entirely. The fifty turns that touch nothing relevant stop paying for it, and the one that does gets it unburied among rules that do not apply.

Deliberately gitignore-shaped, because that is the notation people already know:

pattern matches
*DataSource.cs that file name anywhere in the tree
src/**/*.vue any .vue under src/, at any depth
deploy/** everything under a directory
src/*.cs only directly inside src/* stops at a /

Matching is case-insensitive: a rule author is describing a convention, not addressing an inode.

By default a rule steers this project only — resolved from the git remote, so the same checkout on another machine is the same project. To steer everything:

Terminal window
bee hook rule add "commit messages are English" --global

Every rule records who wrote it, read from git’s own config (repository-local identity wins over global). On a team store, bee hook rule list tells you whose convention you are following.

Terminal window
bee budget

Breaks the injected context down by component, for session start and for a sample prompt. If a rule set has grown expensive, this is where it shows.