Anthropic Claude Series — Presentation 4 of 10
An agentic coding assistant that lives in your terminal — reading, writing, and executing code with full project context. No IDE required.
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.
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.
# 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
| Requirement | Minimum |
|---|---|
| Node.js | v18.0.0+ (npm method only) |
| Operating System | macOS 12+, Ubuntu 20.04+, Windows via WSL2 |
| RAM | 4 GB recommended |
| Git | Recommended (not required) |
# 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.
# Run without installing
npx @anthropic-ai/claude-code
Useful for one-off usage or trying it out.
# 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.
# 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.
# 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.
$ 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...
> _
# 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
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
}
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
}
old_string matchreplace_all for bulk renamesCreates new files or completely overwrites existing ones.
{
"file_path": "/path/to/new-file.ts",
"content": "export function hello() {\n return 'world';\n}"
}
Executes shell commands with full access to the system environment.
{
"command": "npm test -- --coverage",
"timeout": 120000,
"run_in_background": false
}
Powered by ripgrep. Searches file contents with regex support.
{
"pattern": "function\\s+handle\\w+",
"path": "src/",
"glob": "*.ts",
"output_mode": "content",
"-C": 3
}
content, files_with_matches, count-A, -B, -C flags-iFast file pattern matching. Finds files by name patterns across the project.
{
"pattern": "**/*.test.ts",
"path": "src/"
}
*, **, ?)find commandClaude 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
Claude Code operates in an autonomous plan → act → observe → iterate loop until the task is complete.
Claude Code decides which tools to call, in what order, without user guidance for each step.
When a tool call fails or returns unexpected results, it adjusts its approach and retries.
Independent tool calls are batched together for faster execution (e.g., reading multiple files at once).
Built-in commands that control Claude Code's behavior. Type / in the REPL to see all options.
| Command | Description |
|---|---|
/help | Show all available commands and usage |
/model | Switch model (e.g., Sonnet ↔ Opus) |
/clear | Reset conversation context |
/compact | Summarize context to free up token space |
/cost | Show token usage and estimated cost |
/login | Switch authentication method |
/config | Open or edit settings |
/permissions | View and manage tool permissions |
| Command | Description |
|---|---|
/commit | Generate a commit for staged changes |
/pr | Review a pull request |
/pr-comments | View and address PR feedback |
/init | Generate a CLAUDE.md for current project |
/bug | Report a bug to Anthropic |
/doctor | Diagnose common configuration issues |
/vim | Toggle vim keybinding mode |
/add-dir | Add 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.
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
All levels are merged, with more specific files taking priority.
# Auto-generate from codebase
claude /init
Claude Code enforces a security-first permission model. Every potentially destructive action requires explicit approval.
{
"permissions": {
"allow": [
"Bash(npm test*)",
"Bash(git diff*)",
"Write(src/**)"
],
"deny": [
"Bash(rm -rf*)",
"Bash(*--force*)"
]
}
}
Hooks let you run custom code before or after Claude Code tool calls, enabling validation, logging, and automation.
{
"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 | Fires When |
|---|---|
| PreToolUse | Before a tool executes |
| PostToolUse | After a tool completes |
| UserPromptSubmit | When user sends a message |
| Stop | When agent turn finishes |
Hooks receive context via env vars: CLAUDE_FILE_PATH, CLAUDE_TOOL_NAME, CLAUDE_TOOL_INPUT
The Model Context Protocol lets you extend Claude Code with custom tools and data sources via MCP servers.
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.
// .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"
]
}
}
}
| Server | Provides |
|---|---|
| GitHub | Issues, PRs, repos, actions |
| PostgreSQL | Database queries & schema |
| Filesystem | Sandboxed file access |
| Slack | Channel messages & search |
| Puppeteer | Browser automation |
| Sentry | Error tracking & issues |
# 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
Project: .claude/mcp_servers.json
Global: ~/.claude/mcp_servers.json
Claude Code can spawn sub-agents for complex tasks — isolated Claude instances that handle specific parts of a larger problem.
The main agent can delegate tasks to sub-agents using the Agent tool. Each sub-agent gets its own context window and tool access.
Claude Code maintains persistent memory across sessions via CLAUDE.md files, enabling it to learn and remember project-specific context.
CLAUDE.md at the start of every session| Type | Scope | Location |
|---|---|---|
| User | All projects | ~/.claude/CLAUDE.md |
| Project | Current repo | ./CLAUDE.md |
| Folder | Subdirectory | ./src/CLAUDE.md |
| User-Project | Per user per repo | .claude/local/CLAUDE.md |
> 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."
Claude Code has deep Git integration — it can commit, branch, create PRs, and review code following your project's conventions.
# 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.
# 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.
--no-verify)git add -AOne of Claude Code's strongest capabilities: coordinated edits across many files in a single operation.
> 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.
While Claude Code is terminal-native, it integrates with popular IDEs for a seamless workflow.
Ctrl+Shift+`# Install extension
code --install-extension anthropic.claude-code
Install from the JetBrains Marketplace or search "Claude Code" in plugin settings.
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.
| Scope | Path |
|---|---|
| User | ~/.claude/settings.json |
| Project | .claude/settings.json |
| Local (gitignored) | .claude/settings.local.json |
{
"model": "claude-sonnet-4-20250514",
"permissions": {
"allow": ["Bash(npm *)"],
"deny": ["Bash(rm *)"]
},
"hooks": { ... },
"mcpServers": { ... },
"customCommands": { ... }
}
| Variable | Purpose |
|---|---|
ANTHROPIC_API_KEY | API authentication |
CLAUDE_MODEL | Override default model |
CLAUDE_CODE_USE_BEDROCK | Use AWS Bedrock |
CLAUDE_CODE_USE_VERTEX | Use Google Vertex |
CLAUDE_CODE_USE_AZURE | Use Microsoft Azure AI Foundry |
ANTHROPIC_BASE_URL | Custom API endpoint |
CLAUDE_CODE_MAX_TURNS | Limit agent turns |
# 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
| Problem | Solution |
|---|---|
| Authentication errors | Run claude login or check API key |
| Slow responses | Use /compact to reduce context |
| Wrong file edits | Be more specific in your prompt |
| Context too long | /clear to reset, or /compact |
| Tool permission denied | Check /permissions |
| MCP server fails | claude mcp list to debug |
# Diagnose configuration issues
/doctor
# Checks:
# - Node.js version
# - Authentication status
# - MCP server connectivity
# - Settings file validity
# Enable verbose output
claude --verbose
# Debug logging
CLAUDE_CODE_DEBUG=1 claude
# View conversation log
# (stored in ~/.claude/logs/)
Claude Code never makes changes it can't undo. Use git diff to review changes and git checkout to revert if needed.
Run multiple Claude Code instances in parallel, isolated environments using 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
# 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.
> 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
> 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
> /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
> 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
/compact regularly on long sessions/clear for unrelated tasks/cost to monitor token usagenpm test 2>&1 | claude -p "fix"Escape for multi-line input mode/commands for repeated tasks--json for scripting integrationgit diffClaude Code transforms software development by bringing agentic AI capabilities directly into your terminal workflow.
Get started:
curl -fsSL https://claude.ai/install.sh | sh && cd your-project && claude
Anthropic Claude Series — Presentation 4 of 10
Next: API & SDK