permissions-security
# Claude Code Permissions & Security
What this skill does
# Claude Code Permissions & Security
Complete reference for the permission model and security features.
## Permission Modes
Claude Code operates in one of several permission modes:
### Default Mode (`default`)
- Prompts on first use of each tool type
- User approves/denies each tool call
- Safest mode for general use
### Accept Edits Mode (`acceptEdits`)
- Auto-approves file edits (Read, Write, Edit)
- Still asks for Bash commands and other tools
- Good balance for code-focused work
### Plan Mode (`plan`)
- Read-only analysis mode
- Claude can read but not modify anything
- Good for exploration and planning
- Invoke with `Shift+Tab` or `--permission-mode plan`
### Don't Ask Mode (`dontAsk`)
- Auto-denies unless pre-approved in allow list
- Good for locked-down environments
- Must configure allow list in settings.json
### Bypass Permissions (`bypassPermissions`)
- Skips ALL permission prompts
- Use only in trusted, sandboxed environments
- `--dangerously-skip-permissions` flag
- **Never use in production or with untrusted code**
### Switching Modes at Runtime
- `Shift+Tab` — Cycle through permission modes interactively
- `--permission-mode <mode>` — Set mode at startup
## Permission Configuration
### Allow Lists
In `settings.json` or `.claude/settings.json`:
```json
{
"permissions": {
"allow": [
"Read",
"Write",
"Edit",
"Glob",
"Grep",
"Bash(npm test)",
"Bash(npm run *)",
"Bash(npx tsc *)",
"Bash(git status)",
"Bash(git diff *)",
"Bash(git log *)",
"Bash(git add *)",
"Bash(git commit *)",
"Bash(ls *)",
"Bash(mkdir *)",
"Bash(cat *)",
"Bash(head *)",
"Bash(tail *)",
"Bash(wc *)",
"Bash(echo *)",
"Bash(pwd)",
"Bash(which *)",
"Bash(node *)",
"Bash(python3 *)",
"WebFetch",
"WebSearch",
"TodoWrite",
"NotebookEdit",
"Agent"
]
}
}
```
### Deny Lists
```json
{
"permissions": {
"deny": [
"Bash(rm -rf /)",
"Bash(sudo *)",
"Bash(curl * | bash)",
"Bash(wget * | bash)",
"Bash(chmod 777 *)",
"Bash(> /dev/sda)",
"Bash(mkfs *)",
"Bash(dd if=*)",
"Bash(:(){ :|:& };:)"
]
}
}
```
### Pattern Matching
| Pattern | Example | Matches |
|---------|---------|---------|
| Exact tool | `"Read"` | All Read calls |
| Bash prefix | `"Bash(npm test)"` | Exactly `npm test` |
| Bash glob | `"Bash(npm *)"` | Any npm command |
| MCP wildcard | `"mcp__server__*"` | All tools from server |
| MCP specific | `"mcp__fs__read_file"` | Specific MCP tool |
### Precedence
1. Deny rules checked first (if matched, blocked)
2. Allow rules checked second (if matched, auto-approved)
3. If neither matched, user is prompted
## Tool Permission Categories
### Always Safe (typically auto-allowed)
- `Read` — Read file contents
- `Glob` — Find files by pattern
- `Grep` — Search file contents
- `TodoWrite` — Manage todo list
### Requires Approval by Default
- `Write` — Create/overwrite files
- `Edit` — Modify existing files
- `Bash` — Execute shell commands
- `WebFetch` — Fetch web content
- `WebSearch` — Search the web
- `NotebookEdit` — Edit Jupyter notebooks
### Special Tools
- `Agent` — Spawn sub-agents (inherits parent permissions)
- `AskUserQuestion` — Always allowed (asks user questions)
- `Skill` — Invoke slash commands
## Security Best Practices
### 1. Principle of Least Privilege
```json
{
"permissions": {
"allow": [
"Read",
"Glob",
"Grep",
"Bash(npm test)",
"Bash(npx tsc --noEmit)"
]
}
}
```
### 2. Protect Sensitive Files
Use hooks to guard sensitive paths:
```bash
#!/bin/bash
# PreToolUse hook
INPUT=$(cat)
TOOL=$(echo "$INPUT" | jq -r '.tool_name')
PATH_ARG=$(echo "$INPUT" | jq -r '.tool_input.file_path // .tool_input.path // ""')
# Block access to secrets
if echo "$PATH_ARG" | grep -qE '\.(env|pem|key|secret)$'; then
echo '{"decision": "deny", "reason": "Access to secret files is blocked"}'
exit 0
fi
echo '{"decision": "approve"}'
```
### 3. Sandbox Bash Commands
```json
{
"permissions": {
"allow": [
"Bash(npm *)",
"Bash(npx *)",
"Bash(git *)",
"Bash(ls *)",
"Bash(cat *)"
],
"deny": [
"Bash(rm *)",
"Bash(sudo *)",
"Bash(curl *)",
"Bash(wget *)"
]
}
}
```
### 4. MCP Server Permissions
```json
{
"permissions": {
"allow": [
"mcp__filesystem__read_file",
"mcp__filesystem__list_directory"
],
"deny": [
"mcp__filesystem__write_file",
"mcp__filesystem__delete_file"
]
}
}
```
### 5. Enterprise Controls
- Organization-level settings cannot be overridden
- API key management via managed auth
- Audit logging via hooks
- Network restrictions via proxy settings
## Session Permission Prompts
During a session, when Claude requests a tool:
- **Allow Once** — Approve this specific call
- **Allow Always** — Add to session allow list (until restart)
- **Deny** — Block this specific call
- **Deny Always** — Add to session deny list
Session permissions reset when Claude Code restarts. For persistent permissions, add them to `settings.json`.
## Managed Settings (Enterprise)
Enterprise admins can push managed settings that users cannot override:
```json
{
"managedSettings": {
"permissions": {
"deny": [
"Bash(curl *)",
"Bash(wget *)",
"WebFetch",
"WebSearch"
]
},
"model": "claude-sonnet-4-6",
"hooks": {
"PostToolUse": [
{
"matcher": "*",
"hooks": [
{
"type": "command",
"command": "bash /opt/audit/log-tool-use.sh"
}
]
}
]
}
}
}
```
## Security Audit Checklist
- [ ] No API keys in `.mcp.json` (use env vars)
- [ ] `.env` files in `.gitignore`
- [ ] Deny list covers destructive commands
- [ ] PreToolUse hooks guard sensitive files
- [ ] PostToolUse hooks log activity
- [ ] MCP servers are from trusted sources
- [ ] Permission mode appropriate for environment
- [ ] Enterprise managed settings in place (if applicable)
Related in AI Agents
skill-development
IncludedComprehensive meta-skill for creating, managing, validating, auditing, and distributing Claude Code skills and slash commands (unified in v2.1.3+). Provides skill templates, creation workflows, validation patterns, audit checklists, naming conventions, YAML frontmatter guidance, progressive disclosure examples, and best practices lookup. Use when creating new skills, validating existing skills, auditing skill quality, understanding skill architecture, needing skill templates, learning about YAML frontmatter requirements, progressive disclosure patterns, tool restrictions (allowed-tools), skill composition, skill naming conventions, troubleshooting skill activation issues, creating custom slash commands, configuring command frontmatter, using command arguments ($ARGUMENTS, $1, $2), bash execution in commands, file references in commands, command namespacing, plugin commands, MCP slash commands, Skill tool configuration, or deciding between skills vs slash commands. Delegates to docs-management skill for official documentation.
reprompter
IncludedTransform messy prompts into well-structured, effective prompts — single or multi-agent. Use when: "reprompt", "reprompt this", "clean up this prompt", "structure my prompt", rough text needing XML tags and best practices, "reprompter teams", "repromptception", "run with quality", "smart run", "smart agents", multi-agent tasks, audits, parallel work, anything going to agent teams. Don't use when: simple Q&A, pure chat, immediate execution-only tasks. See "Don't Use When" section for details. Outputs: Structured XML/Markdown prompt, quality score (before/after), optional team brief + per-agent sub-prompts, agent team output files. Success criteria: Single mode quality score ≥ 7/10; Repromptception per-agent prompt quality score 8+/10; all required sections present, actionable and specific.
adaptive-compaction
IncludedAdaptive add-on policy and recovery layer that decides WHEN to compact, prune, snapshot, or fork -- replacing fixed-percent auto-compaction across Claude Code, Codex, and MCP-capable hosts. Trigger on auto-compact timing or damage: "when should I compact", "is it safe to compact now or start a fresh session", "auto-compact fires too early/mid-task", "switching to an unrelated task but the window still has space", "context rot", "answers get worse the longer the session runs", "the agent forgot the plan or my decisions after it summarized", "add a layer on top that manages context without changing the agent", raising autoCompactWindow to give the policy room, or installing/tuning a cross-tool compaction policy or PreCompact hook -- even when "compaction" is never said but the problem is context-window pressure or post-summarization memory loss. Do NOT use to summarize a conversation, build RAG, write a summarization prompt (decides WHEN not HOW), or answer max-context-length trivia.
agent-skill-creator
IncludedCreate cross-platform agent skills from workflow descriptions. Activates when users ask to create an agent, automate a repetitive workflow, create a custom skill, or need advanced agent creation. Triggers on phrases like create agent for, automate workflow, create skill for, every day I have to, daily I need to, turn process into agent, need to automate, create a cross-platform skill, validate this skill, export this skill, migrate this skill. Supports single skills, multi-agent suites, transcript processing, template-based creation, interactive configuration, cross-platform export, and spec validation.
llm-wiki
IncludedUse when building or maintaining a persistent personal knowledge base (second brain) in Obsidian where an LLM incrementally ingests sources, updates entity/concept pages, maintains cross-references, and keeps a synthesis current. Triggers include "second brain", "Obsidian wiki", "personal knowledge management", "ingest this paper/article/book", "build a research wiki", "compound knowledge", "Memex", or whenever the user wants knowledge to accumulate across sessions instead of being re-derived by RAG on every query.
skill-master
IncludedAgent Skills authoring, evaluation, and optimization. Create, edit, validate, benchmark, and improve skills following the agentskills.io specification. Use when designing SKILL.md files, structuring skill folders (references, scripts, assets), ingesting external documentation into skills, running trigger evals, benchmarking skill quality, optimizing descriptions, or performing blind A/B comparisons. Keywords: agentskills.io, SKILL.md, skill authoring, eval, benchmark, trigger optimization.