Observed in: Claude Code internal architecture
A 2-stage security classification system that determines whether tool invocations should be auto-approved or blocked. This is the core of Claude Code's "auto-approve" mode.
The YOLO classifier is Claude Code's most security-critical component. When the user enables "auto mode" (previously called "YOLO mode"), this classifier evaluates every tool invocation before it runs.
yolo-classifier-prompts/auto_mode_system_prompt.txt (bundled at build time via bun:bundle feature flag TRANSCRIPT_CLASSIFIER)permissions_external.txtUSER_TYPE=ant): permissions_anthropic.txtsettings.autoMode:allow — actions the user explicitly permitssoft_deny — actions that should be blocked (but user can override)environment — context about the user's environmentThe classifier uses a forced tool call (classify_result) for structured output:
{
"name": "classify_result",
"description": "Report the security classification result for the agent action",
"input_schema": {
"type": "object",
"properties": {
"thinking": {
"type": "string",
"description": "Brief step-by-step reasoning."
},
"shouldBlock": {
"type": "boolean",
"description": "Whether the action should be blocked (true) or allowed (false)"
},
"reason": {
"type": "string",
"description": "Brief explanation of the classification decision"
}
},
"required": ["thinking", "shouldBlock", "reason"]
}
}
buildYoloSystemPrompt(context):
1. Load BASE_PROMPT from auto_mode_system_prompt.txt
2. Replace <permissions_template> with external OR anthropic template
3. Replace <user_allow_rules_to_replace> with user's allow rules
4. Replace <user_deny_rules_to_replace> with user's deny rules
5. Replace <user_environment_to_replace> with user's environment info
The classifier also receives the user's CLAUDE.md content as a prefixed user message:
The following is the user's CLAUDE.md configuration. These are
instructions the user provided to the agent and should be treated
as part of the user's intent when evaluating actions.
<user_claude_md>
{content}
</user_claude_md>
These tools are pre-approved and skip the classifier entirely:
classify_result)The classifier receives a compact transcript of the conversation:
On Windows, additional deny rules are injected:
cache_control for prompt caching across classifier callsTRANSCRIPT_CLASSIFIER build flag