← Blog

· 4 min read

Claude Agent SDK: Build a Read-Only Code Reviewer with Subagents

If your team already uses Claude Code, the Claude Agent SDK is the shortest path to putting the same agent inside your own product or pipeline. The interesting part is subagents: small specialists the main agent can send off on focused jobs.

The SDK was renamed from the Claude Code SDK and gives you the same tools, agent loop and context management that power Claude Code, in Python and TypeScript. Its use is governed by Anthropic's Commercial Terms (Anthropic, 2026).

1. What you get

The SDK's main features
FeatureWhat it does
Built-in toolsRead, write and edit files, run commands, search the web
PermissionsDecide which tools run automatically and which need approval
SubagentsSeparate agents for focused subtasks; only their final message comes back
HooksYour code runs when a tool is called or a session starts or stops
MCPConnects external tools and data through an open standard

2. A small demo: a read-only reviewer

Install with pip install claude-agent-sdk and set ANTHROPIC_API_KEY.

import asyncio
from claude_agent_sdk import query, ClaudeAgentOptions, AgentDefinition

async def main():
    async for message in query(
        prompt="Review the authentication module for security issues",
        options=ClaudeAgentOptions(
            allowed_tools=["Read", "Grep", "Glob", "Agent"],
            agents={"code-reviewer": AgentDefinition(
                description="Code review specialist for quality and security.",
                prompt="You are a code review specialist.",
                tools=["Read", "Grep", "Glob"], model="sonnet")})):
        if hasattr(message, "result"):
            print(message.result)
asyncio.run(main())

The reviewer can read and search, but it has no write tool, so it cannot change your code. That is the habit I would keep everywhere: give each subagent the fewest tools its job needs. Our free subagent templates follow the same rule, and the Anthropic code recipe covers plain API calls.

3. Two settings to get right on day one

Permissions. One mode, bypassPermissions, is documented as "use with extreme caution", because the agent then has full system access (Anthropic, 2026). Keep it out of anything that touches production.

Budget. A subagent can spawn subagents of its own, and spend has no limit unless you set max_budget_usd (Anthropic, 2026). Set it before the first real run, and log what each run cost.

Are you ready to ship an agent on it?

Score each 0 (no), 1 (partly) or 2 (yes):

  • Narrow tools: every subagent lists only the tools it needs.
  • Budget cap: max_budget_usd is set and monitored.
  • No bypass: nothing in production runs with bypassed permissions.
  • Hooks: risky tool calls are logged or blocked by a hook.
  • Terms read: someone has read the Commercial Terms for your use.
What your score means (my recommendation)
ScoreNext move
8–10Pilot it on one internal workflow.
5–7Fix permissions and budget first.
0–4Keep it on a developer laptop for now.

Your next step

Run the reviewer on one repository this week with a small budget cap, and compare its findings with your last human review.

Sources

  1. Anthropic (2026). Agent SDK overview. Read 20 November 2026.
  2. Anthropic (2026). Subagents in the SDK. Read 20 November 2026.
  3. Anthropic (2026). Handling permissions. Read 20 November 2026.
  4. Anthropic (2026). Migrate to Claude Agent SDK. Read 20 November 2026.

NEW CODE EVERY MONTH.

Get a note when new Claude Code templates, code recipes or tools go live.

No account required

We email once to confirm. Unsubscribe anytime — it deletes your address.

New drops, every week

Free tools & Claude templates, landing regularly.

We keep shipping new free tools, code recipes and Claude Code templates. Follow @freeyantra on Instagram or join the newsletter so you never miss one.

Follow @freeyantra

or get them by email

Double opt-in. Unsubscribe any time. Privacy