Skip to main content

Permissions, Hooks & Safety — Claude Code CLI

[ ABORT TO HUD ]
SEQ. 1
SEQ. 2
SEQ. 3

Permissions, Hooks & Safety

💻 Claude Code CLI⏱ 20 min⭐ 950 BASE XP⌨ HANDS-ON LAB

Tiered Permission Model & .claude/settings.json

Claude Code replaces legacy CLI config flags with hierarchical JSON files: ~/.claude/settings.json (user global), .claude/settings.json (team Git-committed), and .claude/settings.local.json (git-ignored overrides). Rules follow strict Deny > Ask > Allow precedence:

TierAction TypesDefault Behavior
Read-OnlyFile reads, directory listings, grep searchesAuto-approved (unless matched by deny)
File EditModifying existing files, creating new filesPrompts for confirmation unless in allow
Bash / ExecutionRunning shell commands, test suites, buildsPrompts user for explicit authorization
Destructive / DeniedRead(.env*), rm -rf, force pushBlocked outright by deny or strict confirmation

Deterministic Lifecycle Hooks

Unlike advisory CLAUDE.md instructions, Hooks (PreToolUse, PostToolUse, SessionStart, UserPromptSubmit) in .claude/settings.json execute deterministic shell commands at runtime—exiting with code 2 blocks a tool call before execution.

Slash Commands in Claude Code

  • /help: Display available commands and shortcuts.
  • /compact: Compact conversation context to preserve token capacity.
  • /clear: Reset conversation state and clear memory buffer.
  • /settings: Interactively view and modify permissions, model, and CLI settings.
  • /cost: View token usage and cost for the current session.
  • /doctor: Verify environment health, API connectivity, and permissions.
  • /review: Perform a code review on git diffs before committing.
⌨ HANDS-ON LABConfigure .claude/settings.json Permissions & Hooks
⭐ +150 XP

Legacy 'claude config' commands were replaced by hierarchical .claude/settings.json files. Inspect your project settings and define explicit permission and PreToolUse hook rules.

1Inspect your project's .claude/settings.json configuration file.
2Write a PreToolUse lifecycle hook and strict .env deny rule into .claude/settings.json.
lab-sandbox — simulated environment
INFINITY LAB SANDBOX v2.6 — simulated shell
Type the command for the current objective. Helpers: "hint", "solution", "clear".
$
OBJECTIVE 1 / 2 — type "hint" if stuck
SYNAPSE VERIFICATION
QUERY 1 // 2
Which slash command in Claude Code compacts conversation context to save tokens?
/shrink
/compact
/compress
/trim