July 13, 2026

TL;DR — Claude Code is Anthropic's terminal-first coding agent with the highest SWE-bench Verified score (80.9%) of any production tool. This tutorial covers everything from installation to advanced multi-agent systems: CLAUDE.md (project memory), Plan Mode (think before acting), skills (dynamic capabilities), MCP servers (external tool integration), subagents (parallel specialists), hooks (lifecycle automation), permissions (safety guardrails), and essential shortcuts. Setup takes 5 minutes. Pro is $20/month.

Claude Code Tutorial 2026: Complete Guide from Setup to Multi-Agent Systems

Claude Code is Anthropic's agentic coding tool. It lives in your terminal, reads your entire codebase, edits files, runs commands, creates commits, and connects to external services — all through natural language. It scores 80.9% on SWE-bench Verified, the highest of any production coding agent in 2026 (aisaying 2026).

This guide takes you from zero to a working Claude Code setup with CLAUDE.md, skills, MCP servers, hooks, memory, and subagents.

Installation: 5-Minute Setup

# 1. Install globally (requires Node.js 18+)
npm install -g @anthropic-ai/claude-code

# 2. Authenticate
claude login

# 3. Start a session from your project directory
claude

Authentication opens a browser tab linked to your Anthropic account (Pro plan or API key). Once authenticated, every subsequent claude invocation in a project directory starts an informed session — Claude knows your filesystem, your build system, and your CLAUDE.md from the first message (prabhat 2026).

Prerequisites:
- Node.js 18 or higher
- Anthropic account (Claude Pro, Max, or API key)
- macOS, Linux, or Windows (WSL)

Four Interaction Modes

Mode How to Start Use It For
Interactive (REPL) claude Daily coding, exploratory work, pair programming
One-shot claude "task description" Quick tasks, return to shell after
Non-interactive claude -p "query" Scripts, CI pipelines, automation (output to stdout)
Plan Mode Shift+Tab (inside session) Research and plan before writing code

Sources: prabhat.dev (2026), eesel.ai (2026), built-not-hired.com (2026).

Essential Commands and Shortcuts

Command/Shortcut What It Does
claude Start interactive mode
claude "task" Run a one-time task and return to shell
claude -p "query" Non-interactive: run query and exit (for pipes/scripts)
claude -c or --continue Resume most recent conversation in this directory
claude -r or --resume Open conversation picker to resume a previous session
claude --permission-mode plan Start in Plan Mode (read-only)
claude --worktree Start session in a new git worktree on its own branch
claude --bg "task" Launch a background agent session
claude agents View all running, blocked, and completed sessions
Shift+Tab Cycle permission modes (Default → Accept Edits → Plan)
Ctrl+C Cancel current generation
Ctrl+D Exit session
Alt+P / Option+P Switch model (Sonnet, Opus)
Alt+T / Option+T Toggle extended thinking
Esc then Esc Rewind or summarize conversation
!command Run a shell command directly
@filename Reference a specific file in your message
/ Open the command and skill menu
/init Auto-generate CLAUDE.md based on your project
/compact Compact context to free up space
/clear Clear conversation history
/mcp List connected MCP servers

Sources: eesel.ai (2026), built-not-hired.com (2026), computingforgeeks.com (2026).

CLAUDE.md: The Brain File

CLAUDE.md is the single most important file in your setup. It is a markdown file in your project root that Claude reads at the start of every session — before your first prompt. A good CLAUDE.md cuts your token usage in half and stops the agent from re-discovering your stack on every turn (ayautomate 2026).

CLAUDE.md Loading Order

Claude Code loads CLAUDE.md files from multiple locations and combines them (additive, not overriding):

  1. ~/.claude/CLAUDE.md — global preferences (all projects)
  2. ./CLAUDE.md — project root (committed to git, shared with team)
  3. ./CLAUDE.local.md — local overrides (gitignored)
  4. ./subdirectory/CLAUDE.md — directory-specific context

Example CLAUDE.md

# Project: E-commerce API

## Tech Stack
- Node.js 22, Express, PostgreSQL, Redis
- TypeScript strict mode
- Tests: Vitest, Supertest

## Architecture
- Routes → Controllers → Services → Repositories
- Auth is in src/auth/ — don't modify without security review
- Never modify migrations/ or config/production.js

## Coding Standards
- Use async/await, not callbacks
- No console.log in production code (use the logger utility)
- Use zod for schema validation, not joi
- No new dependencies without asking first

## Commands
- Build: npm run build
- Test: npm test
- Lint: npm run lint
- Dev: npm run dev

## Quality Gates
- Always run npm test after edits
- If tests fail, fix them before committing

