Agentic coding tools have crossed a threshold. They no longer just autocomplete a line or suggest a function name. They read your project, plan a sequence of edits, run tests, and loop until the task is done. Claude Code is Anthropic’s take on this pattern: a terminal-first CLI that connects directly to Claude’s API so you can hand off real engineering work.
This guide covers everything you need to go from zero to a productive first session, including the configuration details that the quick-start guides usually skip.
What Claude Code Actually Does
Before installing anything, it helps to have a clear mental model. Claude Code is an agent loop wrapped around a terminal. You give it a goal in plain language. It reads relevant files, writes a plan, makes edits, and can invoke shell commands and test runners to verify its own work. The loop continues until it believes the task is complete or it needs your input.
Under the hood every turn of that loop is a Claude API call. The model sees your conversation history, a representation of your file system (or the parts you allow), and the output of any tools it ran. The quality of the output depends heavily on which model you choose and how clearly you describe the task.
Prerequisites
- Node.js 18 or later. Claude Code ships as an npm package.
- An Anthropic API key. Create one at console.anthropic.com and store it. You will set it as the environment variable
ANTHROPIC_API_KEY. - A project to work on. A git repository is ideal. Claude Code respects
.gitignoreand uses git history as context when you ask it to.
Installation
Install the CLI globally so it is available in any project directory:
npm install -g @anthropic-ai/claude-codeVerify the installation:
claude --versionSet your API key. The recommended approach is a shell profile entry so the key is available in every session:
export ANTHROPIC_API_KEY="your-key-here"Add that line to ~/.zshrc, ~/.bashrc, or whichever profile your shell loads. Reload the profile or open a new terminal, then confirm the variable is set:
echo $ANTHROPIC_API_KEYYou should see your key. If not, check the profile file name and make sure you sourced it.
Choosing the Right Model
Claude Code defaults to a sensible model, but you can and should choose explicitly based on the task. Anthropic’s current lineup relevant to coding work:
- Claude Fable 5 (
claude-fable-5): The most capable model in the family. Best for complex refactors, architectural decisions, or tasks that require deep reasoning across a large codebase. It supports a 1M-token context window, which matters when you need the model to hold an entire large project in view. - Claude Opus 4.8 (
claude-opus-4-8): Strong reasoning with the same 1M-token context window. A solid choice for demanding multi-file tasks. - Claude Sonnet 4.6 (
claude-sonnet-4-6): Fast and capable with a 1M-token context window. A good default for most day-to-day coding sessions where you want speed without giving up quality. - Claude Haiku 4.5 (
claude-haiku-4-5): The fastest and most economical option, with a 200K-token context window. Use it for quick lookups, simple one-file edits, or when you are iterating rapidly on small changes.
You can set the model with a flag at invocation time or configure it as a default in your project settings file. Check the CLI documentation for the exact flag name, as CLI flags can change between releases.
Your First Session
Navigate to your project root and start a session:
cd my-project
claudeYou will land in an interactive prompt. Try something concrete rather than open-ended for your first task. Open-ended prompts like “improve my code” give the agent nowhere to start. Specific prompts give it a clear finish line.
A good first prompt might be:
Add input validation to the `createUser` function in src/users.ts.
It should reject empty strings for name and email, and reject email
addresses that do not contain an @ symbol. Add corresponding unit
tests in src/users.test.ts.Watch what happens. The agent will read the relevant files, describe what it plans to do, and then make the edits. It may run the test suite to confirm its work. You can intervene at any point by responding in the chat.
Adaptive Thinking: When and Why to Enable It
On Claude 4.6 and later models, Anthropic introduced adaptive thinking. Instead of a fixed reasoning budget, the model dynamically adjusts how much internal chain-of-thought reasoning it applies based on task complexity. Simpler tasks get less overhead; harder tasks get more.
When you are working through the API directly (rather than the CLI), you enable this with:
thinking: { type: "adaptive" }The older budget_tokens approach is no longer used on these models. If you are building tooling on top of the API or customizing Claude Code’s behavior programmatically using the anthropic Python SDK or the @anthropic-ai/sdk TypeScript SDK, use the adaptive form and do not set a fixed token budget.
For most Claude Code sessions you do not configure thinking directly. The CLI handles it. But knowing what is happening underneath helps you understand why the model sometimes takes a few extra seconds before responding on harder problems.
Habits That Make AI Pair-Programming Pay Off
The tool is only as good as how you use it. These habits separate productive sessions from frustrating ones.
Work in small, reviewable chunks
Resist the temptation to hand off a massive task and walk away. Instead, break work into pieces you can review in five minutes. “Refactor the entire authentication module” is a recipe for a long agent run that produces a diff you cannot sanity-check. “Extract the token validation logic into a standalone function with tests” is a task you can review and merge in ten minutes.
Commit before every session
Always start with a clean working tree. If the agent goes sideways, you want a single git checkout . to undo everything cleanly. This habit also forces you to review what you already have before describing what you want next.
Be explicit about constraints
The model does not know your team’s style guide, your preferred test framework, or the fact that one particular file must not be touched. State these constraints upfront in your prompt or in a project-level configuration file that the CLI loads at startup. Many teams maintain a CLAUDE.md file in the project root with standing instructions: coding conventions, files that are off-limits, commands to run for tests, and context about the architecture.
Read the diff before you accept it
Every edit the agent proposes is a diff. Read it. You are still the engineer. The agent can introduce subtle logic errors that look plausible at a glance, especially in complex conditional logic or security-sensitive code. Your job in a paired session is to think at the design and correctness level while the agent handles the mechanical work.
Use MCP to extend what the agent can see
Model Context Protocol is an open standard for connecting AI models to external tools and data sources. Claude Code supports MCP servers, which means you can give the agent access to your database schema, internal API documentation, issue tracker, or any other structured data source, without pasting that information into every prompt. Setting up an MCP server for your most common reference data pays back quickly in sessions that no longer start with three paragraphs of context-setting.
Troubleshooting Common Early Problems
- Authentication errors: Double-check that
ANTHROPIC_API_KEYis exported (not just set) in your shell environment. Runenv | grep ANTHROPICto confirm. - The agent edits the wrong files: Add an explicit list of in-scope files or directories to your prompt. You can also use the project configuration to mark certain paths as read-only.
- Responses feel slow: On large codebases, the agent reads a lot before acting. If speed matters more than depth, switch to
claude-haiku-4-5for the session, or scope your task to a smaller directory. - The agent loops without making progress: Interrupt the session and rephrase. Sometimes a task description is ambiguous in a way that is invisible to you but paralyzing for the model. Adding a concrete example of the desired output usually breaks the loop.
Takeaway
Getting value from an agentic coding tool is less about the tool and more about developing a new working style. Install it, point it at a real project, and tackle something concrete in your first session. The engineers who get the most out of Claude Code treat it the way they would treat a capable junior developer: they give clear instructions, review every change, and build shared context over time through project-level documentation. Start there, and the speed gains follow naturally.
