Skip to main content

Lesson 8: Claude Code Fundamentals

Topics Covered
  • Installing Claude Code and authenticating with your Anthropic account
  • Understanding the core tools: Read, Edit, Write, Bash, Glob, and Grep
  • Managing context and conversation memory across sessions
  • Choosing between CLI and IDE integration for different workflows
  • Tracking usage limits and optimizing for your plan
  • Building real workflows for code review, refactoring, and debugging

You've learned to call LLM APIs and build AI features. Now it's time to flip the script: instead of embedding AI in your apps, let AI drive your development workflow.

Claude Code is a CLI tool that brings Claude directly into your terminal and IDE, giving you an AI pair programmer that can read, edit, and execute across your entire codebase. In this lesson, you'll go from installation to productive workflows in minutes.

Installation & Setup

Claude Code works on macOS, Linux, and Windows. Installation takes less than a minute.

install.sh
# macOS/Linux (Homebrew)
brew install claude

# or using curl
curl -fsSL https://claude.ai/install.sh | sh

# Verify installation
claude --version

Once installed, authenticate with your Anthropic account:

authenticate.sh
# Opens your browser to authenticate
claude auth login

# Check your plan and limits
claude auth status

You'll see your plan (Free, Pro, Team) and usage limits. Pro users get higher monthly limits and priority access to new features.

Why CLI authentication matters

Unlike API keys that you embed in code, Claude Code uses OAuth to authenticate. This means you never handle raw credentials, and you can revoke access from the Anthropic dashboard anytime. It's the same security model as GitHub CLI or Vercel CLI.

Your First Session

Start Claude Code in any project directory:

start-session.sh
cd ~/projects/my-app
claude

You're now in an interactive session. Claude can see your current directory and maintain conversation context across multiple turns. Try a simple request:

You: Read the package.json file and tell me what this project does

Claude uses its Read tool to access the file, analyzes the dependencies, and explains the project. You didn't copy/paste anything—Claude autonomously grabbed what it needed.

Here's the key insight: Claude Code isn't a chatbot that requires you to feed it information. It's an autonomous agent that reads files, searches codebases, edits code, and runs commands based on your high-level requests.

Core Tools

Claude Code has specialized tools for different operations. Understanding when each tool is used helps you craft better requests.

Read Tool

The Read tool fetches file contents with line numbers:

You: Read src/index.js

Claude displays the file with numbered lines, making it easy to reference specific sections. The Read tool automatically handles large files (you can specify offset/limit for massive files) and works with images, PDFs, and Jupyter notebooks.

Edit Tool

The Edit tool performs exact string replacements:

You: In src/config.js, change API_URL from localhost to the production URL

Claude must read the file first (to know what to replace), then makes the change. It preserves formatting and indentation. Edits are preferred over rewrites because they keep your existing code intact.

Edit precision

Be specific about what to change. Instead of "update the config," say "change the timeout from 5000 to 10000 in src/config.js." This helps Claude make surgical edits without rewriting sections unnecessarily.

Write Tool

The Write tool creates new files or overwrites existing ones:

You: Create a new file src/utils/logger.js with a simple console logger

Use this sparingly. Claude prefers editing existing files because it maintains your project's style and structure.

Bash Tool

The Bash tool runs terminal commands:

You: Run the tests
Claude: [Executes: npm test]

You: Install the dotenv package
Claude: [Executes: npm install dotenv]

It handles git operations, package installations, and script execution. For long-running commands, Claude can use the run_in_background parameter to keep working while the command runs.

Glob Tool

The Glob tool finds files by pattern:

You: Find all TypeScript files in src/
Claude: [Uses Glob with pattern "src/**/*.ts"]

It's fast and returns files sorted by modification time. Use this when you need to locate files without knowing exact names.

Grep Tool

The Grep tool searches file contents with regex:

You: Search for all API endpoints in the codebase
Claude: [Uses Grep to find patterns like "app.get", "app.post"]

You can filter by file type, show context lines around matches, and use powerful regex patterns. It's built on ripgrep, so it's extremely fast even on large codebases.

Tool selection is automatic

You don't tell Claude which tool to use—it infers from your request. "Read the config file" triggers Read. "Find all TODO comments" triggers Grep. "Install dependencies" triggers Bash. This abstraction lets you focus on what you want, not how to get it.

Context & Memory

Claude Code maintains context across your entire conversation. Every file Claude reads, every tool result, and every exchange stays in memory.

Here's how context works:

  • Files you ask about are automatically added to context
  • Tool outputs (grep results, bash output) are preserved
  • Earlier conversation turns are summarized when context grows large
  • You effectively have unlimited context through automatic summarization

Best practice: Let Claude read files instead of pasting code. Instead of:

You: Here's my auth code: [pastes 500 lines]

Do this:

You: Analyze the authentication flow in src/auth/

Claude uses Glob to find relevant files, Read to access them, and analyzes the flow. You saved keystrokes, and Claude got properly formatted, line-numbered content.

Pro users get ~200K tokens of active context before summarization kicks in. That's enough for dozens of files and a long conversation.

CLI vs IDE Integration

