02 · Your first finding
Write the kind of code an assistant produces when it is told to make a type error go away. It compiles, the tests pass, and Redline names five problems in it: four a checker can prove, and one only a reviewer would notice.
You will learn
- How to review a change on your machine before you push
- How to read a finding: severity, rule id, problem
- How to run the same review inside Claude Code, Copilot or Cursor
- What the gate does with a broken rule at observe
Write some plausible code
The directory from step 00 holds users; now they have to arrive from somewhere, as JSON. Start a branch:
$ git checkout -b feat/load-user
Open src/users.ts and keep everything in it. Below the closing } of UserDirectory, leave one blank line, then add this. The blank line keeps your line numbers the same as the ones on this page:
// TODO: handle retries
export function loadUser(raw: string) {
// @ts-ignore
return JSON.parse(raw) as unknown as User
}
export type Payload = unknown
export function requireUser(directory: UserDirectory, id: string, requester: User): User {
const user = directory.find(id)
if (!user) throw new Error(`${requester.email} asked for user ${id}, which does not exist`)
return user
}
Look at it for a moment before reading on. Would you have caught all of it in a review on a busy afternoon? It compiles, because @ts-ignore tells the compiler to look away and as unknown as User tells it to trust whatever comes back. pnpm test still passes.
Review it
Redline reviews your diff against main. Git only diffs files it tracks. src/users.ts already is, so staging it is optional here, but it is the habit that saves you on a new file:
$ git add src/users.ts $ pnpm redline review profile javascript-typescript — rules in scope: core, typescript src/users.ts:20 Redline/HIGH [core/untracked-todo]: this TODO carries no ticket reference, so nothing will bring anyone back to it. src/users.ts:22 Redline/BLOCKER [core/type-checker-suppression]: a type-checker suppression needs an inline explanation AND a ticket reference on the same line. src/users.ts:23 Redline/BLOCKER [core/unsafe-assertion]: a double assertion overrides the type checker with no stated reason. src/users.ts:26 Redline/HIGH [typescript/unknown-type-alias]: this alias names `unknown`, so it reads as a contract it is not. 4 finding(s)
$ git add src/users.ts $ npx redlinegate review profile javascript-typescript — rules in scope: core, typescript src/users.ts:20 Redline/HIGH [core/untracked-todo]: this TODO carries no ticket reference, so nothing will bring anyone back to it. src/users.ts:22 Redline/BLOCKER [core/type-checker-suppression]: a type-checker suppression needs an inline explanation AND a ticket reference on the same line. src/users.ts:23 Redline/BLOCKER [core/unsafe-assertion]: a double assertion overrides the type checker with no stated reason. src/users.ts:26 Redline/HIGH [typescript/unknown-type-alias]: this alias names `unknown`, so it reads as a contract it is not. 4 finding(s)
$ git add src/users.ts $ yarn redline review profile javascript-typescript — rules in scope: core, typescript src/users.ts:20 Redline/HIGH [core/untracked-todo]: this TODO carries no ticket reference, so nothing will bring anyone back to it. src/users.ts:22 Redline/BLOCKER [core/type-checker-suppression]: a type-checker suppression needs an inline explanation AND a ticket reference on the same line. src/users.ts:23 Redline/BLOCKER [core/unsafe-assertion]: a double assertion overrides the type checker with no stated reason. src/users.ts:26 Redline/HIGH [typescript/unknown-type-alias]: this alias names `unknown`, so it reads as a contract it is not. 4 finding(s)
$ git add src/users.ts $ bun run redline review profile javascript-typescript — rules in scope: core, typescript src/users.ts:20 Redline/HIGH [core/untracked-todo]: this TODO carries no ticket reference, so nothing will bring anyone back to it. src/users.ts:22 Redline/BLOCKER [core/type-checker-suppression]: a type-checker suppression needs an inline explanation AND a ticket reference on the same line. src/users.ts:23 Redline/BLOCKER [core/unsafe-assertion]: a double assertion overrides the type checker with no stated reason. src/users.ts:26 Redline/HIGH [typescript/unknown-type-alias]: this alias names `unknown`, so it reads as a contract it is not. 4 finding(s)
The messages are shortened here; your terminal prints each in full, with the fix. No model was called: these four rules are decided by a checker, so the result is the same every time. A new file you forgot to git add is not in the diff at all; if nothing else changed, the review stops with there is nothing to review — the diff is empty.
Four, not five, and that is the point. Line 30 is missing, and it is the worst line in the file. The terminal runs only the rules a checker can decide, and no checker can tell that requester.email is a customer's email address. Finding it takes a model: run /redline-review in your assistant, in the next tab. With no assistant, review --engine api calls a model from the terminal, given an API key.
Onboarding added a /redline-review command to every assistant. In Claude Code, Copilot Chat (agent mode) or Cursor, in this repository, type:
> /redline-review
The assistant collects the rules that apply to the files you changed, the diff and the checker's findings into one prompt, and reviews against it. The reply uses the same Redline/SEVERITY [rule-id]: problem shape, ending with a count such as 3 BLOCKER · 2 HIGH · 0 SUGGESTION.
A model also applies the rules a checker cannot decide, so expect a fifth finding:
Redline/BLOCKER [core/customer-data-in-logs]: line 30 puts the requester's email address into an error message, which ends up in logs and error trackers.
Nothing in the code says requester.email is personal data. It is a string, like any other. Knowing that it belongs to a customer, and that error messages are read by people who should not see it, takes judgement. The model may word it differently from run to run, or find more; the rule ids do not change.
Reviewing is half of it. The assistant reads the rules on every request, so they shape new code before anything is reviewed. Try it:
> Write a function in src/account.ts that parses an Account { id: string; email: string } from a JSON string.
An assistant that has read the rules usually validates the parsed value with a type guard or a schema instead of writing as unknown as Account. It depends on the model, so treat it as something to look for, not a guarantee. That is why the review exists.
A browser chat works too. This copies the whole review prompt to the clipboard on macOS; on Linux pipe to xclip -selection clipboard, on Windows to clip. Then paste it into the chat.
$ pnpm redline review --print-prompt | pbcopy
$ npx redlinegate review --print-prompt | pbcopy
$ yarn redline review --print-prompt | pbcopy
$ bun run redline review --print-prompt | pbcopy
Wouldn't ESLint catch this?
Four of the five, yes, with the right configuration, and you should run it. None of these rules is on in a default setup:
| Line | Redline | ESLint |
|---|---|---|
| 20 | core/untracked-todo | no-warning-comments flags every TODO, with a ticket or without |
| 22 | core/type-checker-suppression | @typescript-eslint/ban-ts-comment, configured to require a description |
| 23 | core/unsafe-assertion | @typescript-eslint/no-unsafe-type-assertion, not in the recommended set |
| 26 | typescript/unknown-type-alias | No rule; a custom no-restricted-syntax selector |
| 30 | core/customer-data-in-logs | Nothing. A linter sees a string, not a customer's email address. |
Line 30 is the kind of rule most of the standard is made of: missing auth checks, races, personal data where it should not be. They need a reviewer, so Redline gives every assistant the same reviewer's brief. And the rules reach the assistant before it writes, in AGENTS.md and its siblings, where a linter only reports after the code exists.
Reading a finding
Every finding has the same three parts, in the same order:
Redline/BLOCKER [core/unsafe-assertion]: a double assertion overrides the type checker with no stated reason.
- Severity.
BLOCKERmust not merge.HIGHis a deliberate trade-off a reviewer acknowledges.SUGGESTIONis optional. - Rule id, in brackets. It is stable, it is what you look up in the next step, and it is how the organisation counts which rules earn their place.
- The problem, and how to fix it, in a sentence or two.
New term Deterministic rule
A rule a program can decide on its own, with no model: a @ts-ignore is either there or it isn't. Most of the standard needs judgement and is applied by a model. The deterministic share runs in your terminal and in the gate, and always gives the same answer. More in Deterministic rules.
Push it anyway
On GitHub, open a pull request with the findings still in it, to see what the pipeline does:
$ git add src/users.ts $ git commit -m "feat: load a user from JSON" $ git push -u origin feat/load-user $ gh pr create --title "feat: load a user from JSON" --body-file .github/pull_request_template.md
On GitHub, fill in the ## Launch readiness checklist honestly. One item is false: Input validated at boundaries touched by this change, because this code skips validation. Leave that box unticked. Step 03 makes it true, and you tick it then.
$ gh pr checks ✓ test compiles, tests pass X redline-gate / Deterministic policy the same four findings X redline-gate / PR checklist one box, honestly unticked ✓ redline-gate / ADR required for significant changes ✓ redline-gate / Dependency review ✓ redline-gate / Secret scan (diff) ✓ redline-gate / gate passes, with a warning
Open redline-gate / gate: its log says why it passed with two red jobs. checklist and policy are the ids of the PR checklist and Deterministic policy jobs:
# from the log of redline-gate / gate Warning: Process checks failed: checklist policy. This repository is at rung 'observe', which reports and does not block. The findings are recorded either way.
That is observe doing its job: the findings are visible on the pull request and recorded, and nothing is blocked yet.
Notice what the gate did not see: line 30. The Deterministic policy job runs the same checker as your terminal, and the gate calls no model, so the email address in the error goes unremarked. In a pull request, that rule is applied by the review in your assistant before you push, and by a human reviewer. Step 07 adds a GitHub ruleset that also asks Copilot to review every pull request, when your plan includes it.
A local review always exits 0 and is never recorded. It is a mirror, not a gate: nothing on your machine can block you.
Leave this pull request open. Step 03 fixes the code on this branch and merges it.
Check your understanding
The Deterministic policy job failed, but the gate passed. Why?