Claude Agent SDK Best Practices
Practical rules for taking a Claude Agent SDK agent from a working prototype to something safe to run in production, covering tool scoping, checkpoints, subagents, and sessions.
Search across all documentation pages
Practical rules for taking a Claude Agent SDK agent from a working prototype to something safe to run in production, covering tool scoping, checkpoints, subagents, and sessions.
bash, web_search, or web_fetch; every enabled tool is additional surface area the loop can act on unsupervised.bash to an explicit command allowlist rather than granting an open shell. Unrestricted bash access turns one tool into an arbitrary-code-execution capability; a command allowlist keeps it to the specific operations the task requires.file_edit to the paths a task should actually touch. Path or glob restrictions keep a monorepo-wide agent from editing files outside the package or directory it was asked to work on.web_fetch over web_search when the URL is already known. web_search is a broader, less predictable capability; reserve it for genuinely open-ended research tasks.resume to replay side effects. Resuming restores the record of what already happened; it does not re-run bash commands or re-fetch URLs from the prior session.Tool scoping (Group A), since it determines what the agent is capable of at all; checkpoints, subagents, and sessions all build on top of a well-scoped tool set.
If nothing reachable is destructive or irreversible, checkpoints add less value; but most agents that write files, run commands, or call external systems have at least one action worth gating.
Yes, for genuinely single-shot, stateless tasks where there's nothing meaningful to resume. Persistence matters once a task spans more than one process lifetime.
Assuming local development safety nets (a human watching the terminal, catching a bad checkpoint prompt) carry over automatically to a hosted deployment, when they need to be rebuilt explicitly.
Only if that subagent's own tool scope includes something destructive or irreversible; checkpoint configuration is set per AgentOptions, so it can differ between parent and subagent as needed.
Whenever the underlying task or prompt changes meaningfully, and periodically as a matter of routine, since scope that was correct at launch can drift out of sync with what the agent actually does over time.
Most of it still applies, tool scoping and thoughtful subagent use in particular, even if checkpoint routing and hosted-specific concerns are simpler for a local, single-operator run.
An overly restrictive allowlist can cause the agent to fail mid-task on a legitimate action it needs, forcing you to loosen scope reactively; test the exact operations a task requires before locking down an allowlist.
Stack versions: Written against the Claude model lineup current as of ~June 2026 - Claude Fable 5, Claude Opus 4.8, Claude Sonnet 5 (the default), and Claude Haiku 4.5 - and the Claude Agent SDK (latest release, Python and TypeScript). Model names, SDK versions, and pricing move quickly - verify current specifics at platform.claude.com/docs before relying on them.
Reviewed by Chris St. John·Last updated Jul 16, 2026