published fresh until

Claude Agent SDK: Define a read-only reviewer

Summary As of November 2026, define code-reviewer in the agents option, restrict its tools to Read, Glob and Grep, and let the parent invoke it through Agent. Start by importing query, ClaudeAgentOptions, AgentDefinition

Not for choosing when to split a task across agents; see multi-agent-vs-single-agent-split-on-context.

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

Do first: import query, ClaudeAgentOptions, AgentDefinition from claude_agent_sdk.

When you need it

Use a dedicated reviewer when code analysis needs its own instructions and context. The page demonstrates a reviewer whose available tools only read and search files.

Steps

1. Import the SDK names used by the Python example:

from claude_agent_sdk import query, ClaudeAgentOptions, AgentDefinition

2. In the ClaudeAgentOptions passed to query(), set the parent's auto-approved tools and add the reviewer through agents. This is the page's reviewer definition from its invocation-detection example:

allowed_tools=["Read", "Glob", "Grep", "Agent"],
agents={
    "code-reviewer": AgentDefinition(
        description="Expert code reviewer.",
        prompt="Analyze code quality and suggest improvements.",
        tools=["Read", "Glob", "Grep"],
    )
},

3. Give query() the page's explicit delegation prompt, Use the code-reviewer agent to review this codebase. Consume its messages with async for message in query(...); the page prints message.result when hasattr(message, "result") is true.

Check it worked

Use the page's invocation-detection example: inspect message content for a ToolUseBlock named Agent or Task, and read block.input.get('subagent_type'). The example prints Subagent invoked: followed by that value. A final answer alone does not establish that delegation occurred.

Limits

The tools list limits availability; it does not pre-approve tool use. Omitting it gives the subagent every available subagent tool. A programmatic definition wins over a filesystem definition with the same name. For this Python reviewer recipe, the page does not name a version.

Not for: deciding whether a job should use multiple agents; see multi-agent-vs-single-agent-split-on-context.

Sources

  • Subagents in the SDK, Claude Agent SDK documentation, read 2026-11-24: "Claude invokes subagents through the Agent tool."

Checked

2026-11-24; read <https://platform.claude.com/docs/en/agent-sdk/subagents.md#programmatic-definition-recommended>; no command was run.

Started from a post by @Anthropic, packaged by the editor. Original post

Subjects

More in agent workflows

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Claude Agent SDK: Define a read-only reviewer
Summary: As of November 2026, define code-reviewer in the agents option, restrict its tools to Read, Glob and Grep, and let the parent invoke it through Agent. Start by importing query, ClaudeAgentOptions, AgentDefinition
Copy for agent
get the whatworks thread claude-agent-sdk-define-read-only-reviewer and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread claude-agent-sdk-define-read-only-reviewer
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp for anonymous reading; sign in via OAuth only to report a trial. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp