04 · A team rule
Step 01 gave every assistant the organisation's rules. Your team has rules of its own, true for your code and nobody else's. This step writes one down in a file you own, and Redline carries it to every assistant and every review prompt.
You will learn
- Why a team rule needs its own file, and what the .redline folder is
- What a rule is made of: an id, the rule, the fix and the reason
- How to re-render the assistant files, and which reviews apply the rule
Why a team needs its own rules
Every rule so far came from the organisation. core/customer-data-in-logs applies to every repository, which is why it is in the shared standard.
Some rules are only true for one codebase. Say this repository is a library: other services import it, and they decide what gets logged and where. A console.log in here writes into somebody else's logs, maybe with their customer's data in it, and they cannot turn it off. "Never log" is right for this repository and wrong for a service, so the organisation's standard cannot say it. Your team has to.
Where would you write it down? You have three choices:
| Where you write the rule | What happens |
|---|---|
Inside the REDLINE markers in AGENTS.md | ❌ the next init rewrites that block, and the rule is gone |
Below the markers in CLAUDE.md | ⚠️ it survives, but only Claude reads it. Copilot and Cursor never see it |
.redline/local.md | ✅ Redline copies it into every assistant file on every run, and into the /redline-review prompt |
What the .redline folder is
.redline/ is a folder at the root of your repository. It does not exist yet: you create it in this step. The file that matters in it is local.md, and it is different from everything step 01 wrote:
- It is yours. Redline reads it on every run, and never writes, rewrites or deletes it. Even
redline removeleaves it in place. - It is plain markdown. No schema, no config keys. Write it the way you would explain the rule to a new teammate.
- It is reviewed like code. It is committed, so a change to a team rule goes through a pull request like any other change.
What a rule is
A rule is one line an assistant can act on and a reviewer can point at. The rule for this step, taken apart:
| Part | In the example | Why it is there |
|---|---|---|
| Id | local/no-console | Every finding quotes it, which is how you later count whether the rule catches real problems or only makes noise. The local/ prefix keeps it apart from the organisation's core/ ids. |
| Rule | No console.* calls in src/. | Specific enough that a finding can point at one line. |
| Fix | Throw an Error … and let the caller log it. | An assistant that knows the fix writes it, instead of only stopping. |
| Reason | This service is a library: the code that calls it decides… | A model applies this rule, and a model that knows why makes better calls at the edges, such as a script in scripts/ that is not shipped. |
Write it
On a new branch, create the folder and the file. Paste this into your terminal:
$ git checkout -b feat/team-rule $ mkdir -p .redline $ cat > .redline/local.md <<'EOF' ## Errors are returned, not logged This service is a library: the code that calls it decides what to log and where. - `local/no-console` — No `console.*` calls in `src/`. Throw an `Error` with a message that says what was wrong, and let the caller log it. EOF
Or create the file in your editor with the same text:
## Errors are returned, not logged
This service is a library: the code that calls it decides what to log and where.
- `local/no-console` — No `console.*` calls in `src/`. Throw an `Error` with a message that says what was wrong, and let the caller log it.
Render it
The file alone changes nothing: assistants read AGENTS.md, CLAUDE.md and the rest, not .redline/. Run init again to copy the rule into them. With a flag, it asks no questions and keeps every answer you gave in step 01:
$ pnpm redline init --no-commit Files 5 written + .github/copilot-instructions.md + AGENTS.md + CLAUDE.md + .cursor/rules/redline-core.mdc + .redline.json not committed — the files are in your working tree …
$ npx redlinegate init --no-commit Files 5 written + .github/copilot-instructions.md + AGENTS.md + CLAUDE.md + .cursor/rules/redline-core.mdc + .redline.json not committed — the files are in your working tree …
$ yarn redline init --no-commit Files 5 written + .github/copilot-instructions.md + AGENTS.md + CLAUDE.md + .cursor/rules/redline-core.mdc + .redline.json not committed — the files are in your working tree …
$ bun run redline init --no-commit Files 5 written + .github/copilot-instructions.md + AGENTS.md + CLAUDE.md + .cursor/rules/redline-core.mdc + .redline.json not committed — the files are in your working tree …
It also prints the same ▲ warnings as in step 01; nothing new. Every assistant file gains a # Repository-local rules section with your rule, and .redline.json records "localRules": true. Look at the diff before you go on:
$ git diff --stat
Add a second rule
Rules change, and someone will edit local.md and forget to re-run init. See what happens then. Add a second rule to the end of the file:
$ cat >> .redline/local.md <<'EOF' ## Exports are named Callers import from this library by name. A default export can be imported under any name, so a search for it misses callers. - `local/no-default-export` — No `export default` in `src/`. Export the function or type by name. EOF
The assistant files still carry only the first rule. pnpm redline verify notices:
$ pnpm redline verify | grep artifacts-current ok artifacts-current this repository's own .redline/local.md has changed since the last render — re-run redline init to fold it in: …
$ npx redlinegate verify | grep artifacts-current ok artifacts-current this repository's own .redline/local.md has changed since the last render — re-run redline init to fold it in: …
$ yarn redline verify | grep artifacts-current ok artifacts-current this repository's own .redline/local.md has changed since the last render — re-run redline init to fold it in: …
$ bun run redline verify | grep artifacts-current ok artifacts-current this repository's own .redline/local.md has changed since the last render — re-run redline init to fold it in: …
It says ok, not FAIL: the file is yours, so changing it is work to do, not drift. Re-render, and check again:
$ pnpm redline init --no-commit $ pnpm redline verify | grep artifacts-current ok artifacts-current rendered artifacts match standards v0.2.2
$ npx redlinegate init --no-commit $ npx redlinegate verify | grep artifacts-current ok artifacts-current rendered artifacts match standards v0.2.2
$ yarn redline init --no-commit $ yarn redline verify | grep artifacts-current ok artifacts-current rendered artifacts match standards v0.2.2
$ bun run redline init --no-commit $ bun run redline verify | grep artifacts-current ok artifacts-current rendered artifacts match standards v0.2.2
Both rules are in every assistant file now, and both go into the same pull request.
Who checks it
A team rule is written in prose, so a model applies it. The checker only runs rules a program can decide:
| Where | Sees local/no-console? |
|---|---|
| Your assistant, while writing | ✅ it reads AGENTS.md, CLAUDE.md, the Copilot instructions or the Cursor rules |
| /redline-review in your assistant | ✅ the rule is in the review prompt |
| redline review in your terminal | ❌ it runs only the checker's rules |
| The gate's Deterministic policy job | ❌ the same checker |
Try it
Break the rule on purpose. Create src/greet.ts:
export function greet(name: string): string {
console.log('greeting', name)
return 'hi ' + name
}
It is a new file, so stage it, or no review can see it:
$ git add src/greet.ts
Run /redline-review in your assistant and expect a finding tagged [local/no-console] on line 2. Run pnpm redline review in the terminal and it says nothing about it, exactly as the table says. To see the rule in the prompt the assistant receives:
$ pnpm redline review --print-prompt | grep no-console
$ npx redlinegate review --print-prompt | grep no-console
$ yarn redline review --print-prompt | grep no-console
$ bun run redline review --print-prompt | grep no-console
Throw the file away afterwards:
$ git rm -f src/greet.ts
Merge it
What is left is the rule and the files init re-rendered. Commit them and open the pull request:
$ git add -A $ git commit -m "docs: add the team's own rules" $ git push -u origin feat/team-rule $ gh pr create --title "docs: add the team's own rules" --body-file .github/pull_request_template.md $ gh pr checks --watch
Tick the checklist boxes that are true, as in step 01. When every check is green, merge, and bring main back for the next step:
$ gh pr merge --squash $ git checkout main $ git pull
Check your understanding
Your team adds a rule to .redline/local.md. A pull request breaks it. What fails?