12.15 Security Design Principles Summary
mindmap
root((Security Design))
Defense in Depth
No single layer bypass is fatal
Each layer operates independently fail-closed
Multi-layer architecture covers the full chain
Secure by Default
default mode requires confirmation
bypassPermissions requires explicit opt-in
Sandbox off by default (opt-in)
deny and safetyCheck take priority over bypass
Extensible
Hooks enable programmatic approval
Rule system supports wildcards
Enterprises can customize security policies
policySettings has highest priority
Auditable
Every decision records its source
Telemetry events fully recorded
PermissionDenied Hook for auditing
Mistake-Proof
200ms grace period to prevent accidental triggers
dangerouslyDisableSandbox naming
Denial tracking prevents infinite loops
AI explainer assists decision-making
Progressive Evolution
tree-sitter shadow testing strategy
Observe first then switch
Telemetry-driven security decisionsLooking at the entire permission and security system, its core design philosophy can be summarized as: every layer assumes the other layers may fail. The AST parser assumes regex checks may be bypassed, so it operates independently; path constraints assume command analysis may miss things, so they check independently; user confirmation assumes all automation may fail, so it serves as the final safety net. This "pessimistic but pragmatic" design mindset is the fundamental methodology for building security-critical systems.
Hands-on Practice: In claude-code-from-scratch's
src/agent.ts, search for permission-related code to see a minimal "confirm before execution" implementation. Compare it with the defense-in-depth architecture in this chapter and consider: what are the minimum security layers a minimal Agent needs? See the tutorial Chapter 5: Permissions and Security.
Previous chapter: Task Management System | Next chapter: System Prompt Design