Claude Code & CLI Tools
Getting Started with Claude Code
Claude Code is Anthropic's official terminal-based AI coding assistant. If you live in the terminal, this is your tool.
Why Claude Code?
Claude Code excels when you:
- Prefer terminal over GUI
- Work with complex, multi-step tasks
- Need agentic capabilities (autonomous work)
- Want deep git integration
- Require MCP (Model Context Protocol) connections
Installation
Prerequisites
- Node.js 18+ installed
- npm or yarn
- Anthropic API key
Install Globally
npm install -g @anthropic-ai/claude-code
Verify Installation
claude --version
# Output: claude <version number>
First-Time Setup
Set your API key via environment variable:
export ANTHROPIC_API_KEY=your-key-here
Or add it to your shell profile (~/.zshrc or ~/.bashrc) to persist across sessions.
Basic Usage
Start an Interactive Session
cd your-project
claude
This opens an interactive REPL where you can chat with Claude about your code.
Single Command
claude "Explain what this project does"
With File Context
claude "Review this file for security issues" --file src/auth.ts
The Interface
┌─────────────────────────────────────────────────────────────┐
│ Claude Code │
│ Working directory: ~/projects/my-app │
│ Model: claude-sonnet-4-6 │
├─────────────────────────────────────────────────────────────┤
│ │
│ You: Create a utility function for date formatting │
│ │
│ Claude: I'll create a date formatting utility for you. │
│ │
│ [Creating file: src/utils/dateFormat.ts] │
│ │
│ ```typescript │
│ export function formatDate(date: Date): string { │
│ return date.toLocaleDateString('en-US', { │
│ year: 'numeric', │
│ month: 'long', │
│ day: 'numeric' │
│ }); │
│ } │
│ ``` │
│ │
│ [Apply changes? (y/n)] │
│ │
├─────────────────────────────────────────────────────────────┤
│ > _ │
└─────────────────────────────────────────────────────────────┘
Essential Commands
Slash Commands
| Command | Description |
|---|---|
/help |
Show available commands |
/clear |
Clear conversation history |
/model |
Change AI model |
/config |
View/edit configuration |
/review |
Review a pull request |
/memory |
View and manage memory files |
/cost |
Show API usage cost |
Keyboard Shortcuts
| Key | Action |
|---|---|
| Ctrl+C | Cancel current operation |
| Ctrl+D | Exit Claude Code |
| Up/Down | Navigate history |
| Tab | Autocomplete file names |
Configuration
Project-Level Configuration
Create a CLAUDE.md file in your project root to give Claude persistent instructions:
# Project Rules
- Use TypeScript for all new files
- Follow the existing code style
- Include JSDoc comments for public functions
- Run tests before committing
Settings File
Create .claude/settings.json in your project for tool permissions and settings:
{
"permissions": {
"allow": [
"Bash(git *)",
"Bash(npm *)",
"Read",
"Write",
"Edit"
]
}
}
Your First Task
Let's complete a real task:
Step 1: Navigate to Project
cd ~/my-project
Step 2: Start Claude Code
claude
Step 3: Ask Claude
Create a simple API endpoint that returns the server health status.
Include timestamp and memory usage.
Step 4: Review Changes
Claude will show you the proposed changes with diffs.
Step 5: Apply or Modify
- Type
yto apply all changes - Type
nto reject - Type
eto edit before applying
IDE Integration
VS Code Extension
- Install "Claude Code" from VS Code marketplace
- Press ⌘/Ctrl + Shift + P
- Type "Claude Code: Open Terminal"
- Claude Code runs in integrated terminal
JetBrains Integration
- Install "Claude Code" plugin
- Open Terminal panel
- Run
claudecommand
Comparison with Cursor
| Feature | Claude Code | Cursor |
|---|---|---|
| Interface | Terminal | GUI |
| Best for | Complex tasks, automation | Visual editing |
| Learning curve | Higher | Lower |
| Customization | Extensive | Moderate |
| Memory (CLAUDE.md) | Built-in | Manual |
| MCP Support | Native | Limited |
Use Both: Many developers use Cursor for daily coding and Claude Code for complex refactoring or automation tasks.
Troubleshooting
Command Not Found
# Ensure global npm bin is in PATH
export PATH="$PATH:$(npm bin -g)"
API Key Issues
# Verify key is set
echo $ANTHROPIC_API_KEY
# Test with simple command
claude "Say hello"
Model Selection
# Use a specific model for a session
claude --model claude-sonnet-4-6 "Your prompt"
Terminal Power: Claude Code gives you AI assistance without leaving your terminal workflow. In the next lesson, we'll explore the agentic features that make it uniquely powerful. :::