Rules
sqry rules runs declarative checks against the code graph. A rule is a
graph query plus a pass/fail (or informational) verdict, packaged with a
witness that records exactly what fired. sqry ships built-in rule packs, and you
can author your own as TOML. The same engine is exposed to AI assistants through
the rules_run MCP tool.
Run a rule or pack
sqry rules run <RULE_OR_PACK> [PATH] [--format text|json]
| Argument / flag | Default | Description |
|---|---|---|
<RULE_OR_PACK> | required | A shipped rule id, a shipped pack selector, or a path to a TOML rule pack. |
[PATH] | . | Workspace path. sqry walks up to the nearest .sqry-index when needed. |
--format | text | text for a human-readable report, json for machine-readable output plus full witness data. |
A selector that matches a shipped rule id runs that single rule. Any other selector is treated as a path to a TOML rule pack.
Built-in packs
Three selectors ship with sqry:
| Selector | Contents |
|---|---|
bbnty.intake | First-run intake pack: call cycles, entry points, unused nodes, duplicate bodies. |
bbnty.recipes | Seven proof-recipe rules (pr_r1 through pr_r7). |
bbnty.all | The recipes plus the intake rules. |
These are useful as a first pass and as worked examples for authoring your own packs. For standing project-specific checks, write a TOML rule pack and pass its path.
Reading the report
sqry rules run bbnty.intake
rules source: bbnty.intake
rule bbnty.intake.cycles.calls
status: ok
output: 0 cycle component(s)
witness: 1 step(s), 0 citation(s), truncated=false
- rule fired bbnty.intake.cycles.calls, severity=info
rule bbnty.intake.entrypoints
status: ok
output: 8746 entry-point node(s)
witness: 1024 step(s), 0 citation(s), truncated=true
- ... use --format json for full witness data
rule bbnty.intake.unused.nodes
status: ok
output: 21041 node(s)
rule bbnty.intake.duplicates.body
status: unsupported
error: rule requires beside-cache coordination; use the MCP surface
Each rule reports:
- status:
okwhen the rule ran, orunsupportedwhen it needs a capability the single-snapshot CLI path does not provide (see below). - output: a short summary of what the rule produced (counts, components, paths).
- witness: the recorded steps and citations that justify the result.
Long witnesses are truncated in text output; use
--format jsonfor the full record.
Unsupported rules on the CLI
Some rules need beside-cache coordination, for example comparative queries or
structural-similarity lookups across snapshots. Those report status: unsupported on the single-snapshot CLI path and are reserved for the
coordinator and MCP surface. In the built-in packs this affects the
duplicate-body and several proof-recipe rules. Everything else runs on the CLI.
JSON output
sqry rules run bbnty.intake --format json
{
"source": "bbnty.intake",
"results": [
{
"id": "bbnty.intake.cycles.calls",
"status": "ok",
"output": { "cycles": [] },
"witness": { "steps": [], "citations": [], "truncated": false },
"error": null
}
]
}
The JSON form carries the full, untruncated witness for every rule, which is the right input for CI gates and agent workflows.
MCP tool
The standalone MCP server exposes the same engine as rules_run. Resolve a
shipped rule or pack by id, or point it at a TOML rule pack by workspace path;
the tool returns each rule’s structured output plus its witness. Rules that need
cross-snapshot or similarity routes are reported as unsupported until the
coordinator surface is enabled.
See also
- Diagnostics for index health and troubleshooting.
- MCP Tools for the full tool reference.