Anthropic Claude Series — Presentation 4 of 10

Claude Code

The CLI Tool for Agentic Software Development

An agentic coding assistant that lives in your terminal — reading, writing, and executing code with full project context. No IDE required.

CLI Agentic Terminal-native Open Source
01

What Is Claude Code?

Claude Code is Anthropic's agentic coding tool that operates directly in your terminal. It understands your entire codebase, executes real commands, and iterates autonomously to complete complex tasks.

Reads & Understands

  • Searches across entire codebases
  • Reads files, configs, docs
  • Understands project structure
  • Analyzes dependencies

Writes & Edits

  • Creates new files from scratch
  • Makes surgical edits to existing code
  • Multi-file refactoring
  • Generates tests & documentation

Executes & Iterates

  • Runs shell commands
  • Executes tests, fixes failures
  • Git commits & PR creation
  • Self-corrects on errors

Key differentiator: Unlike chat-based assistants, Claude Code operates as a true agent — it plans multi-step tasks, uses tools, and iterates until the job is done. It works with your real filesystem and shell environment.

02

Installation

Install (Recommended: Native Installer)

# Native installer — no Node.js required
curl -fsSL https://claude.ai/install.sh | sh

# Alternative: install via npm
npm install -g @anthropic-ai/claude-code

# Verify installation
claude --version

# Update to latest
npm update -g @anthropic-ai/claude-code

Prerequisites

RequirementMinimum
Node.jsv18.0.0+ (npm method only)
Operating SystemmacOS 12+, Ubuntu 20.04+, Windows via WSL2
RAM4 GB recommended
GitRecommended (not required)

First Launch

# Navigate to your project
cd my-project/

# Start Claude Code
claude

On first run, Claude Code will walk you through authentication and display the interactive REPL.

Alternative: npx

# Run without installing
npx @anthropic-ai/claude-code

Useful for one-off usage or trying it out.

03

Authentication

Anthropic API Key

# Set via environment variable
export ANTHROPIC_API_KEY=sk-ant-...

# Or pass inline
ANTHROPIC_API_KEY=sk-ant-... claude

Direct API access. You pay per token via your Anthropic account. Best for individual developers.

OAuth / Browser Login

# Interactive login flow
claude login

# Opens browser for OAuth
# Tokens stored securely

Browser-based login tied to your Anthropic Console account. Supports Max plan with included usage.

Third-Party Providers

# Amazon Bedrock
export CLAUDE_CODE_USE_BEDROCK=1

# Google Vertex AI
export CLAUDE_CODE_USE_VERTEX=1

# Microsoft Azure AI Foundry
export CLAUDE_CODE_USE_AZURE=1

Route through your cloud provider. Use existing AWS or GCP credentials and billing.

Console Setup: Go to console.anthropic.com → create an API key → set usage limits → enable billing. Claude Code uses Claude Sonnet by default, switchable to Opus via /model.

04

First Run — The REPL Interface

$ cd my-project && claude

╭──────────────────────────────────╮
│  Claude Code        v1.0.32     │
│                                  │
│  /help for commands              │
│  Type your request...            │
╰──────────────────────────────────╯

> Explain the architecture of this project

  I'll analyze the project structure...

  [Read] package.json
  [Glob] **/*.ts
  [Read] src/index.ts
  [Read] src/config.ts

  This project is a TypeScript REST API
  using Express with the following
  architecture...

> _

REPL Features

  • Interactive prompt — type natural language requests
  • Tool transparency — see every tool call in real time
  • Permission prompts — approve or deny file writes and commands
  • Multi-turn — context carries across turns
  • Vim keybindings — Escape for multi-line edit mode

One-Shot Mode

# Non-interactive: pass prompt directly
claude -p "explain this codebase"

# Pipe input
cat error.log | claude -p "fix this"

# Output as JSON
claude -p "list files" --json
05

Core Tools — File Operations

Read

Reads files from the filesystem. Supports text, images, PDFs, and Jupyter notebooks.

{
  "file_path": "/absolute/path/to/file.ts",
  "offset": 100,  // start at line 100
  "limit": 50     // read 50 lines
}
  • Always uses absolute paths
  • Returns content with line numbers
  • Can read images for visual analysis

Edit

Performs exact string replacements in files. Surgical, diff-based editing.

{
  "file_path": "/path/to/file.ts",
  "old_string": "const x = 1;",
  "new_string": "const x = 2;",
  "replace_all": false
}
  • Requires unique old_string match
  • Preserves exact indentation
  • replace_all for bulk renames

Write

Creates new files or completely overwrites existing ones.

{
  "file_path": "/path/to/new-file.ts",
  "content": "export function hello() {\n  return 'world';\n}"
}
  • Must Read before overwriting existing files
  • Prefers Edit for partial changes

Bash

Executes shell commands with full access to the system environment.

{
  "command": "npm test -- --coverage",
  "timeout": 120000,
  "run_in_background": false
}
  • 2-minute default timeout (up to 10 min)
  • Background execution support
  • Working directory persists between calls
06

Core Tools — Search Operations

Grep (Content Search)

Powered by ripgrep. Searches file contents with regex support.

{
  "pattern": "function\\s+handle\\w+",
  "path": "src/",
  "glob": "*.ts",
  "output_mode": "content",
  "-C": 3
}
  • Three output modes: content, files_with_matches, count
  • Context lines with -A, -B, -C flags
  • Case-insensitive with -i
  • Multiline matching support

Glob (File Search)

Fast file pattern matching. Finds files by name patterns across the project.

{
  "pattern": "**/*.test.ts",
  "path": "src/"
}
  • Standard glob patterns (*, **, ?)
  • Results sorted by modification time
  • Much faster than find command

Tool Selection Strategy

Claude Code automatically chooses the right tool for the job:

Know the file path? → Use Read  |  Search by file name? → Use Glob  |  Search by content? → Use Grep  |  Run a command? → Use Bash

07

The Agent Loop

Claude Code operates in an autonomous plan → act → observe → iterate loop until the task is complete.

User Prompt Plan Analyze & strategize Execute Tool Read, Edit, Bash... Observe Evaluate result iterate until done Respond to User Summary + results done

Autonomous

Claude Code decides which tools to call, in what order, without user guidance for each step.

Self-Correcting

When a tool call fails or returns unexpected results, it adjusts its approach and retries.

Parallel Calls

Independent tool calls are batched together for faster execution (e.g., reading multiple files at once).

08

Slash Commands

Built-in commands that control Claude Code's behavior. Type / in the REPL to see all options.

CommandDescription
/helpShow all available commands and usage
/modelSwitch model (e.g., Sonnet ↔ Opus)
/clearReset conversation context
/compactSummarize context to free up token space
/costShow token usage and estimated cost
/loginSwitch authentication method
/configOpen or edit settings
/permissionsView and manage tool permissions
CommandDescription
/commitGenerate a commit for staged changes
/prReview a pull request
/pr-commentsView and address PR feedback
/initGenerate a CLAUDE.md for current project
/bugReport a bug to Anthropic
/doctorDiagnose common configuration issues
/vimToggle vim keybinding mode
/add-dirAdd additional directories to context

Custom slash commands: You can create custom commands by adding them as .claude/commands/ markdown files. They show up under / and can include templates with $ARGUMENTS placeholder.

09

CLAUDE.md — Project Configuration

CLAUDE.md is a special markdown file that gives Claude Code persistent context about your project — coding standards, architecture, common patterns, and instructions.

# CLAUDE.md

## Project Overview
This is a TypeScript monorepo using Turborepo.

## Code Style
- Use functional components with hooks
- Prefer named exports over default exports
- All functions must have JSDoc comments

## Architecture
- /packages/api — Express REST API
- /packages/web — Next.js frontend
- /packages/shared — Shared types

## Testing
- Run tests: `npm test`
- E2E tests: `npm run test:e2e`
- Always write tests for new features

## Common Gotchas
- The DB migration must run before tests
- Port 3000 is used by the dev server

File Hierarchy

  • ~/.claude/CLAUDE.md — Global user config
  • /project/CLAUDE.md — Project root
  • /project/src/CLAUDE.md — Folder-specific

All levels are merged, with more specific files taking priority.

What to Include

  • Build & test commands
  • Code style preferences
  • Architecture overview
  • Common pitfalls & gotchas
  • Naming conventions
  • Deployment procedures

Generate Automatically

# Auto-generate from codebase
claude /init
10

Permission System

Claude Code enforces a security-first permission model. Every potentially destructive action requires explicit approval.

Always Allowed (No Prompt) Read, Glob, Grep, Fetch Requires Approval Write, Edit, Bash (first time or new pattern) Denied by Default Destructive ops (rm -rf, git push --force)

Approval Options

  • Yes — allow this one time
  • Always allow — auto-approve this tool
  • No — deny this action
  • Always allow for project — scope to this repo

settings.json

{
  "permissions": {
    "allow": [
      "Bash(npm test*)",
      "Bash(git diff*)",
      "Write(src/**)"
    ],
    "deny": [
      "Bash(rm -rf*)",
      "Bash(*--force*)"
    ]
  }
}
11

Hooks

Hooks let you run custom code before or after Claude Code tool calls, enabling validation, logging, and automation.

Hook Configuration (settings.json)

{
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "Bash",
        "hooks": [
          {
            "type": "command",
            "command": "echo 'Running Bash tool...'"
          }
        ]
      }
    ],
    "PostToolUse": [
      {
        "matcher": "Write",
        "hooks": [
          {
            "type": "command",
            "command": "npx prettier --write $CLAUDE_FILE_PATH"
          }
        ]
      }
    ],
    "UserPromptSubmit": [
      {
        "hooks": [
          {
            "type": "command",
            "command": "echo 'Prompt received'"
          }
        ]
      }
    ]
  }
}

Hook Types

HookFires When
PreToolUseBefore a tool executes
PostToolUseAfter a tool completes
UserPromptSubmitWhen user sends a message
StopWhen agent turn finishes

Use Cases

  • Auto-format files after Write/Edit
  • Run linters before committing
  • Log all tool usage for auditing
  • Block certain file modifications
  • Inject context before prompts
  • Send notifications on completion

Environment Variables

Hooks receive context via env vars: CLAUDE_FILE_PATH, CLAUDE_TOOL_NAME, CLAUDE_TOOL_INPUT

12

MCP Servers

The Model Context Protocol lets you extend Claude Code with custom tools and data sources via MCP servers.

What is MCP?

An open protocol for connecting AI models to external tools, APIs, and data. Claude Code acts as an MCP client that can connect to any MCP server.

Configuration

// .claude/mcp_servers.json
{
  "mcpServers": {
    "github": {
      "command": "npx",
      "args": [
        "-y", "@modelcontextprotocol/server-github"
      ],
      "env": {
        "GITHUB_TOKEN": "ghp_..."
      }
    },
    "postgres": {
      "command": "npx",
      "args": [
        "-y", "@modelcontextprotocol/server-postgres",
        "postgresql://localhost/mydb"
      ]
    }
  }
}

Popular MCP Servers

ServerProvides
GitHubIssues, PRs, repos, actions
PostgreSQLDatabase queries & schema
FilesystemSandboxed file access
SlackChannel messages & search
PuppeteerBrowser automation
SentryError tracking & issues

Adding Servers

# Add via CLI
claude mcp add github \
  npx -y @modelcontextprotocol/server-github

# List configured servers
claude mcp list

# Remove a server
claude mcp remove github

Scope

Project: .claude/mcp_servers.json
Global: ~/.claude/mcp_servers.json

13

Sub-agents

Claude Code can spawn sub-agents for complex tasks — isolated Claude instances that handle specific parts of a larger problem.

Main Agent Agent (Explore) Research & analyze Agent (Code) Implement changes Agent (Test) Validate & verify Read, Grep, Glob Edit, Write, Bash Bash(npm test)

Agent Tool

The main agent can delegate tasks to sub-agents using the Agent tool. Each sub-agent gets its own context window and tool access.

Capabilities

  • Read-only agents for exploration
  • Full agents for implementation
  • Parallel execution for independent tasks
  • Results returned to parent agent

When Sub-agents Help

  • Searching large codebases in parallel
  • Multi-file edits across different modules
  • Research tasks that need deep exploration
  • Preventing context window exhaustion
14

Memory System

Claude Code maintains persistent memory across sessions via CLAUDE.md files, enabling it to learn and remember project-specific context.

How Memory Works

  • Claude Code reads CLAUDE.md at the start of every session
  • You can ask it to "remember" something and it writes to CLAUDE.md
  • Memory persists between sessions and across team members (if committed)
  • Memories follow the file hierarchy: global → project → folder

Memory Types

TypeScopeLocation
UserAll projects~/.claude/CLAUDE.md
ProjectCurrent repo./CLAUDE.md
FolderSubdirectory./src/CLAUDE.md
User-ProjectPer user per repo.claude/local/CLAUDE.md

Adding Memories

> Remember that we use pnpm not npm

  I'll add that to your project's
  CLAUDE.md file.

  [Write] CLAUDE.md
  Added: "Use pnpm instead of npm for
  all package management commands."

Best Practices

  • Keep CLAUDE.md concise — it's loaded every turn
  • Commit project CLAUDE.md to version control
  • Put personal preferences in user-level config
  • Use folder-level CLAUDE.md for module-specific rules
  • Review and prune periodically
15

Git Integration

Claude Code has deep Git integration — it can commit, branch, create PRs, and review code following your project's conventions.

Commits

# Ask Claude to commit
> commit these changes

# Or use slash command
/commit

