/claude-code-superpowers:permission-systemfrom claude-code-superpowers
Teaches Claude Code's multi-layered permission system: permission modes (default/bypass/auto), checkPermissions method on tool definitions, per-tool rules, and Zod validation gates. Use when adding tools with side effects, writing permission rules, or debugging denied tool calls.
Ships in claude-code-superpowers. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Every tool call in Claude Code passes through a permission gate before execution. The gate is a checkPermissions(input, context) method defined on the tool itself. The framework calls this method before invoking call() — the tool never calls it manually. If the result has behavior: 'deny', the framework sends a tool_result with is_error: true back to the LLM and never invokes call() at all. This makes the permission boundary declarative: a tool that omits checkPermissions gets the default implementation, which returns { behavior: 'allow' } unconditionally.
Three permission modes control how the gate behaves: 'default' prompts the user for sensitive operations, 'bypass' grants everything silently, and 'auto' approves operations matching pre-approved rules.
Claude Code executes arbitrary shell commands, reads and writes files, and can make network requests. Running in a developer's local environment means a mistake has real consequences — files can be deleted, credentials can be exfiltrated, production systems can be modified. The permission system is a defense-in-depth layer: even if the LLM produces a malicious or incorrect tool call, the user is prompted before the side effect happens.
The system is per-input, not per-tool. checkPermissions receives the full parsed input, so a bash tool can be auto-approved for git status (read-only) while still prompting for rm -rf (destructive). Rules match tool names, command patterns, and file path globs, making the policy composable and auditable.
checkPermissions(input, context) as a method on your tool definition — the framework calls it before call(), so no manual invocation is needed inside call().checkPermissions, read context.getAppState().toolPermissionContext and pass it to the appropriate utility (e.g., checkReadPermissionForTool, checkBashPermissionForTool) from src/utils/permissions/.isDestructive?(input) if the tool performs irreversible mutations. This signals to the permission UI that extra confirmation is appropriate.~/.claude/settings.json under permissions.allow. Rules use glob-like matchers: Bash(git *) approves all git bash commands; FileRead(src/*) approves file reads in src/.toolPermissionContext in AppState carries the current rules — read it via context.getAppState().toolPermissionContext.// Source: src/Tool.ts (checkPermissions in ToolDef)
// checkPermissions is optional — buildTool provides a default that returns { behavior: 'allow' }
checkPermissions(
input: z.infer<Input>,
context: ToolUseContext,
): Promise<PermissionResult>
// PermissionResult behaviors:
// { behavior: 'allow'; ... } — proceed immediately
// { behavior: 'deny'; message: string; ... } — framework rejects, call() is never invoked
// { behavior: 'ask'; ... } — framework prompts user before proceeding
// { behavior: 'passthrough'; message: string; ... } — delegate to next layer
// Source: src/tools/FileReadTool/FileReadTool.ts (checkPermissions implementation)
async checkPermissions(input, context): Promise<PermissionDecision> {
const appState = context.getAppState()
return checkReadPermissionForTool(
FileReadTool,
input,
appState.toolPermissionContext,
)
},
// call() — framework has already run checkPermissions; no manual permission call needed
async call({ file_path, offset, limit }, context, _canUseTool?) {
const content = await readFile(file_path)
return { data: content }
},
// Source: src/utils/permissions/ (rule matching)
// Permission rules in settings.json:
// {
// "permissions": {
// "allow": ["Bash(git *)", "FileRead(**/*.ts)"],
// "deny": ["Bash(rm *)"]
// }
// }
The key non-obvious detail: Zod schema validation happens BEFORE checkPermissions is called. The framework validates the input first; checkPermissions is only invoked with valid, parsed arguments. This means permission rules can safely inspect typed fields (e.g., input.command) without needing to handle malformed input.
Before — tool with no checkPermissions method (executes without any permission check):
{
// No checkPermissions — buildTool default returns { behavior: 'allow' } unconditionally
async call({ file_path }, context, _canUseTool?) {
// Directly executes without asking the user — dangerous for destructive ops
await fs.unlink(file_path)
return { type: 'success', data: `Deleted ${file_path}` }
},
isDestructive: (_input) => true,
isReadOnly: (_input) => false,
}
After — same tool with checkPermissions delegating to the appropriate utility:
{
// checkPermissions is called by the framework before call() — never call it manually
async checkPermissions(input, context): Promise<PermissionDecision> {
const appState = context.getAppState()
return checkWritePermissionForTool(
DeleteFileTool,
input,
appState.toolPermissionContext,
)
},
async call({ file_path }, context, _canUseTool?) {
// Framework already ran checkPermissions — safe to execute here
try {
await fs.unlink(file_path)
return { type: 'success', data: `Deleted ${file_path}` }
} catch (err) {
return { type: 'error', error: formatFileError(err, file_path) }
}
},
isDestructive: (_input) => true,
isReadOnly: (_input) => false,
isConcurrencySafe: (_input) => false, // File deletion is not concurrent-safe
}
checkPermissions methodbuildTool for genuinely destructive operationsisDestructive is not implemented for tools that delete, overwrite, or execute system commands'default' permission modeisDestructive — isReadOnly: true is sufficient signal'bypass' (CI/headless), checkPermissions always returns allow — don't add extra guards on topcall() — use checkPermissions; custom checks create policy inconsistenciestool-definition — where checkPermissions fits in the Tool interfacedomain-model — how toolPermissionContext lives in AppStateerror-handling — what to return when permission is deniedWhat SKILL.md sets; muted values are Claude Code's defaults
16 skills in this plugin
/async-concurrencyTeaches Claude Code's concurrency model: isConcurrencySafe() for parallel tool execution, AbortController propagation for cancellation, Promise.all() for parallel initialization, and the StreamingToolExecutor for concurrent progress streams. Use this when writing tools that could benefit from parallel execution, need to respect cancellation, or must stream partial results. Read-only tools that don't declare concurrency safety are needlessly serialized.
/build-tool-factoryTeaches how to create a new Claude Code tool using the buildTool() factory from src/Tool.ts.
Use this whenever adding a new capability to Claude Code — buildTool is the only correct entry
point. It fills in safe defaults for isConcurrencySafe, isReadOnly, isDestructive,
checkPermissions, and userFacingName so you only implement what your tool actually needs.
/creating-skillsGenerated from the plugin's indexed repository (techymt/claude-code-superpowers) — no native marketplace selected
npx claudepluginhub p/techymt-claude-code-superpowersOther plugins' skills for the same job