3.1 Claude Code — Permission Modes
Claude Code operates in one of six permission modes. The mode controls what actions Claude can take without asking for your confirmation:
| Mode | What Claude can do autonomously | Typical use |
|---|---|---|
| default | Read files; asks before writing or running commands | Day-to-day interactive use |
| acceptEdits | Read + write files; asks before running commands | Sessions where you're comfortable with file edits |
| plan | No file writes or commands; produces a plan only | Design sessions, review before committing |
| auto | Read, write, and run most commands | Trusted automated tasks |
| dontAsk | Everything except bypassing safety | Fully automated pipelines, CI with human oversight |
| bypassPermissions | Bypasses all permission checks | CI/CD systems with full automation; no human in loop |
bypassPermissions should only be used in locked-down CI/CD environments where the task is fully defined and no external content can modify Claude's behaviour. Never use it interactively.
Choosing a mode. The principle is least privilege: give Claude the minimum permissions it needs for the current task. Use plan mode first for unfamiliar tasks — review the plan, then switch to auto for execution.
3.2 Configuration Hierarchy
Claude Code has four configuration layers, applied in order (highest wins):
Enterprise policy (locked)
└── User global settings (~/.claude/settings.json)
└── Project settings (.claude/settings.json)
└── Local session overrides (--flag arguments)
What belongs in each layer:
- Enterprise policy: Enforced organisation-wide constraints — approved model IDs, blocked tool categories, compliance settings. Set by admin, cannot be overridden.
- User global settings: Personal preferences — default model, preferred permission mode, API key location.
- Project settings: Project-specific configuration — CLAUDE.md path, project-level MCP servers, hook configurations. Committed to the repo.
- Local session overrides: One-off flags (
--model,--permission-mode) that apply to the current terminal session only.
3.3 CLAUDE.md — Durable Project Context
CLAUDE.md is a Markdown file at the project root (or in .claude/) that provides persistent context read at every Claude Code session start. It is the authoritative source for:
- Project architecture and conventions
- Commands to run (build, test, lint)
- Code style rules Claude must follow
- Files or directories Claude should never modify
- APIs and external services in use
Structure for a CLAUDE.md:
# CLAUDE.md
## Project
E-commerce backend — Node.js + TypeScript + PostgreSQL. REST API, no GraphQL.
## Commands
- Build: npm run build
- Test: npm test (runs Vitest, must pass before any commit)
- Lint: npm run lint (ESLint + Prettier — fix lint errors, never suppress)
## Architecture
- src/routes/ — Express route handlers (thin; delegate to services)
- src/services/ — Business logic (no direct DB calls; use repositories)
- src/repositories/ — All database access (pg pool, never raw query strings)
- src/lib/ — Shared utilities
## Conventions
- All DB queries use parameterised queries — no string interpolation
- Errors bubble up as AppError instances (src/lib/errors.ts)
- Tests use integration test DB (TEST_DATABASE_URL env var)
## Do not modify
- src/lib/auth.ts — auth logic, requires security review
- migrations/ — migration files are append-only
A well-maintained CLAUDE.md removes the need to re-explain project conventions in every session. It is the most impactful single file for teams adopting Claude Code.
3.4 Rules and Instruction Files
Beyond CLAUDE.md, Claude Code supports scoped instruction files in a .claude/rules/ directory. These apply per-subdirectory or per-file-type:
.claude/
rules/
frontend.md # applies to src/components/**, src/pages/**
api.md # applies to api/**, src/routes/**
security.md # applies globally (sensitive patterns)
This lets you give Claude different instructions for different parts of the codebase — e.g., strict security review rules for the authentication module, different style conventions for the frontend vs backend.
3.5 Hooks
Hooks are shell commands or scripts that Claude Code executes at defined lifecycle points. They give you programmatic control over Claude's actions:
| Hook type | When it fires | Common use |
|---|---|---|
| PreToolUse | Before Claude executes a tool | Block dangerous commands, log actions, validate parameters |
| PostToolUse | After a tool completes | Capture output, trigger downstream processes |
| Notification | When Claude emits a notification | Send alerts to Slack/PagerDuty |
| Stop | When the session ends | Cleanup, summary reports |
Example: Block rm -rf commands via PreToolUse hook.