# Claude will:
# 1. Run git status & git diff
# 2. Analyze staged changes
# 3. Draft a descriptive commit message
# 4. Create the commit

Commit messages follow conventional format and include Co-Authored-By attribution.

Pull Requests

# Create a PR
> create a PR for this branch

# Review an existing PR
/pr 123

# Address PR comments
/pr-comments

Uses gh CLI under the hood for all GitHub operations.

Safety Guardrails

  • Never force-pushes unless explicitly asked
  • Never amends commits (creates new ones)
  • Never skips hooks (--no-verify)
  • Warns before pushing to main/master
  • Stages specific files, avoids git add -A
  • Checks for secrets before committing

Code Review Workflow

  • 1. Fetch PR diff and comments
  • 2. Analyze each changed file
  • 3. Check for bugs, style, and logic issues
  • 4. Provide inline feedback
  • 5. Summarize findings
16

Multi-file Editing

One of Claude Code's strongest capabilities: coordinated edits across many files in a single operation.

How It Works

  • 1. Discover — Grep/Glob to find all affected files
  • 2. Analyze — Read each file to understand context
  • 3. Plan — Determine all changes needed
  • 4. Execute — Apply edits (often in parallel)
  • 5. Verify — Run tests to confirm nothing broke

Example: Rename a Function

