Agent Wealth HubFree public resources
中文 EN العربية

Back to catalog / Agent orchestration

Configure a least-privilege code-review subagent

Declare a focused reviewer with AgentDefinition, grant read tools only, and invoke it from the main task.

Goal

Have a code-review subagent produce verifiable findings without repository-editing tools.

Steps

  1. Declare AgentDefinition(description=..., prompt=..., tools=[...], model=...) in ClaudeAgentOptions(agents={...}). [agents]
  2. Give the reviewer only read tools such as Read and Grep, and scope its target to named files or directories. [agents]
  3. Use query(..., options=options) to ask the main agent to invoke the named subagent, then inspect AssistantMessage and ResultMessage. [agents]

How to verify

Check that review findings cite files or evidence and that AgentDefinition.tools excludes Write, Edit, and Bash.

Troubleshooting

If the subagent is not selected, check that its name matches the prompt; do not broaden tool permissions to fix routing.

Permissions

Prerequisites

Permissions

Limitations

Subagent descriptions and tool lists are not an OS sandbox; the runtime must enforce actual isolation.

Pinned upstream source

https://github.com/anthropics/claude-agent-sdk-python/blob/b6e9d12fe1cc98dde988ab7b7713c1feeee50c6c/examples/agents.py

Repository
anthropics/claude-agent-sdk-python
File path
examples/agents.py
Pinned commit
b6e9d12fe1cc98dde988ab7b7713c1feeee50c6c
Source checked
2026-10-14 · Reviewed against the pinned upstream source

Repository metrics

These values describe the upstream repository, not popularity or likes for an individual skill or playbook.

Stars
Not collected
Forks
Not collected
Observed at
Not collected

No metrics snapshot is available yet.

License: MIT

Main topic

Take a coding Agent change from context to verification

Related resources