Getting Started with Claude Code

You have a project on GitHub and a Next.js app running locally. Now it's time to bring AI assistance directly into your development workflow. This chapter walks you through installing Claude Code, authenticating it, and using it to build features, fix bugs, and understand your codebase — all from your terminal or VS Code.

Claude Code is fundamentally different from a chatbot. It reads your actual files, makes real edits, runs commands, and works across your entire project — not just on a snippet of code you paste in. By the end of this chapter, you'll know how to give it tasks and use it effectively without losing control of what it produces.

What Is Claude Code?#

Claude Code is an AI coding agent made by Anthropic. You install it on your machine, and it operates locally: it can read and edit your files, run terminal commands, create Git commits, and work across multiple files at once.

Here's what makes it different from simply chatting with an AI:

CapabilityCopy-paste chatbotClaude Code
Reads your filesNo — you paste code manuallyYes — reads your entire project
Edits files directlyNo — you copy output backYes — writes changes to disk
Runs commandsNoYes — npm run build, git commit, tests, etc.
Works across filesNo — one snippet at a timeYes — refactors across many files simultaneously
Remembers project contextNo — starts fresh each timeYes — via CLAUDE.md and session history

Claude Code is particularly useful for:

  • Building features — describe what you want, and Claude writes the code across all the files it needs to touch
  • Fixing bugs — paste an error message and let Claude trace through your codebase to find the root cause
  • Understanding code — ask "how does authentication work in this project?" and get an accurate answer grounded in your actual code
  • Automating routine tasks — writing tests, updating dependencies, generating Git commit messages

Step 1: Install Claude Code#

Install#

The recommended way to install Claude Code is with the native installer, which handles updates automatically in the background. For the full official guide, see the Claude Code Quickstart.

macOS and Linux:

curl -fsSL https://claude.ai/install.sh | bash

Windows (PowerShell):

irm https://claude.ai/install.ps1 | iex

Windows (Command Prompt):

curl -fsSL https://claude.ai/install.cmd -o install.cmd && install.cmd && del install.cmd

Alternative: npm

If you prefer to install via npm (requires Node.js 18+):

npm install -g @anthropic-ai/claude-code

Note: The npm installation method still works but is deprecated — Anthropic recommends the native installer above because it manages updates automatically. Also, never install with sudo; doing so can cause file permission problems that are difficult to fix.

Verify the Installation#

After installing, open a new terminal window and confirm that Claude Code is available:

claude --version

You should see a version number printed. If you see "command not found," close and reopen your terminal — the installer may need a fresh shell session to update your PATH.

For a more thorough check:

claude doctor

This command inspects your installation, verifies your authentication status, and reports any configuration issues.

Step 2: Install the VS Code Extension#

Claude Code also works as a VS Code extension, giving you AI assistance directly inside your editor.

Install from the Marketplace#

  1. Open VS Code
  2. Open the Extensions panel: Cmd+Shift+X (Mac) or Ctrl+Shift+X (Windows/Linux)
  3. Search for "Claude Code"
  4. Click Install on the extension by Anthropic

Once installed, open Claude Code inside the editor:

  1. Open the Command Palette: Cmd+Shift+P (Mac) or Ctrl+Shift+P (Windows/Linux)
  2. Type "Claude Code" and select Claude Code: Open in New Tab

The VS Code extension gives you everything the terminal version does, plus a few editor-specific features:

FeatureWhat it does
Inline diffsSee exactly what Claude changed before accepting it
@-mentionsReference a specific file or line directly in your prompt
Plan reviewReview Claude's planned approach before it executes any changes
Conversation historyBrowse and resume past sessions without leaving the editor

Tip: Whether you prefer the terminal or the VS Code extension is a matter of personal preference. Both use the same underlying Claude Code installation. Many developers use the terminal for running commands and the extension when actively editing code — you can switch between them freely.

Step 3: Authenticate#

Claude Code requires a paid Anthropic account. On first launch, it will open your browser and walk you through the login flow.

