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
- Declare
AgentDefinition(description=..., prompt=..., tools=[...], model=...)inClaudeAgentOptions(agents={...}). [agents] - Give the reviewer only read tools such as
ReadandGrep, and scope its target to named files or directories. [agents] - 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
- Python 3.10+, claude-agent-sdk, and an authenticated Claude Code CLI.
Permissions
- Review only approved source directories; review text may contain confidential source code.
Limitations
Subagent descriptions and tool lists are not an OS sandbox; the runtime must enforce actual isolation.
Pinned upstream source
- 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