Claude Code
Claude Code is Anthropic's agentic coding tool. It runs in your terminal (and VS Code, JetBrains, the desktop app, web, Slack), reads the codebase, edits files, runs commands, runs tests, and creates git commits and PRs.
16.1 Install and start
# macOS / Linux / WSL (native installer)
curl -fsSL https://claude.ai/install.sh | bash
# Windows PowerShell
irm https://claude.ai/install.ps1 | iex
# or via npm
npm install -g @anthropic-ai/claude-code
cd my-project
claude # interactive session
claude "fix this bug" # start with a prompt
claude -p "give a summary" --output-format json # headless / scripting
claude -c # continue the last conversation
claude -r # resume an old session (picker)16.2 How it works
- 1.Gather context: read files, grep, git
- 2.Plan: decide the approach in plan mode
- 3.Act: edit files, bash commands
- 4.Verify: tests, build, lint
- 5.Repeat / report: until the work is done
Every tool call goes through the permission system
16.3 Memory: CLAUDE.md
| File | Scope | Use |
|---|---|---|
| Managed / enterprise policy | The whole organization | Company-wide rules |
| ~/.claude/CLAUDE.md | User (all projects) | Personal preferences |
| ./CLAUDE.md | Project (committed to git) | Build commands, architecture, conventions |
| CLAUDE.local.md | Project, only you | Personal project notes (gitignore) |
| Subfolder CLAUDE.md | When working in that folder | Module-specific rules |
The /init command scans the codebase and creates a starter CLAUDE.md. In CLAUDE.md you can import other files with @path/to/file. Keep it short and specific — it is loaded in every session.
# Project: Billing API (.NET 8)
## Commands
- Build: `dotnet build`
- Test: `dotnet test --filter Category!=Integration`
## Conventions
- Async method names end with `Async`.
- Never hand-edit EF Core migrations.
- Update `docs/api.md` on every public API change.16.4 Slash commands (important)
| Command | What it does |
|---|---|
| /init | Create CLAUDE.md |
| /clear | Clear the conversation (new task) |
| /compact [focus] | Summarize history to save context |
| /context | How full the context window is |
| /model | Switch model (Opus, Sonnet, Haiku...) |
| /config | Settings |
| /permissions | Allow/deny rules |
| /memory | Edit CLAUDE.md files |
| /mcp | Manage MCP servers, OAuth login |
| /agents | Create/manage subagents |
| /hooks | Configure hooks |
| /plugin | Install plugins / marketplaces |
| /resume | Open an old session |
| /review, /security-review | Code review / security review |
| /cost, /usage | Tokens/cost and plan usage |
| /help | All commands |
Custom slash command: create a .claude/commands/fix-issue.md file (with the $ARGUMENTS placeholder) — it runs as /fix-issue 123. In newer versions these have merged with skills.
16.5 Keyboard shortcuts and input tricks
| Shortcut | What it does |
|---|---|
| Shift+Tab | Cycle permission modes (default → accept edits → plan ...) |
| Esc | Stop Claude midway |
| Esc Esc | Rewind: go back to the previous message/checkpoint |
| @file | Mention a file to put it in context |
| !command | Run a bash command directly, output goes into context |
| # / memory | Quickly add a note to memory (depends on version) |
| Ctrl+C | Cancel / exit |
| Image paste / drag | Give a screenshot or design mockup |
16.6 Permission modes
| Mode | Behavior |
|---|---|
| default | Asks permission on every risky action (edit, bash) |
| acceptEdits | Automatically accepts file edits, asks on commands |
| plan | Read-only: only explore and plan, nothing changes |
| auto | A classifier auto-approves safe actions, stops on risky ones |
| bypassPermissions | Everything allowed — only in an isolated sandbox/container |
// .claude/settings.json (project, committed to git)
{
"permissions": {
"allow": ["Bash(dotnet test:*)", "Bash(git status)", "Read(./src/**)"],
"deny": ["Read(./.env)", "Bash(rm -rf:*)"]
},
"env": { "ASPNETCORE_ENVIRONMENT": "Development" }
}Settings hierarchy (high → low priority): managed policy → command-line args → .claude/settings.local.json → .claude/settings.json → ~/.claude/settings.json.
16.7 Hooks
Hooks are shell commands that run deterministically on Claude Code lifecycle events — not left to the model. For example a formatter after every edit, or blocking a dangerous command.
| Event | When it runs |
|---|---|
| PreToolUse | Before a tool runs (you can block / modify) |
| PostToolUse | After a tool runs (format, lint) |
| UserPromptSubmit | When the user submits a prompt (add context / validate) |
| Notification | When Claude waits for permission or input |
| Stop / SubagentStop | When the response ends |
| PreCompact | Before compaction |
| SessionStart / SessionEnd | Session start / end |
{
"hooks": {
"PostToolUse": [{
"matcher": "Edit|Write",
"hooks": [{ "type": "command", "command": "dotnet format --include $CLAUDE_FILE_PATHS" }]
}]
}
}16.8 Subagents
A subagent is a specialized assistant that runs in its own separate context window, with its own tools and system prompt. The main conversation stays clean — the subagent returns only a summary. Create one with /agents or put a file in .claude/agents/.
---
name: test-runner
description: Runs tests after a code change and fixes failures. Use proactively.
tools: Read, Edit, Bash, Grep
model: sonnet
---
You are a test automation expert. Run the tests, if they fail find the root cause,
make a minimal fix, and run them again. Give a short report at the end.16.9 Plugins, MCP and integrations
| Item | What it is |
|---|---|
| Plugins | A bundle of commands, subagents, skills, hooks, MCP servers; installed from a marketplace with /plugin |
| MCP | Connect tools like GitHub, Jira, DB, Figma, Sentry (claude mcp add) |
| IDE | VS Code / JetBrains extension: diff view, selection context |
| GitHub Actions | /install-github-app; work starts by mentioning @claude in a PR/issue |
| Git worktrees | Several Claude sessions in parallel on different branches |
| Headless mode | claude -p in CI/CD and scripts; --output-format stream-json |
| Claude Code on the web | Tasks in a cloud sandbox from the browser, also from mobile |
| Checkpoints | A snapshot before every edit; you can rewind |
16.10 Best workflow
- Explore: "First read the relevant files, do not write code yet."
- Plan: Have it make a plan in plan mode (Shift+Tab) and review it.
- Code: Have it implement, in small steps.
- Verify: Have it check with tests / build / screenshots (TDD is best).
- Commit: Have it write the commit message and create the PR.
- New unrelated task? /clear. Context filling up? /compact.