src/hooks/toolPermission/ and is the single chokepoint for all potentially destructive operations.
Permission modes
- default
- plan
- bypassPermissions
- auto
Prompts the user for approval before each potentially destructive operation. This is the standard mode for interactive sessions.
How it works
checkPermissions() is called
The tool’s
checkPermissions(input, context) method is called, returning a result of the shape:Rules are checked
The permission handler checks the invocation against the configured rule set. If a matching wildcard rule grants approval, the tool proceeds immediately.
Permission rules
Rules use wildcard patterns to match specific tool invocations. They are configured in project or user settings.ToolName(argument-pattern). Wildcards (*) match any sequence of characters within the argument.
Key files
PermissionContext.ts
src/hooks/toolPermission/PermissionContext.tsHolds the active permission mode and rule set. Passed into every tool execution context.handlers/
src/hooks/toolPermission/handlers/Per-tool permission handlers that implement the approval logic for each tool category.permissionLogging.ts
src/hooks/toolPermission/permissionLogging.tsLogs all permission decisions for auditing and debugging.types/permissions.ts
src/types/permissions.tsTypeScript types for the permission rule schema, decision objects, and mode enums.Tool permission interface
Each tool implements acheckPermissions() method that the permission system calls before execution:
PermissionResult is:
Related
/memorycommand — Manage project and user memories- Architecture — How the permission system fits into the Query Engine’s tool-call loop