Tip: You do not have to write CLAUDE.md from scratch. Run /init inside Claude Code to auto-generate one based on your project, or ask: "Read this project and write a CLAUDE.md that captures the key patterns and conventions" (built-not-hired 2026).

Keep it under 200 lines per file. Write in plain language. Update it as your project evolves. Commit it to git.

Permission Modes

Mode What It Does When to Use
Default File reads automatic. Edits and commands require approval. Start here. Daily work.
Accept Edits Reads and file edits automatic. Only shell commands need approval. Trusted tasks, faster workflow.
Plan Read-only. Claude explores and plans but does not change anything. Before big tasks, codebase exploration.

Press Shift+Tab to cycle between modes (built-not-hired 2026).

Built-in Tools

Claude Code has access to these built-in tools without any configuration:

Tool What It Does
Read Reads any file in your project
Edit Makes precise changes to specific lines in a file
Write Creates new files
Bash Runs shell commands (builds, tests, git, anything)
Grep Searches file contents across your codebase
Glob Finds files by name pattern
WebFetch Fetches content from URLs
WebSearch Searches the web

MCP: External Tool Integration

The Model Context Protocol (MCP) is how Claude Code talks to external systems: filesystems, databases, APIs, browsers, design tools. By 2026 there are hundreds of MCP servers (ayautomate 2026).

Adding an MCP Server

# Add a filesystem MCP server
claude mcp add filesystem npx -- -y @modelcontextprotocol/server-filesystem /Users/you/projects

# Add a remote HTTP MCP server
claude mcp add --transport http my-server https://api.example.com/mcp

# List all configured MCP servers
claude mcp list

# Check status inside a session
/mcp

MCP servers can be configured at three scopes:
- User-level: ~/.claude.json (all projects)
- Project-level: .mcp.json (committed to git, shared with team)
- Project-local: .mcp.json with local overrides (gitignored)

Security note: MCP servers run with your full local permissions. Only add servers from sources you trust (ayautomate 2026).

Subagents: Parallel Specialists

Subagents are scoped specialists you invoke from the main session. They run with their own system prompt, their own tool allowlist, and their own context window — they cannot see your main conversation context. Use them to parallelize, isolate risky tasks, or enforce a specific role (prabhat 2026).

Creating a Subagent

Create .claude/agents/code-reviewer.md in your repo:

---
name: code-reviewer
tools:
  - Read
  - Grep
  - Bash
allowed_commands:
  - git diff
  - git log
model: claude-sonnet-4-6
---

You are a senior code reviewer. Review code changes for:
- Security vulnerabilities
- Performance issues
- Code style violations
- Missing tests

Provide specific, actionable feedback with file paths and line numbers.
Do not make edits — review only.

Invoking a Subagent

In your main session, type:

Use the code-reviewer agent to review the changes in this branch

Common subagents to start with: code-reviewer, test-writer, debugger, doc-writer, migration-helper. Build the ones you actually need, not the ones from a tutorial (ayautomate 2026).

Subagents can also run in isolated git worktrees, which is especially powerful for large batched changes (support.claude.com 2026).

Hooks: Lifecycle Automation

Hooks are shell commands the CLI runs automatically at specific lifecycle events: before a tool call, after a file edit, when the session stops. They wire Claude Code into your existing dev workflow without trusting the agent to remember (prabhat 2026).

Auto-Format on Edit

Add to .claude/settings.json:

{
  "hooks": {
    "PostToolUse": [
      {
        "matcher": "Edit|Write",
        "handler": {
          "type": "command",
          "command": "prettier --write $FILE_PATH"
        }
      }
    ]
  }
}

Five Hook Handler Types

Type How It Works
command Runs a shell script. Event JSON on stdin, block/allow on stdout.
http POSTs event JSON to a URL. Useful for webhooks and policy servers.
mcp_tool Calls a tool on a connected MCP server.
prompt Sends a yes/no question to a Claude model for policy evaluation.
agent Spawns a subagent with Read/Grep/Glob access for condition checking.

Source: eesel.ai (2026).

Skills: Dynamic Capabilities

Skills live in .claude/skills/ inside your project. Each skill gets its own folder with a SKILL.md file. Unlike rules (which are always included), skills are loaded dynamically when the agent decides they are relevant — keeping your context window clean (cursor.com 2026, prabhat 2026).

Example Skill Structure

.claude/skills/
  deploy/
    SKILL.md
    deploy-config.md

SKILL.md Example

---
name: deploy
description: "Deploy the application to production. Use when the user asks to deploy, ship, or release."
---

## Deploy Process
1. Run npm run build
2. Run npm test
3. If both pass, run deploy.sh production
4. Verify deployment at https://api.example.com/health

The description field is what Claude reads to decide whether to activate the skill. When a task matches, Claude loads the full SKILL.md and follows its instructions (built-not-hired 2026).

