- Paths: which files the pull request changes
- Facts: details of the pull request itself, such as how many lines changed or who opened it
- Classifiers: the answer to a question about the change. Use one for what paths and facts can’t express
How a classifier works
A classifier has a name, a question, and the answers that it can give. Its answer reaches a rule in these steps:- Choose or define a classifier:
claude/code_reviewandclaude/diffcome with Claude Approvals. A custom classifier is a folder in your repository,.claude/classifiers/<name>/, on the default branch - Name it in a rule: write the classifier’s name in a rule’s condition in your policy file,
.claude/approvals.yml. For a custom classifier in the folderchange_risk, the name isrepo/change_risk, as in"repo/change_risk = low" - Approvals runs it on a pull request: for example, when a pull request opens ready for review and changes a file that the rule matches. See When a classifier runs. Each run that calls a model is billed to your organization’s usage credits
- The rule uses the answer: the answer helps decide who has to approve. It shows under Classifier results in Claude’s comment on the pull request, unless a
reusecondition reads it
Example classifier definition
You define a custom classifier in a file nameddef.yml. The file holds the question for the model, in prompt, and the answers that the model can pick, in outputs.
This example defines a classifier named change_risk. Its prompt asks the model to rate how risky a change is, and its outputs lets the model answer low, medium, or high:
A definition can also set
inputs, tools, and budget. See Classifier definition file keys.
Use the example’s rating in a rule
A classifier takes its name from its folder. The example is saved at.claude/classifiers/change_risk/def.yml, so you write repo/change_risk in your policy file’s rules.
To use the rating, compare it with a value in a rule’s condition. For example, if: "repo/change_risk = low" is true when the model answered low. For a rule that asks for fewer people under that condition, see Read a classifier’s answer from a rule.
Classifiers Anthropic provides
Claude Approvals comes with prebuilt classifiers,claude/code_review and claude/diff. To use one, write its name in a condition in one of your rules.
claude/code_review
claude/code_review tells a rule whether Code Review passed. For example, if: "claude/code_review = pass" is true while its answer is pass.
claude/code_review gives one of these answers:
You can read it in any condition, or list it under
advisory.
- To read the severity of its open findings: write
claude/code_review.severity, which isnone,minimal, orhigh - To let people turn
failintopass: name them in your policy’sfindingslists. They do it by closing the Important findings
claude/diff
claude/diff tells a rule how much a pull request changed since an approval or an earlier answer. It answers trivial, same_intent, or different.
Read it in a condition under reuse, which says what continues to count after a push.
Add a custom classifier
With a custom classifier, you write a question about a pull request, and a Claude model answers it. You define the classifier in a file in your repository, then name it in a rule:- Define the classifier: create a folder under
.claude/classifiers/, named in lower-case letters, digits, and_. In it, save adef.ymlthat holds the question and the answers to pick from. In a rule, you write the folderchange_riskasrepo/change_risk. - Name it under
advisory: in the root.claude/approvals.yml, pick a rule that has averdictand whosepathsmatch the files that you want judged, and list the classifier under that rule’sadvisory. Underadvisory, the classifier runs and is billed, and decides nothing. - Merge both files: open one pull request with both, and Claude comments on the pull request. If the rule that you edited is enforced, expect a warning that says “rules still hold on these files”, which doesn’t block the merge. Merge the pull request once the Policy files in this change section of that comment reports no refusal.
- Read its answers: open a pull request that changes those files, and look for the answer in Claude’s comment.
- Let a rule depend on it: once you trust the answers, read them from a rule.
When a classifier’s answer appears
After you merge a classifier’s definition and the rule that names it, wait five minutes. Then open a pull request that isn’t a draft and that changes a file that rule’spaths match. Look for the classifier’s line in one of these places:
- Claude’s comment: under Classifier results
- The Claude Approvals check’s summary: under Advisory classifiers (not counted toward this verdict)
def.yml sets a longer time limit. Under an enforced rule, the line stays as it is when the run ends.
The answer shows the next time Approvals evaluates the pull request, for example when someone approves it or requests changes. The line then reads, for example, “repo/change_risk: reported low (advisory)”.
- The line still shows no result: wait until the run’s time limit is up, then have someone approve the pull request or request changes
- Your classifier has no line: check that the rule that names the classifier has a
verdict, and that itspathsmatch the file you changed
Read a classifier’s answer from a rule
To make a rule depend on a classifier’s answer, write the classifier’s name in a condition: the rule’s ownif, or the if of an override. Once repo/change_risk answers well under advisory, move its name into an override’s if.
Keep the strict verdict on the rule itself, because the rule’s verdict applies when a run gives no answer.
This rule asks for two people, and for one while repo/change_risk answers low:
Ways to read a classifier in a condition
A condition can read a classifier in these forms:Classifier definition file keys
Write a classifier’s definition indef.yml, which can be up to 64 KiB. For a whole file, see Example classifier definition.
You can write these keys in def.yml:
If you name a model family, the classifier uses that family’s newest model, so cost and answers can change with no pull request. If you name an exact ID, the classifier stops loading when that model is retired. Your organization’s list of allowed models applies to these runs.
outputs
Give each output a type, and write names and values in lower-case letters, digits, and _. Don’t name an output severity, and don’t use true, false, error, incomplete, or complete as a value. Put quotes around "yes" and "no".
inputs
An input is a value that a rule can set for a run. Define each input under inputs in def.yml, then set it from a rule in parentheses after the classifier’s name, as in repo/change_risk(rigor=thorough). Give each input a default, and either values or min and max, as in rigor: { values: [quick, thorough], merge: right, default: quick }. Say in your prompt what each value changes.
An input’s merge says what happens when rules ask for different values on one pull request:
tools
List an entry under tools to let a run do more:
Approvals holds back some of a run’s
tools in observe mode and on some pull requests:
- In observe mode: a run keeps only
findingsandcodefrom itstools. Approvals can list the findings in its own comment, and opens no new review threads. That holds while your policy file, or every rule that names the classifier and matches a changed file, saysmode: observe. - On some pull requests: a run adds no comment, label, review thread, or GitHub review request. Examples are a pull request from a fork, and one where an author lacks write access
labels
Don’t grant labels where a label gates a merge, a deploy, or a workflow. A label that a run adds is a real label on the pull request, and anything that reads labels can act on it.
reviewers
Say in your prompt whom to add, by login. Where a rule that applies reads the classifier’s answer, the Claude Approvals check can wait for their approval, on top of seats. Name people who have write access. With a policy file in a subdirectory, list the classifier only under advisory.
To drop a reviewer who can’t approve, first merge a change to the prompt if it names that person, and allow five minutes. Then comment @claude approvals rerun on the pull request.
budget
Set time, cost, or both under budget, as in budget: { time: 300, cost: 5 }. A run that reaches either limit stops, and a condition then reads incomplete. If you ask for more than the maximum, the run gets the maximum and Approvals warns you.
Approvals stops a run when its estimated spend reaches
cost, and the bill can be higher. Under $5, a run on a large pull request can stop before it answers.
How a classifier run behaves
A rule’s result can turn on when its classifier runs, what the run can read, and what happens when it gives no answer.When a classifier runs
Arepo/ classifier runs on a pull request only if you name it in a matching rule: in an if, an override’s if, a reuse condition, or advisory. On a pull request from a fork, repo/ classifiers don’t start before a maintainer vouches for the commit. For claude/code_review, see when Approvals starts a review.
- What can start a run: a pull request opens ready for review, is marked ready, or is reopened. A push that changes the diff, a change of base branch, and a rerun of the Claude Approvals check can also start one. After your policy stops observing, Approvals evaluates some open pull requests by itself, which can start a run.
- Which definition runs: the default branch’s copy of the definition and prompt. A pull request’s own copy doesn’t run. The folder’s files are protected files.
- A changed definition ends earlier answers: an edit to
def.ymlorprompt.mdcounts once it’s on the default branch. An open pull request keeps its check until its next evaluation, such as a push or a rerun. That evaluation drops the earlier answer, and the classifier can run again. - After a push that changes the diff: an earlier answer can count where
reusekeeps it, or where the push changes only covered files whose rules don’t name the classifier - Order: with
run: sequential, the default, an override’s classifiers normally wait for the overrides above it. Withrun: parallel, they can all start at once, which can bill runs that no verdict needed.
What a classifier run can read and change
Arepo/ classifier’s run is a Claude Code cloud session on Anthropic’s infrastructure. If your organization requires self-hosted compute, a condition reads error in place of that run’s answer.
Check what the session can read and what it can change:
- What it can read: the pull request’s title, description, labels, author, changed files, diff, approvals, and required reviewers, the classifier’s earlier runs, your policy files, and the files under
.claude/classifiers/. Withfindingsintools, it reads parts of the review threads - What
codeadds: read-only copies of files at the pull request’s head and on the default branch, without some files, such asCLAUDE.md,AGENTS.md,.claude/,.mcp.json, and files whose names end in.pdf - What it can change: the session’s GitHub access is read-only. Where
toolslists an entry that writes, the run records what it asks for, and Approvals can carry it out after the run.
What a rule sees when a classifier run gives no answer
When a run ends with no answer, a condition normally reads one of these values:
In both cases, an override that needs the answer leaves the rule’s own
verdict in place. A rule’s own if that needs the answer fails the Claude Approvals check, with the title A classifier had no result.
To choose another verdict, put an override on = error or = incomplete above the overrides that read the answer. An override can’t choose another verdict for a missing answer in a rule’s own if. Move the comparison that reads the classifier from the rule’s if into an override.
What a classifier run costs
A run that calls a model is billed to your organization’s usage credits, by tokens:Limit what a custom classifier costs
You can cap one run, cap the month, pick a lower-cost model, or start fewer runs:- Cap one run: in the classifier’s
def.yml, addbudget: { cost: 5 }. Approvals stops a run when its estimated spend reaches that many US dollars, and the bill can be higher. With nobudget, the cap is $10 - Cap the month: set a spend limit for classifier runs at Organization settings > Usage, which takes an Owner role
- Pick a lower-cost model: in
def.yml, changemodel, for example fromopustosonnet - Start fewer runs: make your edits to
def.ymlandprompt.mdin one pull request. After each merged edit, the classifier runs again at each open pull request’s next evaluation
Related resources
- Claude Approvals policy file reference: conditions, overrides,
reuse, andfindings - Set up Claude Approvals: observe mode, enforcement, and spend limits
- Troubleshoot Claude Approvals: when a classifier gives no answer
- Data usage: how Anthropic handles data from Claude Code