Your complete guide to getting the most out of Claude Code — Anthropic's AI coding assistant that lives in your terminal.
Whether you just installed Claude Code or you've been using it for months and want to level up, this guide has you covered. Think of it as the missing manual — written by a developer, for developers.
- What is Claude Code?
- Installation & First Steps
- The Auto-Setup Prompt
- CLAUDE.md & The Memory System
- Skills
- Custom Agents
- Hooks
- MCP Servers
- Plan Mode & Extended Thinking
- Session Management
- IDE Integrations
- Permissions & Security
- Headless Mode & CI/CD
- Tips & Best Practices
- Example Files
Claude Code is an agentic AI coding assistant that runs in your terminal. It can read your codebase, edit files, run commands, manage git operations, and much more — all through natural language. Unlike other AI coding tools, it has deep context awareness and can work with your entire project, not just individual files.
What makes it different:
- Terminal-native — works where you already work
- Agentic — it doesn't just suggest, it does
- Context-aware — understands your project structure, conventions, and history
- Customizable — memory files, skills, hooks, agents, and MCP servers let you tailor it to your workflow
npm install -g @anthropic-ai/claude-codecd your-project
claudeThat's it. Claude will analyze your project and be ready to help. You can immediately start asking it to:
- Explain parts of your codebase
- Fix bugs
- Write new features
- Run tests
- Create git commits and PRs
- Refactor code
> What does this project do? Give me a high-level overview.
> Find all the API endpoints and list them.
> Run the tests and fix any failures.
> Create a commit with a good message for the staged changes.
Don't want to manually configure everything? We built a single prompt that analyzes your project and sets up everything automatically.
Just paste it into Claude Code and it will:
- Analyze your project (language, framework, structure, dependencies)
- Create an optimal
CLAUDE.mdwith project-specific instructions - Set up
.claude/rules/with language/framework rules - Create custom skills (commit, test, review, deploy)
- Configure hooks (auto-format, lint, test triggers)
- Recommend and set up MCP servers
- Create
.claude/settings.jsonwith optimal permissions - Update
.gitignorefor local files
It's the fastest way to go from zero to a fully configured Claude Code environment.
This is probably the single most impactful feature. CLAUDE.md files are persistent memory that Claude reads at the start of every conversation. Think of them as instructions that stick.
Claude loads memory files in a specific order, from broadest to most specific:
| File | Scope | Shared with team? | Use for |
|---|---|---|---|
~/.claude/CLAUDE.md |
All projects | No (your machine) | Personal preferences, global coding style |
CLAUDE.md (project root) |
This project | Yes (commit it) | Project conventions, architecture decisions, common commands |
CLAUDE.local.md (project root) |
This project | No (gitignored) | Your personal project notes, local paths, secrets |
folder/CLAUDE.md |
Subdirectory | Yes | Module-specific instructions |
Here's the thing — Claude Code reads this at the start of every conversation. So keep it focused on things that are always relevant:
# Project: My Awesome App
## Key Commands
- `npm run dev` — start dev server (port 3000)
- `npm test` — run tests (jest)
- `npm run lint` — eslint + prettier
## Architecture
- Next.js 14 with App Router
- PostgreSQL with Prisma ORM
- Auth via NextAuth.js
## Conventions
- Use `snake_case` for database columns, `camelCase` for JS/TS
- All API routes go in `app/api/`
- Tests live next to the files they test (e.g., `foo.test.ts`)
## Important Notes
- Never modify migration files directly — use `prisma migrate dev`
- The `lib/legacy/` folder is being deprecated — don't add new code thereYou can reference other files from CLAUDE.md:
@rules/typescript.md
@rules/api-standards.md
@docs/architecture.mdThis keeps your CLAUDE.md clean while still giving Claude access to detailed context.
- Keep it concise. Claude reads this every time. Don't dump your entire architecture doc here.
- Be specific. "Follow best practices" is useless. "Use Zod for all API input validation" is actionable.
- Update it. If Claude keeps making the same mistake, add a note about it.
- Use CLAUDE.local.md for personal stuff — your local database URL, your preferred branch names, etc.
See examples/CLAUDE.md.example and examples/CLAUDE.local.md.example for full templates.
Skills are reusable, invocable prompts that extend what Claude can do. Think of them as custom slash commands.
Skills live in .claude/skills/ and each skill is a folder with a SKILL.md file:
.claude/skills/
├── commit/
│ └── SKILL.md
├── review/
│ └── SKILL.md
└── test-runner/
└── SKILL.md
---
name: commit
description: Create a well-formatted commit
user_invocable: true
---
# Commit Skill
Analyze all staged changes and create a commit with a conventional commit message.
## Steps
1. Run `git diff --cached` to see staged changes
2. Analyze the nature of the changes
3. Generate a commit message following conventional commits format
4. Create the commitOnce created, you invoke skills with a slash command:
> /commit
> /review src/api/
> /test-runner --coverage
Skills can use frontmatter to configure behavior:
---
name: deploy
description: Deploy to staging or production
user_invocable: true
allowed_tools: ["Bash", "Read"]
---See the examples/skills/ directory for ready-to-use skill templates.
Custom agents are specialized personas you can create for specific tasks. They're like having team members with different expertise.
Create agents in .claude/agents/:
# Security Reviewer
You are a security-focused code reviewer. When reviewing code:
1. Check for OWASP Top 10 vulnerabilities
2. Look for hardcoded secrets or credentials
3. Verify input validation and sanitization
4. Check authentication and authorization logic
5. Review dependency versions for known CVEs
Always provide severity ratings (Critical/High/Medium/Low) for findings.For agents you want across all projects, put them in ~/.claude/agents/.
> @security-reviewer Review the changes in the last 3 commits
> @refactor-helper Clean up the user service module
See examples/agents/ for agent templates.
Hooks let you run shell commands automatically in response to Claude Code events. They're perfect for enforcing workflows and automating repetitive tasks.
| Event | When it fires |
|---|---|
PreToolUse |
Before a tool is executed |
PostToolUse |
After a tool execution completes |
Notification |
When Claude Code sends a notification |
Stop |
When Claude finishes a response turn |
SubagentStop |
When a subagent (Task tool) finishes |
Hooks are configured in .claude/settings.json or .claude/settings.local.json:
{
"hooks": {
"PostToolUse": [
{
"matcher": "Write|Edit",
"command": "npx prettier --write \"$CLAUDE_FILE_PATH\""
}
],
"Stop": [
{
"command": "echo 'Claude finished a response'"
}
]
}
}Auto-format after file changes:
{
"hooks": {
"PostToolUse": [
{
"matcher": "Write|Edit",
"command": "npx prettier --write \"$CLAUDE_FILE_PATH\""
}
]
}
}Run linter after edits:
{
"hooks": {
"PostToolUse": [
{
"matcher": "Write|Edit",
"command": "npx eslint --fix \"$CLAUDE_FILE_PATH\""
}
]
}
}Notify on completion:
{
"hooks": {
"Stop": [
{
"command": "osascript -e 'display notification \"Claude is done!\" with title \"Claude Code\"'"
}
]
}
}Hooks receive context through environment variables:
$CLAUDE_FILE_PATH— the file that was modified$CLAUDE_TOOL_NAME— the tool that was used$CLAUDE_TOOL_INPUT— JSON input to the tool$CLAUDE_TOOL_OUTPUT— JSON output from the tool
See examples/hooks.json.example for more hook configurations.
MCP (Model Context Protocol) servers extend Claude's capabilities by connecting it to external tools and data sources. Think of them as plugins.
MCP servers are configured in .claude/settings.json:
{
"mcpServers": {
"postgres": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-postgres", "postgresql://localhost:5432/mydb"]
},
"github": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"],
"env": {
"GITHUB_TOKEN": "your-token-here"
}
}
}
}| Server | What it does |
|---|---|
server-postgres |
Query and manage PostgreSQL databases |
server-github |
Enhanced GitHub operations |
server-filesystem |
Extended filesystem operations |
server-brave-search |
Web search capability |
server-puppeteer |
Browser automation |
server-slack |
Slack integration |
server-memory |
Persistent key-value memory |
server-sequential-thinking |
Enhanced reasoning capabilities |
serena |
IDE-like semantic code navigation and editing (symbol-level find, references, rename — 30+ languages) |
# Add a server interactively
claude mcp add postgres -- npx -y @modelcontextprotocol/server-postgres postgresql://localhost:5432/mydb
# List configured servers
claude mcp list
# Remove a server
claude mcp remove postgres
# Add Serena for IDE-like semantic code intelligence (uses uvx, not npx)
claude mcp add serena -- uvx --from git+https://github.com/oraios/serena serena start-mcp-serverSerena deserves a special mention. It's an MCP server that gives Claude IDE-like superpowers — symbol-level navigation, find references, rename across files, and more. Instead of grep-based searching, Claude can work at the semantic level, which dramatically improves accuracy on large codebases. It supports 30+ languages via language servers.
Best for: Large/complex projects, strongly-typed languages, heavy refactoring tasks.
Some servers support OAuth for authentication. Claude Code handles the OAuth flow automatically — just configure the server and it will prompt you to authenticate.
See examples/mcp.json.example for configuration examples.
When facing a complex task, ask Claude to plan before executing:
> Plan how you would refactor the authentication module
Or use the /plan command. In plan mode, Claude will:
- Analyze the relevant code
- Design an approach
- Present the plan for your approval
- Only proceed when you say go
This is invaluable for large changes where you want to review the approach first.
Claude can use extended thinking for complex reasoning tasks. This is especially useful when:
- Debugging tricky issues
- Designing architecture
- Working through complex logic
- Planning multi-step changes
You can enable it in settings or let Claude decide when to use it.
# Resume the most recent session
claude --resume
# List recent sessions
claude --sessions
# Resume a specific session
claude --resume <session-id>For parallel work, Claude Code works great with git worktrees:
# Create a worktree for a feature
git worktree add ../my-feature feature-branch
# Run Claude in the worktree
cd ../my-feature
claudeThis lets you have multiple Claude sessions working on different features simultaneously.
Claude automatically creates checkpoints as it works. If something goes wrong, you can ask it to revert to a previous checkpoint.
Claude Code integrates directly with VS Code. Features include:
- Status line showing Claude's current activity
- Code diagnostics from your editor available to Claude
- Direct file navigation from Claude's responses
Similar integration available for JetBrains IDEs (IntelliJ, WebStorm, PyCharm, etc.).
Claude Code works in any terminal. For the best experience, use a modern terminal that supports:
- 256 colors
- Unicode
- Mouse events (optional, for some UI features)
Claude Code asks for permission before:
- Running shell commands
- Writing or editing files
- Performing network operations
// .claude/settings.json (shared with team)
{
"permissions": {
"allow": [
"Read",
"Glob",
"Grep",
"Bash(npm run *)",
"Bash(npx prettier *)",
"Bash(git *)"
],
"deny": [
"Bash(rm -rf *)",
"Bash(sudo *)"
]
}
}// .claude/settings.local.json (personal, gitignored)
{
"permissions": {
"allow": [
"Bash(docker *)",
"Bash(kubectl *)"
]
}
}- Allow common read operations — no risk, saves time
- Allow project-specific commands — your test runner, linter, formatter
- Deny destructive commands —
rm -rf,sudo, anything that could cause real damage - Use local settings for personal tools — Docker, k8s, cloud CLI tools
See examples/settings.json.example and examples/settings.local.json.example.
Claude Code can run without human interaction, perfect for CI/CD pipelines.
# Run a single task
claude -p "Run the test suite and report results" --output-format json
# With a specific model
claude -p "Review the code for security issues" --model claude-sonnet-4-5-20250929
# From a file
claude -p "$(cat prompts/review.md)" --output-format jsonGitHub Actions — PR Review:
name: Claude Code Review
on: [pull_request]
jobs:
review:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: anthropics/claude-code-action@v1
with:
prompt: "Review this PR for bugs, security issues, and style problems."Pre-commit Hook:
#!/bin/bash
claude -p "Review the staged changes for issues. Output only if there are problems." \
--output-format texttext— plain text (default)json— structured JSON (great for parsing in CI)stream-json— streaming JSON events
Even a minimal one. It compounds over time as you add instructions Claude needs.
Don't configure manually — use the auto-setup prompt to bootstrap your configuration. You can always tweak it after.
# Bad
> Make the code better
# Good
> Refactor the UserService class to use dependency injection
> and add unit tests for the createUser method
Before refactoring a module or adding a complex feature, ask Claude to plan first. Review the plan, then execute.
Don't just ask Claude to write code — ask it to run the tests too. It can fix failures in real time.
If you do something regularly (commits, reviews, deployments), create a skill for it.
When you notice Claude making repeated mistakes, add a note. This file is your leverage.
Never put API keys or local paths in committed files. Use CLAUDE.local.md and .claude/settings.local.json.
Need Claude to work on two features at once? Use git worktrees to give each task its own directory.
Claude is good, but always review its changes. Use git diff or your IDE's diff view before committing.
This repository includes ready-to-use example files:
| File | Description |
|---|---|
| CLAUDE.md.example | Project memory file template |
| CLAUDE.local.md.example | Local memory file template |
| settings.json.example | Shared settings template |
| settings.local.json.example | Local settings template |
| hooks.json.example | Hook configurations |
| mcp.json.example | MCP server configurations |
| skills/commit/ | Commit message skill |
| skills/review/ | Code review skill |
| skills/test-runner/ | Test runner skill |
| agents/security-reviewer.md | Security review agent |
| agents/refactor-helper.md | Refactoring agent |
| rules/typescript.md | TypeScript rules |
| rules/python.md | Python rules |
| rules/api-standards.md | API design rules |
Found something wrong or have a suggestion? Open an issue or PR. This guide is for the community.
Built with love and a lot of Claude Code sessions.