Getting Started with Claude Code
/init generates your CLAUDE.md. From there — slash commands, /status, /model, and the habits that make Claude Code productive from day one.
The First Command: /init
cd your-project
claude
> /init/init inspects your project — reads your package.json, tsconfig, directory structure, framework conventions — and generates a CLAUDE.md file. This is the AI's onboarding document for your codebase.
What a generated CLAUDE.md looks like:
# Project Overview
A Next.js 15 e-commerce application with TypeScript.
## Tech Stack
- Next.js 15 (App Router)
- TypeScript (strict mode)
- Tailwind CSS
- Prisma + PostgreSQL
- Vitest for testing
## Project Structure
src/
app/ → Next.js App Router pages and layouts
components/ → Reusable UI components
lib/ → Utilities, database client, helpers
types/ → Shared TypeScript type definitions
## Common Commands
npm run dev → Development server
npm run test → Run test suite
npm run build → Production build
npm run lint → ESLint check
npx prisma studio → Database UI
## Notes
- Uses "@/" import alias for all imports
- Components follow naming convention...This generated file is a starting point, not a final product. Edit it. The AI can infer your stack and structure, but it can't know:
- Which patterns are intentional vs. historical accidents
- What decisions were made deliberately and should not be changed
- What the team tried and decided was wrong
- Your security constraints
- Domain-specific rules
Spend 10 minutes on it after generation. Time invested in CLAUDE.md compounds — every future session benefits.
Slash Commands Reference
/help → list all available commands
/status → context usage, current model, token count
/model → switch models mid-session
/init → (re)generate CLAUDE.md for this project
/compact → compress conversation history to save context
/exit → quit Claude Code/model — Switching Mid-Session
> /model haiku → fast and cheap for simple tasks
> /model sonnet → the default daily driver
> /model opus → maximum reasoning for hard problemsA pattern that works:
1. Use Sonnet to implement a feature
2. Hit a tricky bug that Sonnet misses multiple times
3. > /model opus
4. "Think hard: why doesn't this work?"
5. Opus figures it out
6. > /model sonnet ← switch back for the next taskDon't use Opus for everything. Use it surgically.
/status — Your Context Gauge
> /status
Model: claude-sonnet-4-6
Context: 24,108 / 200,000 tokens (12.1%)
Session: 47 minutesBefore starting a large task, check /status. If you're at 60% or higher, compact first or start a new session. You want enough context headroom to complete the work without running out mid-task.
Asking Questions vs. Making Changes
Claude Code does both, and the distinction matters.
> what does the auth module do? ← read-only, safe to start with
> how does this project handle sessions? ← read-only
> refactor the auth module ← makes changes
> implement Google OAuth ← makes changesA pattern worth building:
1. Ask questions first: understand what exists
2. Ask what would need to change for your goal
3. Review the AI's understanding
4. Then ask for the implementation> @src/auth/ explain how session management works here
> given that structure, what would I need to change to add
Google OAuth support?
> [after reviewing the plan] implement the Google OAuth flow
starting with the callback handlerThe AI's answer to the second question is your plan. The third message executes it. This prevents the most common failure mode: the AI implementing a solution that conflicts with patterns you didn't know existed.
Referencing Files
> @src/components/UserCard.tsx fix the TypeScript error
> @src/auth/ how does this module work?
> @package.json @tsconfig.json what TypeScript version and features are active?
> @src/ give me a high-level tour of the codebase structureUse @ to attach files and directories. Be specific about what's relevant to the task. Attaching @src/ for a task that only touches one file wastes context on everything else.
The First Session Checklist
A productive pattern for starting with Claude Code on any project:
1. Run /init → generates CLAUDE.md
2. Edit CLAUDE.md (10 minutes):
- Fix anything incorrect
- Add conventions the AI couldn't infer
- Add "do not" rules based on past mistakes
- Add your testing approach
3. Explore before touching:
> @src/ give me a high-level tour
> what's the most important thing I should understand
about this codebase before making changes?
4. Start small:
Not: "build the authentication system"
Yes: "add email format validation to the LoginForm component"
5. Review the output carefully
Read every changed line
6. Commit if it's good
git add -p → git commitWhat CLAUDE.md Actually Does
Every Claude Code session in your project opens by reading CLAUDE.md. It's the first thing in context. Everything in it shapes how the AI interprets your subsequent messages.
Without CLAUDE.md: the AI guesses your conventions from what it can see, defaulting to patterns from its training data.
With a good CLAUDE.md: it knows your stack, your conventions, what to avoid, and what you've already decided. You don't re-explain it session after session.
The compounding effect: a better CLAUDE.md makes every session better. Update it whenever:
- The AI does something wrong that a clear rule would have prevented
- You add a new library or change a pattern
- You make a decision that shouldn't be undone
One line in CLAUDE.md can prevent the same mistake from recurring indefinitely.
Keep reading
Enjoyed this? Get more like it.
Deep dives on system design, React, web development, and personal finance — straight to your inbox. Free, always.