Getting Started with Claude Code
What Is Claude Code
Claude Code is Anthropic's official AI-powered command-line interface for software engineering. It runs directly in your terminal and connects to Claude's frontier models to help you read, write, and refactor code, run shell commands, manage git workflows, and orchestrate complex multi-file changes across your entire codebase. Unlike browser-based AI assistants where you copy-paste snippets back and forth, Claude Code operates natively inside your project directory. It sees your file tree, understands your project structure, and can execute real commands with real consequences.
Think of it as a senior engineer sitting in your terminal who can read every file in your project, run your test suite, search through documentation, and make precise edits -- all while asking your permission before doing anything destructive.
Installation
Claude Code requires Node.js version 18 or higher. If you do not have Node.js installed, grab it from nodejs.org or use a version manager like nvm. Once Node.js is ready, install Claude Code globally:
npm install -g @anthropic-ai/claude-code
Verify the installation:
claude --version
You will also need an Anthropic API key. Set it as an environment variable or let Claude Code prompt you on first launch:
export ANTHROPIC_API_KEY=sk-ant-your-key-here
On Windows, use your system environment variables or set it in your shell profile. Claude Code also supports Amazon Bedrock and Google Vertex AI as alternative model providers if your organization requires them.
Your First Launch
Navigate to any project directory and type:
claude
This starts an interactive REPL session. Claude loads context about your project -- reading your file tree, any CLAUDE.md files, and relevant configuration -- then waits for your instructions. You will see a prompt where you can type natural language requests.
For one-shot queries without entering interactive mode, use print mode:
claude -p "Explain what this project does based on the README and package.json"
Print mode sends your prompt, gets a response, and exits. It is perfect for scripting and quick lookups.
Understanding the Interface
When you interact with Claude Code, you will notice several distinct elements in the output. Tool calls appear when Claude decides to use a capability -- reading a file, running a command, writing code. Each tool call is displayed with what it is doing and its result. Permission prompts appear before potentially impactful actions. Claude will ask you to approve file writes, command execution, and other operations before proceeding.
Try this as your first interaction:
claude
> Explain the structure of this project and list the main entry points
Claude will use file-reading tools to scan your project, then summarize what it finds. Watch the tool calls scroll by -- each one shows you exactly what Claude is doing.
Key Command-Line Flags
Claude Code accepts several flags that control its behavior:
# Use a specific model
claude --model claude-sonnet-4-20250514
# Set permission mode (more on this below)
claude --permission-mode acceptEdits
# Get structured JSON output (useful for scripting)
claude -p "List all TODO comments" --output-format json
# Limit the number of agentic turns
claude --max-turns 10
# Resume the most recent session
claude --resume
# Continue from a specific session
claude --resume <session-id>
The --output-format json flag is especially useful when piping Claude Code into other tools. It returns structured data you can parse with jq or feed into downstream scripts.
Your First Real Tasks
Start with low-risk, read-only tasks to build familiarity:
# Explain a specific file
claude -p "Explain what src/utils/auth.ts does, function by function"
# Find bugs
claude -p "Review src/api/handlers.py for potential bugs or edge cases"
# Generate a component
claude
> Create a React component called UserAvatar that takes a name and imageUrl prop,
> displays the image in a circle, and falls back to initials if no image is provided
For your first write operation, try something small and reversible:
claude
> Add JSDoc comments to all exported functions in src/utils/helpers.ts
Claude will show you the proposed changes, ask for permission to write the file, and apply them only after you approve.
The Permission System
The permission system is the most important safety feature in Claude Code. By default, Claude asks your explicit approval before writing files, running shell commands, or performing any action that modifies your system. This is intentional -- you should always understand what Claude is about to do before it does it.
When Claude wants to run a command or write a file, you will see a prompt like:
Claude wants to run: npm test
Allow? (y/n/always)
Choosing "y" allows it once. Choosing "always" tells Claude it can run that specific type of command without asking again for the rest of the session.
Permission Modes
Claude Code provides six permission modes that control how much autonomy Claude has. Choose the one that matches your comfort level:
default -- Claude asks permission for everything. File writes, shell commands, web requests -- all require approval. This is the safest mode and where every new user should start.
acceptEdits -- Claude can write and edit files freely but still asks before running shell commands. This is the sweet spot for most developers once you trust Claude's code output.
plan -- Claude creates a detailed plan and asks for approval before executing. Useful for complex tasks where you want to review the approach before any work begins.
auto -- Claude runs most operations without asking. It still respects a configurable deny list of dangerous commands. Use this for trusted, well-scoped tasks.
dontAsk -- Similar to auto but with even fewer prompts. Designed for headless and CI/CD environments.
bypassPermissions -- No permission checks at all. Only use this in fully sandboxed environments like containers or throwaway VMs.
Try this to see permission modes in action:
# Start with acceptEdits mode
claude --permission-mode acceptEdits
> Refactor the error handling in src/api/routes.ts to use a centralized error handler
You will notice Claude edits files without asking but still prompts you before running any commands.
Piping Input to Claude
Claude Code works well in Unix-style pipelines. You can pipe file contents, command output, or any text directly to Claude:
# Pipe a file for analysis
cat src/config.ts | claude -p "Are there any security issues in this configuration?"
# Pipe git diff for review
git diff HEAD~3 | claude -p "Summarize these changes and flag anything risky"
# Pipe test output for diagnosis
npm test 2>&1 | claude -p "Analyze these test failures and suggest fixes"
This pattern is powerful for integrating Claude Code into existing shell scripts and automation workflows.
Practical Tips for Beginners
Start every new project by running claude in the project root and asking Claude to explain the project structure. This builds Claude's context and gives you a quick orientation.
Use default permission mode for your first week. Once you develop a feel for what Claude does well, switch to acceptEdits for faster iteration. Keep auto mode reserved for tasks you have run before and fully trust.
If Claude makes a mistake, you can always undo. Claude Code creates conventional git commits, so git diff and git checkout are your safety net. Make sure your work is committed before starting large refactoring tasks.
Run /cost periodically to see how many tokens and how much money your session has consumed. This helps you develop intuition for which tasks are cheap and which are expensive.
Finally, be specific in your prompts. Instead of "fix the bugs," try "fix the null pointer exception in the handleUserLogin function in src/auth/login.ts that occurs when the user object has no email field." Specificity reduces wasted turns and gets you better results faster.