Skip to content
Sign Up Free
Claude Code

How to configure permissions and hooks in Claude Code

Use /permissions and settings.json to configure allow, ask, and deny rules, then add, verify, and troubleshoot Claude Code hooks. Includes setup guidance.

Direct answer

Run /permissions in Claude Code to view and manage permission rules. To persist them, put allow, ask, and deny in settings.json. Hooks use the same settings files and run formatting, tests, or safety checks around tool calls. Permission precedence is deny → ask → allow, so an allow rule cannot override a deny rule.

These settings control local tools on your computer. BetterToken changes the model API Base URL, API Key, and routing only; it does not bypass local permissions or run hooks for you.

Choose permissions or hooks

RequirementUse
Run a specific command without promptingpermissions.allow
Ask every time before an operationpermissions.ask
Block sensitive file reads or dangerous commandspermissions.deny
Format or test after a file changePostToolUse hook
Check or block an action before it runsPreToolUse hook
Explain team conventions to the modelCLAUDE.md, not a permission rule

Choose the correct scope

FileScopeCommit to the repository?
~/.claude/settings.jsonAll projects for the current userNo
.claude/settings.jsonCurrent project and teamYes
.claude/settings.local.jsonCurrent project on this machineNo

Configure minimal permission rules

Inspect existing rules with /permissions

In Claude Code, run:

/permissions

The UI shows allow, ask, and deny rules with their source files. Check for existing team or managed rules before choosing a user or project setting.

Add narrow rules

This project-level example allows common tests and lint, asks before every git push, and blocks .env reads:

{
"permissions": {
"allow": [
"Bash(npm run lint *)",
"Bash(npm test *)"
],
"ask": [
"Bash(git push *)"
],
"deny": [
"Read(./.env)",
"Read(./.env.*)"
]
}
}

Replace the commands with scripts that exist in your project. Do not enable bypassPermissions only to remove prompts; the official documentation limits that mode to isolated containers or VMs.

Verify in /permissions

Save the file and run /permissions again. Confirm each rule appears under the expected source, then trigger one allow, ask, and deny case to verify the behavior.

Add a copyable formatting hook

This example runs the project formatter after Claude Code uses Edit or Write:

{
"hooks": {
"PostToolUse": [
{
"matcher": "Edit|Write",
"hooks": [
{
"type": "command",
"command": "npm run format"
}
]
}
]
}
}

If the file already has permissions, merge hooks into the same top-level JSON object. Do not create a standalone .claude/hooks.json. Run npm run format manually first to confirm it succeeds.

Verify the hook

  1. Run /hooks in Claude Code.
  2. Open PostToolUse and confirm it lists Edit|Write and npm run format.
  3. Ask Claude to modify a test file.
  4. Check the hook output and file format, and confirm the hook ran once without errors.

Claude Code normally reloads settings changes automatically. If it does not, exit the session and restart Claude Code.

Common errors

SymptomCauseFix
Permission rules never applyThey are in ~/.claude.json or the wrong directoryMove them to ~/.claude/settings.json, .claude/settings.json, or .claude/settings.local.json
An allowed action is still blockedIt matches a deny or managed ruleCheck sources in /permissions; deny takes precedence over ask and allow
A hook never runsEvent or matcher does not match the toolInspect /hooks; PreToolUse runs before execution, PostToolUse after success, and matchers are case-sensitive
The hook runs but the command failsWrong script, working directory, or dependencyRun the same command manually from the project directory first
Prompts remain after connecting BetterTokenAPI provider and local permissions are separateKeep the BetterToken Base URL and configure narrow Claude Code permissions separately
You need to disable all hooks temporarilyA hook may interfere with debuggingAdd "disableAllHooks": true, then remove it or set it to false after debugging

BetterToken boundaries

BetterToken handles Claude Code model API access, model routing, balance, and usage. Claude Code still controls:

  • File read and write access
  • Bash confirmation behavior
  • When hooks run and which scripts they execute
  • Sandbox, MCP, and project rules

For 401, Base URL, or model mapping errors, see the Claude Code setup guide. For command prompts and automation, troubleshoot permissions and hooks here.

References