Authenticate via Browser#

Run the following command in your terminal:

claude

On first use, Claude Code will prompt you to log in. Follow the browser instructions to authenticate with your Anthropic account.

Account Requirements#

You need one of the following:

Account typeAccess
Claude ProPersonal use — included in the subscription
Claude MaxPersonal use with higher usage limits
Claude Teams / EnterpriseTeam use — additional features like shared sessions
Anthropic Console (API key)Direct API access — for developers building with the API

Note: A free Claude.ai account does not include Claude Code access. You need a paid subscription or an Anthropic Console account with API credits.

Using an API Key#

If you have an Anthropic API key (from the Anthropic Console), you can authenticate with it directly instead of going through the browser login:

export ANTHROPIC_API_KEY="sk-ant-..."
claude

Or pass it inline for a single session:

claude --api-key sk-ant-...

Check Your Authentication Status#

At any time, you can confirm you're logged in:

claude auth status

To log out:

claude auth logout

Step 4: Your First Session#

With Claude Code installed and authenticated, you're ready to start using it.

Start an Interactive Session#

Navigate to your project folder and launch Claude Code:

cd my-app
claude

You'll see a prompt where you can type tasks in plain English. Start simple to get a feel for how it works:

> What files are in this project?
> Explain what app/page.tsx does.
> Add a paragraph to the homepage that says "Built with Next.js and Claude Code."

Claude reads your files, makes the change, and shows you a diff. You can accept it, reject it, or ask for adjustments before anything is written to disk.

Single-Command Mode#

For quick one-off tasks, you can pass the prompt directly on the command line without entering an interactive session:

claude "explain the project structure"

Resume a Previous Session#

Claude Code saves your conversations. To pick up where you left off:

# Continue the most recent session in the current directory
claude -c

# Open an interactive picker to choose a session
claude --resume

Naming your sessions makes them easier to find later:

# Start a named session
claude --name "homepage-redesign"

# Resume it later by name
claude --resume homepage-redesign

Key Features#

File Editing#

When you ask Claude to make a change, it reads the relevant files, writes the new code, and shows you exactly what changed before applying it. You're always in control — you can accept, reject, or refine the changes.

> Refactor the fetchUser function to use async/await instead of .then()

Claude will find the function, rewrite it, and show you the diff.

Code Generation Across Multiple Files#

Unlike a chatbot where you paste in a snippet and get back another snippet, Claude Code can create or modify multiple files at once:

> Create a /api/contact route that accepts a POST request with name and email fields,
  validates the input, and returns a success or error response

Claude will create the API route file, handle the logic, and explain what it did — no copy-pasting required.

Running Commands#

Claude can run terminal commands on your behalf — starting the dev server, running tests, building the project, or executing scripts. It will ask for your permission before running anything that could have a significant effect.

> Run the tests and fix any failures

Claude runs the test suite, reads the output, identifies failures, and attempts to fix them — then reports back with what it changed.

Git Integration#

Claude Code understands Git and can handle the entire commit workflow:

> Stage my changes and write a good commit message
> Create a new branch called feature/dark-mode and commit my current changes to it

This fits naturally into the Git workflow you learned in the GitHub chapter — Claude handles the mechanics while you focus on the work itself.

Rendering diagram...

The CLAUDE.md File#

Every time you start a Claude Code session in your project, Claude reads a file called CLAUDE.md from the project root — if it exists. This file is how you give Claude persistent context about your project, so you don't have to re-explain things at the start of every session.

Why It Matters#

Without CLAUDE.md, Claude has to infer your project's structure and conventions from the code alone. With it, you can tell Claude exactly how your project is organized, what tools you use, and what rules to follow — so its suggestions are accurate and consistent from day one.

Here's an example CLAUDE.md for a Next.js project:

# My App — Claude Context

## Project Overview
A Next.js 15 web app with TypeScript, Tailwind CSS, and a PostgreSQL database via Prisma.