Claude Code works in two modes: standalone CLI and IDE integration (VS Code, Cursor, etc.).

CLI Mode (the claude command):

  • Full terminal control and command execution
  • Great for project-wide tasks like refactoring or setup
  • Better for exploratory work ("what does this codebase do?")
  • Can run any bash command

IDE Integration:

  • Inline editing with visual diff previews
  • Quick file navigation and symbol lookup
  • Better for focused editing tasks
  • Integrated with your editor's UI

When to use CLI:

  • "Analyze this entire codebase and identify architecture issues"
  • "Set up CI/CD with GitHub Actions"
  • "Refactor all API calls to use the new client library"

When to use IDE:

  • "Fix this specific function"
  • "Add TypeScript types to this file"
  • "Explain what this component does"

Both modes use the same underlying model and tools. Choose based on the scope of your task.

Start with CLI for exploration

When working on an unfamiliar project, start with CLI mode. Once you've identified specific files to edit, switch to IDE mode for surgical changes. You get the best of both: broad context from CLI, precise editing from IDE.

Usage Tracking

Claude Code has usage limits based on your plan. Check your current usage anytime:

check-usage.sh
claude usage

This shows:

  • Current usage period (weekly for Free, monthly for Pro)
  • Requests used out of your total limit
  • Reset date for your limit
  • Current model (Sonnet 4.5 by default)

Usage tiers:

  • Free: Limited requests per week, good for experimentation
  • Pro: Higher monthly limits, priority access, faster responses
  • Team: Shared limits across team members, admin controls

Cost optimization tips:

  • Use focused prompts instead of "analyze everything"
  • Prefer Edit over Write (smaller context, surgical changes)
  • Let Claude use Grep to search instead of reading all files
  • For simple tasks, you can use the lighter haiku model via the Task tool

If you hit your limit, requests pause until the next reset period. Pro users rarely hit limits during normal development work.

Real Workflows

Let's put it all together with practical patterns you'll use daily.

Workflow 1: Code Review

You: Review the changes in my current branch for bugs and best practices

Claude uses git diff to see your changes, analyzes the code, and provides feedback on potential issues, style violations, or improvements. It's like having a senior developer rubber-duck your PRs.

Workflow 2: Refactoring

You: Refactor src/api/ to use async/await instead of promise chains

Claude reads all files in src/api/, identifies promise-based code, and systematically updates each file. It maintains error handling and preserves your logic while modernizing the syntax.

Workflow 3: Documentation

You: Add JSDoc comments to all exported functions in src/utils/

Claude finds all utility functions, infers parameter types and return values from usage, and adds proper JSDoc annotations. You get consistent documentation without manual typing.

Workflow 4: Debugging

You: The app crashes when uploading large files. Find the issue.

Claude searches for upload-related code, identifies buffer size limits or memory constraints, and suggests fixes. It can even implement the fix if you approve.

These workflows show Claude Code's strength: you describe the outcome, and it orchestrates the tools to get there.


Exercise 8: Your First Claude Code Workflow

1. Install and Authenticate

Install Claude Code using Homebrew or the install script, then authenticate:

setup.sh
brew install claude
claude auth login
claude auth status

Verify your plan appears and you have available usage.

2. Start a Session in a Project

Navigate to any project (or create a simple one with a package.json and a few .js files):

start.sh
cd ~/projects/sample-app
claude

3. Request a File Read

Ask Claude to read a specific file:

You: Read package.json and list all dependencies

Notice how Claude uses the Read tool and formats the output. You didn't provide the file contents—Claude accessed it autonomously.

4. Search for Patterns

Ask Claude to find something in your codebase:

You: Find all console.log statements in src/

Claude uses the Grep tool to search. Review the results—it should show file names and line numbers.

5. Make an Edit

Ask Claude to change something small:

You: In src/index.js, add a comment at the top that says "Main entry point"

Claude reads the file, makes the edit, and confirms. Open src/index.js in your editor to verify the change.

6. Run a Command

Ask Claude to execute a bash command:

You: Show the git status of this project

Claude runs git status and displays the output. This demonstrates the Bash tool in action.

7. Check Your Usage

Exit the Claude session (Ctrl+C or type exit), then check your usage:

usage.sh
claude usage

You should see that you've used a few requests from your limit.

Run through these steps and you'll have hands-on experience with every core tool: Read, Grep, Edit, Bash, and usage tracking.

Summary

Claude Code transforms your development workflow by bringing AI directly into your terminal and IDE. You've learned to install and authenticate, use the core tools (Read, Edit, Write, Bash, Glob, Grep), manage context automatically, and choose between CLI and IDE modes based on task scope.

The key mindset shift: don't feed Claude information—let it autonomously gather what it needs. This makes your requests faster, keeps context clean, and lets you focus on outcomes instead of mechanics.

With usage tracking, you can monitor your limits and optimize for your plan. With real workflows like code review, refactoring, and debugging, you're ready to integrate Claude Code into daily development.

Next: In Lesson 9, you'll learn to build autonomous agents that handle complex, multi-step workflows—like researching an API, planning integration, and implementing it with zero manual intervention.