1. brindle
  2. Guides
  3. Rule packs

Rule packs and checks for coding agents

A rule in a prompt is a request. A rule brindle checks against the diff is a gate. Write both in one markdown file and attach it to any agent profile.

Type
Guide
Updated
Related
Codex reviews Claude Code
Milestone checks
Rewind an agent

Teams have standing rules for agent code: no shelling out with user input, no new dependency without a conversation, every source change comes with a test. Pasting them into prompts works until someone forgets, and a model that's told a rule can still break it. brindle splits the job. The prose goes into the agent's prompt, for every provider. The parts that can be matched mechanically are checked against what the branch changed, in the same step as your repo's checks.

Start from a profile with extends

A profile is a markdown file with frontmatter naming the provider, model and prompt for a worker or reviewer. It can start from another profile instead of copying it. Put it in .brindle/agents/ in the repo, or ~/.brindle/agents/ for yourself:

---
name: api-auditor
description: Reviews a branch as an API security audit
extends: reviewer
rules: security/api
---
Audit the change the way a security reviewer would...

extends names one parent, looked up in the repo's profiles, then yours, then the organization's library when available, then the built-ins. A pinned organization profile takes precedence over repo and user files. The child's fields override the parent's one by one, and its prompt is added to the parent's. Chains work; a cycle is an error that names the loop. brindle profile show api-auditor prints the profile as brindle resolves it.

Write a rule pack

The rules field names rule packs. A pack is a markdown file in .brindle/rules/ (the repo's), ~/.brindle/rules/ (yours), the organization's library when available or a built-in, in that order of precedence; pinned organization packs come first. security/api is the file security/api.md. A child's packs come after its parent's. Pick names that aren't built-in ones: a repo file named like a built-in, such as security/backend, replaces it unless organization policy pins that name.

---
name: security/api
description: API code handles untrusted input, secrets and the shell carefully
deny_deps: [pickle]
require_tests_for: [src/**/*.py]
deny_patterns:
  - shell=True
  - \beval\(
---
Treat every input that crosses a trust boundary as hostile until validated...

The text below the frontmatter is the standing instruction. It joins the prompt on Claude Code, Codex, Antigravity, OpenCode and local models alike, with the mechanical rules spelled out so the agent knows what's checked. A pack with only prose is just a prompt.

Three packs ship ready to use. security/backend covers shell-outs from input, eval, unsafe deserializing and secrets in code. tests/only requires a test file whenever the diff changes a non-test file. style/minimal-diff asks for the smallest diff that does the job. Two built-in profiles use them: backend-auditor is reviewer plus security/backend, and qa is developer plus tests/only.

What the diff checks do

Four frontmatter keys are checked against the branch's diff (what it commits on top of its base):

  • deny_deps: names that may not be imported or added to a dependency manifest. brindle reads added import, from and require lines and manifests such as pyproject.toml, requirements*.txt, package.json, go.mod and Cargo.toml.
  • require_tests_for: globs. A change to a matching file must come with an added or changed test file in the same diff, such as one under tests/, a test_* file or a *.spec.* file.
  • deny_patterns: regular expressions that no added line may match.
  • direct_spawn_allowed: globs for the Python files allowed to start processes directly. Outside those files and tests, added process-starting calls are refused.

These run with your checks. The reviewer's check summary lists each pack as pass or fail with the offending file:line. merge_workspace refuses the branch while a pack fails and hands the violations back for the worker to fix, like a failing test. No model has to notice: a worker that adds shell=True is stopped by a match on that line.

The dependency, test-file and regex checks inspect the diff's text; the process-start check also reads Python syntax. They catch honest mistakes and obvious shortcuts, and name the line. A dependency loaded through a name built at run time, or a test that tests nothing, is still for the reviewer, which is why the prose matters too. The diff is read in a way a repo can't tamper with, since git attributes, drivers and prefixes are overridden. A worker whose profile no longer loads fails the gate instead of passing with no rules, and a pack a profile names but that doesn't exist stops the launch, so a rule never silently stops applying.

Create and lint profiles

Write the files by hand, or let brindle write the skeleton:

brindle profile new api-dev --extends developer --rules security/backend
brindle profile lint

brindle profile lint checks every visible profile for a missing parent, a cycle, an unknown pack, a pattern that doesn't compile and an unknown provider, and exits 1 on any failure. Put it in CI or a pre-commit hook to catch a typo when it's written, before a worker launches.

Share rules with a team

Commit .brindle/rules/ and .brindle/agents/ so everyone gets the same rules. With brindle Pro, when reviewers keep asking for the same change, brindle rules suggest lists candidate rules and brindle rules accept adds one to .brindle/rules/learned.md, an ordinary pack every profile in the repo picks up. Nothing changes until you accept. With brindle Team, an admin can publish and pin profiles and packs for the whole organization, so no repo can loosen them.

Where to go next

Start with one pack and one profile that matter, such as qa for test-writing tasks, and watch what the review summary reports on the first few branches. The configuration docs describe profile fields and lookup order, and the cross-model review guide shows how reviewer and checks fit together at merge. brindle demo runs a gated merge on a practice repo.