Context Management

Claude's context window is its working memory for a session. Every file it reads, every message exchanged, and every tool result consumes context. When context fills up, performance degrades — Claude starts forgetting earlier decisions (prabhat 2026).

Key commands for context management:
- /compact — Compact context to free up space (summarizes older messages)
- /clear — Clear conversation history entirely (fresh start)
- Use subagents to isolate expensive tasks in separate context windows
- Use @filename to reference specific files instead of having Claude read entire directories

Project Structure Overview

your-project/
├── CLAUDE.md              # Project memory (committed to git)
├── CLAUDE.local.md        # Local overrides (gitignored)
├── .mcp.json              # MCP server configs (committed)
├── .claude/
│   ├── settings.json      # Permissions, hooks, model config
│   ├── settings.local.json # Local settings (gitignored)
│   ├── rules/             # Modular rule files by topic
│   │   ├── code-style.md
│   │   ├── testing.md
│   │   └── api-conventions.md
│   ├── commands/          # Custom slash commands
│   │   ├── review.md
│   │   └── fix-issue.md
│   ├── skills/            # Dynamic capabilities
│   │   └── deploy/
│   │       └── SKILL.md
│   ├── agents/            # Subagent definitions
│   │   ├── code-reviewer.md
│   │   └── security-auditor.md
│   └── hooks/             # Lifecycle scripts
│       └── validate-bash.sh

Source: prabhat.dev (2026).

Claude Code vs Other AI Coding Tools

Factor Claude Code Cursor GitHub Copilot
Type Terminal agent IDE (VS Code fork) IDE extension
SWE-bench 80.9% 65.8% 52.7%
Memory CLAUDE.md + /memory .cursorrules None
MCP support Yes (native) No No
Subagents Yes No No
Hooks Yes No No
Inline completions No Best (Tab) Good
Price $20/mo (Pro) $20/mo $10/mo

Use Claude Code for: complex refactors, bug hunts across large codebases, migrations, generating tests, autonomous multi-step tasks, and any task where you would spend 30+ minutes understanding code before changing it.

Use Cursor for: daily IDE coding, inline completions, visual editing, multi-file edits with diff review.

Most serious engineers run both — Cursor for daily flow, Claude Code for hard problems (jobsbyculture 2026).

For a full comparison, see our AI coding assistants compared guide. For Cursor specifically, see our Cursor AI guide.

FAQ

Can I use Claude Code with any editor?

Yes. Claude Code runs in the terminal, so it works alongside any editor — VS Code, JetBrains, Vim, Neovim, Emacs, or any other. It does not integrate into the editor's UI like Cursor or Copilot, but it can read and edit the same files your editor has open. Claude Code also has a VS Code extension and JetBrains plugin that provide a UI wrapper around the same underlying engine. CLAUDE.md files, settings, and MCP servers you configure in the CLI work across all surfaces (eesel 2026).

How do I stop Claude Code from running dangerous commands?

Use permission modes. In Default mode, Claude asks before running any shell command or editing files. In Plan mode, Claude cannot make any changes at all. You can also restrict specific tools in .claude/settings.json and use hooks to block unsafe operations. For maximum safety: start in Default mode, commit your work to git before any autonomous task, and use the --permission-mode plan flag for exploration. Never use Accept Edits mode on production code without a git checkpoint.

Can Claude Code work in CI/CD pipelines?

Yes. Use claude -p "query" for non-interactive one-shot execution. Output goes to stdout — pipe it, log it, or use it in scripts. Use --output-format json for structured output. Common CI/CD use cases: automated code review on PRs, generating test coverage reports, fixing linting errors, updating documentation. Set up a dedicated API key for CI and use environment variables for authentication. Use claude --bg "task" for long-running background agents.

How do I manage Claude Code costs?

Four strategies: (1) Use /compact regularly to keep context small — context is the biggest cost driver. (2) Use Claude Sonnet for daily work (not Opus) — Sonnet is 5x cheaper and sufficient for most tasks. (3) Enable prompt caching to reduce input costs 50-90% for repeated context. (4) Use subagents to isolate expensive tasks — each subagent has its own context window, so a complex task in a subagent does not bloat your main session. Real monthly cost for heavy users: $150-200 on Pro with API overages. On Max ($200/month), overages are less common.

What is the /init command?

/init is a built-in command that scans your project and auto-generates a CLAUDE.md file with build commands, test instructions, and code conventions. Review and edit the generated file — it is a starting point, not a finished product. Run /init when you first set up Claude Code in a new project, or when your project structure changes significantly. The auto-generated CLAUDE.md is usually 80% correct and needs minor edits for project-specific conventions (computingforgeeks 2026).


Want a self-hosted AI company brain that does all of this out of the box?
Book a demo →