Back to Learn
Getting Started
18 min read

Getting the Most Out of Claude Code: The 2025 Playbook

clauderules.net

Install and First Session

Claude Code is a command-line tool you install globally with npm. Once installed, authenticate once and it works in any project directory.

bash
# Install Claude Code globally
npm install -g @anthropic/claude-code

# Authenticate (opens browser for login)
claude login

# Start a session in your project
cd /path/to/your/project
claude

On first run, Claude reads any existing CLAUDE.md files, then shows you a prompt. From here you can ask it to do anything: read code, write code, run commands, explain architecture, or fix bugs.

Your first session goal should be simple: ask Claude to summarize what your project does by reading the codebase. This verifies the setup and shows you how Claude understands your code before you put it to work.

Your First CLAUDE.md: The Highest-ROI Investment

A CLAUDE.md file in your project root is the single highest-return investment you can make with Claude Code. It gives Claude persistent knowledge of your project so you never have to re-explain your stack, conventions, or constraints.

Start simple. A minimal but effective CLAUDE.md for a new project:

CLAUDE.md
# Project Name

## What This Is
[One paragraph describing the project and its purpose]

## Tech Stack
- Runtime: Node.js 20, TypeScript 5.4 (strict mode)
- Framework: Next.js 15 App Router
- Database: PostgreSQL via Prisma ORM
- Styling: Tailwind CSS v4
- Auth: NextAuth.js v5

## Key Commands
- `npm run dev` — start development server
- `npm run build` — production build
- `npm test` — run test suite
- `npx prisma db push` — sync database schema

## Code Conventions
- Named exports everywhere (no default exports in lib/)
- No `any` in TypeScript — use `unknown` and narrow
- Prefer Server Components — add "use client" only when needed
- Zod validation at all API boundaries

## Important Constraints
- NEVER commit .env files
- NEVER modify prisma/schema.prisma without running `prisma db push` after
- ALWAYS run `npm run build` before saying a feature is complete

Add to this file as you discover patterns Claude gets wrong. Every correction you make manually is a candidate for a CLAUDE.md rule.

Keyboard Shortcuts That Matter

Escape

Interrupt Claude mid-response or mid-action

Enter

Submit your message

Shift + Enter

Add a newline without submitting

/clear

Clear context and start a fresh conversation

/compact

Summarize and compress context to free up token budget

/undo

Revert the last file edit Claude made

/help

List all available commands and skills

Up arrow

Browse previous messages you sent

The Power of /compact

Claude Code has a finite context window. Long sessions — especially ones involving many file reads — eventually hit the limit. When you see Claude's responses getting shorter or less precise, run /compact.

/compact asks Claude to summarize the conversation so far into a dense representation, then replaces the full history with that summary. This frees up tokens for continued work without losing the key context.

Use /compact proactively when: switching from a research phase to an implementation phase, after completing one feature before starting the next, or any time you notice context getting long.

Using MCP Servers for Richer Context

MCP (Model Context Protocol) servers give Claude access to external data sources and tools. Adding the right MCP servers dramatically expands what Claude can do autonomously.

The most impactful MCP servers for developers:

  • Filesystem — read/write files outside the current working directory
  • GitHub — read PRs, issues, and comments without copy-pasting
  • PostgreSQL or SQLite — query your database with natural language
  • Brave Search or Fetch — let Claude look up documentation it doesn't know
Browse clauderules.net/mcp for a curated directory of MCP servers with installation instructions.

The Plan → Implement → Verify Loop

The biggest mistake developers make with Claude Code: asking it to implement something complex without first reviewing a plan. Claude will dive in and make changes — sometimes the wrong changes — before you can redirect it.

The better workflow:

  1. Ask Claude to describe what it will do before doing it
  2. Review the plan and clarify any misunderstandings
  3. Say "go ahead" to execute
  4. Verify the result with a build or test run
prompt
# Example: Plan-first workflow
You: "I want to add email verification to the signup flow. Before making any changes, describe your plan."

Claude: "Here's what I'll do:
1. Add a verificationToken field to the User model in prisma/schema.prisma
2. Create an API route at /api/auth/verify-email that checks the token
3. Update the signup route to generate a token and send a verification email
4. Add a verification page at /verify-email/[token]
5. Block login for unverified users in the NextAuth callbacks

Shall I proceed?"

You: "Yes, but don't block login yet — we'll add that in a follow-up PR."

Claude: "Understood. I'll skip step 5. Starting now..."

Fixing Bugs Efficiently

Don't just paste an error and say "fix it." Give Claude the context to find the root cause, not just patch the symptom.

prompt
# Weak prompt
"This is broken: TypeError: Cannot read property 'id' of undefined. Fix it."

# Strong prompt
"I'm getting this error when I call the /api/users/[id] endpoint with a valid user ID:
TypeError: Cannot read property 'id' of undefined at line 24 of app/api/users/[id]/route.ts

The route fetches a user from the database and returns their profile. The error
only happens when the user doesn't have a profile record — they have a user record
but no associated Profile. Read the route file and the Prisma schema, identify
the root cause, and fix it without modifying the database schema."

Code Reviews with Claude

Claude Code is excellent at code review. You can pipe a git diff directly into a review prompt:

bash
# Review your staged changes
git diff --staged | claude "Review this diff for:
1. Security vulnerabilities
2. Performance issues
3. Missing error handling
4. TypeScript type safety
Cite specific line numbers."

# Review a specific file's changes
git diff HEAD~1 -- src/auth.ts | claude "What did I change in auth.ts and is anything concerning?"

Writing Tests

Writing tests with Claude is most effective when you give it specific requirements rather than asking for generic coverage:

prompt
Write unit tests for the validateUserInput function in lib/validation.ts.

Requirements:
- Use vitest (already configured in the project)
- Cover: valid input, null input, undefined input, empty string,
  string over 255 chars, special characters, SQL injection attempts
- Each test case should have a descriptive name
- Do not mock the function — test the real implementation
- Place tests in lib/__tests__/validation.test.ts

Advanced: Custom Slash Commands

Once you find yourself repeating the same prompt structure (code reviews, commit messages, documentation), turn it into a skill. Create a Markdown file in .claude/commands/ and invoke it with /command-name.

This gives your whole team access to standardized prompts that encode your best practices. Skills are version-controlled with your repository, so they improve over time along with your codebase.

Start with a /commit skill that generates commit messages following your team's format, and a /review skill for code reviews. These are the most commonly useful team skills.

Keeping Claude Focused

Claude Code gets better results with smaller, focused tasks. Large vague requests produce large vague results.

Break large features into steps. Instead of "add a full user management system," start with "add the user model and migration," then "add the list users API route," then "add the UI component."

One file, one concern. When debugging, point Claude at the specific file and line. When implementing, scope the change to one module at a time.

Use /clear between unrelated tasks. Starting a fresh context prevents earlier conversation from bleeding into new work in confusing ways.

Get the Claude Code Starter Pack

Top CLAUDE.md rules for Next.js, TypeScript, Python, Go, and React — delivered free to your inbox.