## Development Commands
- `npm run dev` — start the development server
- `npm run build` — build for production
- `npm test` — run the test suite
- `npx prisma migrate dev` — run database migrations

## Architecture
- `app/` — pages and API routes (App Router)
- `lib/` — shared utilities and business logic
- `components/` — React components
- `prisma/schema.prisma` — database schema

## Conventions
- Use TypeScript everywhere — no plain JavaScript files
- Use Server Components by default; add `'use client'` only when needed
- API keys and secrets go in `.env.local`, never hardcoded
- Commit messages should be short and describe what changed and why

## Code Style
- Use Tailwind CSS for styling
- Import paths use the `@/` alias from the project root

What to Include in CLAUDE.md#

SectionWhat to write
Project overviewOne or two sentences describing what the project does and what tech stack it uses
Development commandsThe exact commands to run the dev server, tests, build, and any other scripts Claude might need
ArchitectureWhat the key folders contain — helps Claude know where to look for things
ConventionsNaming conventions, preferred patterns, and rules your team follows
Code styleCSS approach, import patterns, formatting rules

The more relevant context you put in CLAUDE.md, the more accurate and consistent Claude's output will be — and the less you'll need to repeat yourself across sessions.

Commit CLAUDE.md to Git: This file belongs in your repository. Committing it means everyone on your team benefits from the same Claude behavior, and Claude picks it up automatically in any environment.

Slash Commands and Permissions#

While in an interactive Claude Code session, you can use slash commands to control the session and adjust its behavior.

Slash Commands#

CommandWhat it does
/helpShow a list of available commands and how to use them
/clearClear the conversation history and start fresh — useful when switching to a different task
/compactSummarize the conversation history to save space when a session gets long
/renameGive the current session a name so you can find and resume it later
/resumeSwitch to a different saved session
/configOpen Claude Code settings — update channels, display preferences, etc.

Permission Modes#

When Claude wants to run a command or make a change that could have side effects — deleting a file, pushing to Git, modifying a database — it stops and asks for your approval first. This is intentional: you are always the final decision-maker.

You can control how often Claude asks for permission by switching modes. Press Shift+Tab during an interactive session to cycle through the available options:

ModeBehavior
DefaultClaude asks before running any tool or executing a command — the safest option for beginners
Accept EditsClaude automatically applies file edits without prompting, but still asks before running commands
PlanClaude describes its entire plan before taking any action — useful for reviewing its approach upfront
Bypass PermissionsClaude runs everything without asking — use with caution

For beginners, stick with the default mode. You'll see exactly what Claude intends to do before it does anything, which keeps you in control and helps you learn how it works.

When Claude asks for permission: Read the proposed action carefully. If it looks right, type yes or press Enter to approve. If you're unsure, type no — Claude will either offer an alternative approach or explain its reasoning. You can always ask it to clarify before approving.

Tips for Writing Effective Prompts#

Claude Code understands plain English, but the quality of your prompts has a direct impact on the quality of the output. Here are the most useful habits to build:

Be Specific About What You Want#

Vague prompts produce vague results. The more specific you are, the better Claude can help:

Less effectiveMore effective
"Fix the bug""The login form shows a blank screen after submitting. Fix it."
"Add a feature""Add a dark mode toggle to the navbar that saves the preference to localStorage"
"Help with tests""Write unit tests for the validateEmail function in lib/utils.ts"

Include Error Messages When Debugging#

When something breaks, paste the full error output. Claude traces through your codebase to find the root cause — the more information it has, the more accurately it can diagnose the problem:

> I'm getting this error when I run npm run build:
  Error: Cannot find module '@/lib/auth'
  at Object.<anonymous> (/Users/me/my-app/app/api/user/route.ts:1:18)

Break Large Tasks Into Steps#

For complex changes, describe the steps explicitly. Claude works through them in order and completes each one before moving to the next:

> Create a contact form page at /contact that:
  1. Shows fields for name, email, and message
  2. Sends the form data to /api/contact on submit
  3. Displays a success message after submission

Ask Claude to Explain Its Plan First#

Before letting Claude make a large change, ask it to walk you through what it intends to do:

> Before you make any changes, explain your plan for refactoring the auth module

This is especially valuable for complex changes. If the plan looks off, you can redirect Claude before any code is touched.

Iterate — Don't Expect Perfection on the First Try#

Claude Code works best as a back-and-forth conversation. If the first result isn't quite right, say so:

> The form looks good, but I want the submit button to be blue, not green. Also,
  can you add validation so the email field requires a valid email address?

You don't have to start over — just describe what needs to change and Claude will continue from where it left off.

Review Every Change#

This is the most important habit for beginners: always read the diff before accepting a change. Claude is highly capable, but it can make mistakes — especially in parts of the codebase it hasn't encountered before. The Git workflow you already know is perfect for this: every edit is visible, and anything that doesn't look right can be reverted.

A healthy workflow looks like this:

# Let Claude work
claude "add a user profile page at /profile"

# Review what it changed
git diff

# If it looks good, commit
git add .
git commit -m "Add user profile page"

# If something is wrong, revert
git checkout .

The combination of Claude Code and Git gives you the best of both worlds: fast AI-assisted development with a complete safety net.

That said, reviewing AI-generated code in practice is more nuanced than it sounds. When Claude generates a large batch of changes — say, a pull request that touches dozens of files — line-by-line review becomes genuinely difficult. Many developers find themselves skimming rather than reading carefully, and some go a step further: they let Claude Code review its own output, asking it to check for bugs, security issues, or style violations before merging.

Whether this is the right approach is still an open debate in the developer community. The optimistic view is that AI-assisted review is better than rushed human review — Claude is thorough and doesn't get fatigued. The skeptical view is that an AI reviewing its own work is unlikely to catch its own blind spots, and that human judgment remains essential for understanding whether the code actually does what the product needs.

For now, the practical middle ground most teams land on: keep individual changes small enough to review meaningfully, use Claude to help with the mechanics of review (spotting obvious errors, checking edge cases), and reserve your own attention for the decisions that matter — overall structure, correctness of the logic, and anything security-sensitive.

Summary#

TopicKey Point
What it isAn AI coding agent that reads your files, edits code, and runs commands — not just a chatbot
Installcurl -fsSL https://claude.ai/install.sh | bash (Mac/Linux) or native installer (Windows)
VS Code extensionSearch 'Claude Code' in the Extensions panel; open with Cmd/Ctrl+Shift+P → 'Claude Code'
AuthenticateRun claude; browser login on first use. Requires a paid plan or API key.
Start a sessionclaude in your project folder — describe tasks in plain English
Single commandclaude "describe the task" for a quick one-off query
Resume sessionsclaude -c (most recent) or claude --resume (picker); use --name to label sessions
CLAUDE.mdA markdown file in your project root that gives Claude persistent context — commit it to Git
Slash commands/help, /clear, /compact, /rename, /resume, /config
PermissionsPress Shift+Tab to cycle modes; default mode asks before every action — recommended for beginners
Effective promptsBe specific, include error messages, break large tasks into steps, always review the diff

Quick Command Reference#

claude                         # Start an interactive session
claude "describe the task"     # Single-command mode
claude -c                      # Continue the most recent session
claude --resume                # Pick a session to resume
claude --name "my-session"     # Start a named session
claude --version               # Check the installed version
claude doctor                  # Check installation and auth status
claude auth status             # Check authentication
claude auth logout             # Log out

You've now completed the Getting Started series. You have Git tracking your code on GitHub, a Next.js project running locally, and Claude Code integrated into your editor and terminal. That's a complete, modern development environment — the same foundation used to build real products. Start with something small: pick one feature you want to add to your Next.js app, open Claude Code, and describe it. The best way to get comfortable with AI-assisted development is to use it on real problems.