> Rename getUserData to fetchUserProfile
  everywhere in the codebase

  [Grep] "getUserData" across **/*.ts
  Found 23 matches in 12 files

  [Edit] src/api/users.ts (definition)
  [Edit] src/hooks/useUser.ts (import)
  [Edit] src/pages/profile.tsx (usage)
  ... (9 more files)

  [Bash] npm test
  All 147 tests passing.

Common Refactoring Tasks

  • Rename functions, types, or variables across the codebase
  • Migrate from one API pattern to another
  • Add error handling to all API endpoints
  • Convert class components to hooks
  • Update import paths after restructuring
  • Add TypeScript types to JavaScript files

Advantages Over IDE Refactoring

  • Semantic understanding — knows when a string match is actually a reference vs. a coincidence
  • Cross-language — updates code, tests, docs, and configs together
  • Verification — runs tests after refactoring
  • Context-aware — adjusts related code (e.g., updating types when renaming)
17

IDE Integration

While Claude Code is terminal-native, it integrates with popular IDEs for a seamless workflow.

VS Code Extension

  • Embeds Claude Code terminal in VS Code
  • File diffs shown in VS Code's native diff viewer
  • Click to open referenced files
  • Shares workspace context
  • Keyboard shortcut: Ctrl+Shift+`
# Install extension
code --install-extension anthropic.claude-code

JetBrains Plugin

  • Works with IntelliJ, WebStorm, PyCharm, etc.
  • Integrated terminal panel
  • File navigation integration
  • Diff visualization

Install from the JetBrains Marketplace or search "Claude Code" in plugin settings.

Terminal-First Philosophy

  • Works in any terminal emulator
  • SSH-compatible (remote dev)
  • tmux/screen compatible
  • CI/CD pipeline integration
  • No IDE dependency required

The IDE extensions are convenience wrappers — all functionality works in a plain terminal.

Workflow tip: Many developers run Claude Code in a side-by-side terminal next to their IDE, using the IDE for browsing/reviewing changes and Claude Code for making them.

18

Advanced Configuration

settings.json Locations

ScopePath
User~/.claude/settings.json
Project.claude/settings.json
Local (gitignored).claude/settings.local.json

Key Settings

{
  "model": "claude-sonnet-4-20250514",
  "permissions": {
    "allow": ["Bash(npm *)"],
    "deny": ["Bash(rm *)"]
  },
  "hooks": { ... },
  "mcpServers": { ... },
  "customCommands": { ... }
}

Environment Variables

VariablePurpose
ANTHROPIC_API_KEYAPI authentication
CLAUDE_MODELOverride default model
CLAUDE_CODE_USE_BEDROCKUse AWS Bedrock
CLAUDE_CODE_USE_VERTEXUse Google Vertex
CLAUDE_CODE_USE_AZUREUse Microsoft Azure AI Foundry
ANTHROPIC_BASE_URLCustom API endpoint
CLAUDE_CODE_MAX_TURNSLimit agent turns

Model Selection

# In REPL
/model claude-opus-4-20250514

# Via environment
export CLAUDE_MODEL=claude-opus-4-20250514

# Via CLI flag
claude --model claude-opus-4-20250514
19

Debugging & Troubleshooting

Common Issues

ProblemSolution
Authentication errorsRun claude login or check API key
Slow responsesUse /compact to reduce context
Wrong file editsBe more specific in your prompt
Context too long/clear to reset, or /compact
Tool permission deniedCheck /permissions
MCP server failsclaude mcp list to debug

Doctor Command

# Diagnose configuration issues
/doctor

# Checks:
# - Node.js version
# - Authentication status
# - MCP server connectivity
# - Settings file validity

Verbose & Debug Mode

# Enable verbose output
claude --verbose

# Debug logging
CLAUDE_CODE_DEBUG=1 claude

# View conversation log
# (stored in ~/.claude/logs/)

Context Management

  • /compact — summarizes conversation, frees tokens
  • /clear — wipes all context, fresh start
  • /cost — shows token usage and spend
  • Claude Code auto-compacts when context is near the limit
  • Prefer focused prompts over open-ended ones to reduce context growth

When Things Go Wrong

Claude Code never makes changes it can't undo. Use git diff to review changes and git checkout to revert if needed.

20

Worktrees & Isolation

Run multiple Claude Code instances in parallel, isolated environments using Git worktrees.

Main Repository Worktree A feature/auth Worktree B fix/bug-123 Worktree C refactor/api claude (PID 1) claude (PID 2) claude (PID 3)

Git Worktrees

# Create isolated worktrees
git worktree add ../feature-auth feature/auth
git worktree add ../fix-bug fix/bug-123

# Run Claude in each
cd ../feature-auth && claude
cd ../fix-bug && claude

Benefits

  • Each instance has its own branch and working directory
  • No conflicts between parallel workstreams
  • Share the same Git history (single .git)
  • Ideal for working on multiple features simultaneously

Headless Mode

# Non-interactive for CI/CD
claude -p "fix all lint errors" \
  --allowedTools "Edit,Bash(npx eslint*)"

Run Claude Code in scripts and pipelines with explicit tool permissions.

21

Real-world Workflows

Bug Fixing

> Users report that login fails
  when email has a + character.
  Find and fix the bug.

Claude will:
1. Search for login/auth code
2. Find email validation logic
3. Identify the regex issue
4. Fix the validation
5. Add a test case
6. Run the test suite

Feature Development

> Add a dark mode toggle to the
  settings page. Use the existing
  theme system in ThemeContext.

Claude will:
1. Read ThemeContext implementation
2. Read the settings page
3. Add toggle component
4. Wire up theme switching
5. Update styles
6. Test the integration

Code Review

> /pr 456

Claude will:
1. Fetch the PR diff via gh CLI
2. Analyze each changed file
3. Check for bugs, security issues
4. Verify test coverage
5. Comment with findings
6. Suggest improvements

Codebase Exploration

> Explain how the payment
  processing pipeline works,
  from checkout to fulfillment.

Claude will:
1. Search for payment-related code
2. Trace the flow across services
3. Read configuration files
4. Map out the architecture
5. Present a clear explanation
22

Tips & Best Practices

Effective Prompting

  • Be specific about what you want
  • Reference file paths when you know them
  • Mention the testing strategy you expect
  • Include constraints ("don't modify X")
  • Break large tasks into steps if needed

Context Management

  • Use /compact regularly on long sessions
  • Start fresh with /clear for unrelated tasks
  • Keep CLAUDE.md concise and current
  • Use /cost to monitor token usage
  • Prefer focused prompts over vague ones

Power User Techniques

  • Pipe error output: npm test 2>&1 | claude -p "fix"
  • Use Escape for multi-line input mode
  • Create custom /commands for repeated tasks
  • Use --json for scripting integration
  • Set up hooks for auto-formatting

Safety & Version Control

  • Always work on a feature branch
  • Review diffs before committing: git diff
  • Use Claude Code's permission system wisely
  • Commit frequently — you can always revert

Common Pitfalls

  • Don't paste entire files into the prompt — let Claude read them
  • Don't fight the tool — rephrase if it misunderstands
  • Don't auto-allow everything — keep security guardrails
  • Don't skip reviewing changes before pushing
23

Summary

Claude Code transforms software development by bringing agentic AI capabilities directly into your terminal workflow.

Core Strengths

  • Terminal-native, no IDE dependency
  • Full filesystem and shell access
  • Autonomous multi-step execution
  • Deep Git integration

Extensibility

  • MCP servers for external tools
  • Hooks for custom automation
  • Custom slash commands
  • IDE plugins and integrations

Safety & Control

  • Permission system with allow/deny
  • Git safety guardrails
  • Transparent tool usage
  • Human-in-the-loop design

Get started:   curl -fsSL https://claude.ai/install.sh | sh && cd your-project && claude

Anthropic Claude Series — Presentation 4 of 10
Next: API & SDK