📚Academy
likeone
online

Testing & Safety

Permission modes, cost limits, sandboxing, and testing agents safely before they touch production

Why Agent Safety Is Different

Traditional software does exactly what you tell it. An agent does what it decides to do. That decision-making ability is the whole point — and the whole risk. An agent with Bash access could theoretically run rm -rf /. An agent with write access could overwrite critical files. An agent with API access could rack up thousands of dollars in charges.

Safety is not an afterthought. It is the foundation you build on. The SDK provides multiple layers of protection, and understanding how to use them is just as important as understanding how to build agents.

Real-world analogy: Giving an agent full access without safety measures is like handing a student driver the keys to a Formula 1 car. They might be brilliant — but start them in a parking lot with speed limits and a driving instructor (you) watching every move.

Permission Modes

The SDK offers three permission modes that control how much autonomy your agent has:

default — Ask Before Acting

The agent requests permission before running tools that modify files or execute commands. Read operations are allowed automatically. This is the safest mode for development and testing.

acceptEdits — Trust File Changes

The agent can read and write files without asking, but still requests permission for Bash commands. Good for coding agents where file edits are expected but arbitrary commands need oversight.

bypassPermissions — Full Autonomy

The agent runs all tools without asking. Only use this when you have other safety measures in place (hooks, sandboxing, cost limits) and you trust the agent's task scope.

TypeScript — permission modes
// Development: ask before modifying anything
const devAgent = new Claude({
  model: "claude-sonnet-4-6",
  tools: "defaults",
  permissionMode: "default",  // ask before writes and commands
});

// Coding: trust file edits, ask before Bash
const codingAgent = new Claude({
  model: "claude-sonnet-4-6",
  tools: "defaults",
  permissionMode: "acceptEdits",  // auto-approve file changes
});

// Production (with other guardrails): full autonomy
const prodAgent = new Claude({
  model: "claude-sonnet-4-6",
  tools: "defaults",
  permissionMode: "bypassPermissions",
  maxBudgetUsd: 1.00,  // but cap spending at $1
  maxTurns: 20,          // and limit tool loops
});
🔒

This lesson is for Pro members

Unlock all 355+ lessons across 36 courses with Academy Pro. Founding members get 90% off — forever.

Already a member? Sign in to access your lessons.

Academy
Built with soul — likeone.ai