Claude Code is Anthropic's agentic command-line tool that brings the full power of Claude directly into your terminal. Unlike chat-based interfaces where you copy and paste code snippets back and forth, Claude Code operates inside your project directory. It can read your files, edit your source code, run shell commands, search across your entire codebase, and execute multi-step tasks — all without leaving the terminal. Think of it less as a chatbot and more as a pair programmer sitting at your keyboard.
This article walks you through everything you need to go from zero to productive with Claude Code: installation, authentication, your first interaction, key commands, project memory, and a real-world walkthrough of using it on an actual task.
Installation
Claude Code is distributed as an npm package. You will need Node.js 18 or later installed on your machine. If you already have Node set up, installation is a single command:
npm install -g @anthropic-ai/claude-code
This installs the claude binary globally, making it available from any directory on your system. You can verify the installation succeeded by checking the version:
claude --version
If you see a version number printed to the terminal, you are ready to move on. If you encounter permission errors on macOS or Linux, you may need to prefix the install command with sudo or configure npm to use a directory you own.
Tip: If you prefer not to install globally, you can run Claude Code on demand with
npx @anthropic-ai/claude-code. This downloads and executes the latest version each time without permanently installing it.
Authentication and Configuration
The first time you launch Claude Code, it will guide you through authentication. Claude Code connects to the Anthropic API, so you need a valid way to authenticate. There are two primary options:
- Anthropic Console login — Claude Code can open your browser and walk you through an OAuth-style login flow tied to your Anthropic account. This is the simplest path if you have a Claude Pro or Team subscription.
- API key — If you have an Anthropic API key, you can set it as an environment variable before launching Claude Code.
To authenticate with an API key, export it in your shell before starting a session:
export ANTHROPIC_API_KEY="sk-ant-your-key-here"
claude
Once authenticated, Claude Code stores your session information locally so you do not need to re-authenticate every time. You can check your current authentication status at any point during a session.
Your First Project Interaction
Claude Code is designed to be launched from within a project directory. Navigate to the root of whatever codebase you want to work on, then simply type claude:
cd ~/projects/my-web-app
claude
When Claude Code starts, it immediately has awareness of your project's directory structure. You will see a clean terminal interface with a prompt where you can type natural language instructions. There is no special syntax — you talk to it the same way you would describe a task to a colleague.
Try something simple to start:
> What files are in this project and what does it do?
Claude Code will read your project's files, examine the directory tree, look at configuration files like package.json or pyproject.toml, and give you a summary of the project's structure and purpose. This is a great way to orient yourself in an unfamiliar codebase — or to verify that Claude Code has correctly understood your project.
Tip: Claude Code asks for your permission before running shell commands or writing to files. You can approve actions one at a time, or use the
--dangerously-skip-permissionsflag in trusted environments if you prefer a fully autonomous workflow.
Understanding the Terminal Interface
The Claude Code interface is intentionally minimal. Once running, you interact through a read-eval-print loop — you type a message, Claude processes it and takes actions, then waits for your next instruction. During execution, you will see real-time output showing what Claude Code is doing: which files it is reading, what commands it is running, and what edits it is making.
A few things to know about the interface:
- Multi-line input — Press
Shift+Enteror\at the end of a line to continue on the next line. - Interrupt — Press
Escapeto interrupt Claude while it is working, which is useful if it heads in the wrong direction. - Exit — Type
/exitor pressCtrl+Ctwice to leave the session. - History — Claude Code maintains conversation context throughout a session, so you can reference previous instructions and build on earlier work.
The interface also supports slash commands — built-in commands prefixed with / that control the tool itself rather than instructing Claude. Some of the most useful ones:
/help Show available commands
/clear Clear conversation history and start fresh
/compact Condense conversation to save context space
/cost Show token usage and estimated cost for the session
/init Generate a CLAUDE.md file for the project
Key Commands and Workflows
Beyond the interactive mode, Claude Code offers several ways to invoke it that fit different workflows:
One-shot mode
If you have a single task and do not need back-and-forth conversation, you can pass your prompt directly as an argument. Claude Code will execute the task and exit:
claude -p "Find all TODO comments in this project and list them by file"
This is perfect for scripting, CI/CD pipelines, or quick one-off questions about a codebase.
Piping input
Claude Code can read from stdin, making it composable with other Unix tools:
git diff --staged | claude -p "Review this diff for bugs and style issues"
This pipes your staged git changes directly into Claude Code for a code review — a powerful pattern that takes seconds to set up and can catch issues before they hit a pull request.
Resume a session
If you exit Claude Code and want to pick up where you left off, you can resume the most recent session:
claude --resume
This restores the full conversation history so you can continue a multi-step task without losing context.
CLAUDE.md and Project Memory
One of Claude Code's most valuable features is CLAUDE.md — a special Markdown file that lives in the root of your project and provides persistent context that Claude reads at the start of every session. Think of it as a briefing document: it tells Claude Code who your project is, how it is structured, what conventions to follow, and any rules it should respect.
You can generate an initial CLAUDE.md by running the /init command inside a Claude Code session, or create one manually. A practical CLAUDE.md might look like this:
# CLAUDE.md
## Project Overview
This is a Next.js 14 e-commerce application using TypeScript,
Tailwind CSS, and Prisma with a PostgreSQL database.
## Key Commands
- `npm run dev` — Start development server on port 3000
- `npm run test` — Run the Jest test suite
- `npm run lint` — Run ESLint across the project
## Conventions
- Use functional components with TypeScript interfaces, not `any`.
- All API routes live in `app/api/` using the App Router.
- Database queries go through Prisma; never write raw SQL.
- Commit messages follow Conventional Commits format.
## Architecture Notes
- Auth is handled by NextAuth.js with the Prisma adapter.
- State management uses React Context, not Redux.
- The `lib/` directory contains shared utilities and helpers.
With this file in place, every Claude Code session starts with a solid understanding of your stack, your patterns, and your preferences. You no longer need to repeat instructions like "we use TypeScript" or "run tests with Jest" — Claude already knows.
Tip: You can also place a CLAUDE.md in subdirectories to provide context that is specific to a particular module or package. Claude Code reads all CLAUDE.md files from the root down to your current working directory.
Practical Walkthrough: Adding a Feature
Let us put this all together with a real task. Suppose you have a Node.js API and you need to add a new endpoint that returns a health check response. Here is what the interaction might look like:
> Add a GET /api/health endpoint that returns a JSON response with
status "ok", the current server time, and the Node.js version.
Include a test for it.
Claude Code will typically proceed through a series of steps. First, it reads your project structure to understand where routes are defined. It examines existing endpoints to match your patterns and conventions. Then it creates the new route file, writes the handler, and generates a corresponding test file. Along the way, it may run your test suite to verify everything passes.
You might see output like this during execution:
Read file: src/routes/index.ts
Read file: src/routes/users.ts
Create file: src/routes/health.ts
Create file: tests/routes/health.test.ts
Run command: npm test
If the tests fail, Claude Code reads the error output, diagnoses the problem, and fixes it — often without you needing to say anything. This iterative loop of write, test, and fix is where agentic coding tools genuinely save time. Instead of manually toggling between your editor, terminal, and test output, Claude Code handles the full cycle.
After the task completes, you can review the changes:
> Show me a git diff of everything you changed
Claude Code will run git diff and walk you through the modifications, explaining what each change does and why it was made. If anything looks wrong, you can ask it to revise.
Where to Go from Here
You now have a fully functional Claude Code setup and an understanding of its core workflow. The real power emerges as you use it on larger, more complex tasks — refactoring modules, debugging production issues, migrating between frameworks, or writing comprehensive test suites across an entire project.
A few suggestions for building proficiency:
- Start with code exploration. Use Claude Code to understand unfamiliar codebases before you try to modify them. Asking questions about architecture and data flow is low-risk and high-value.
- Invest in your CLAUDE.md. The more context you provide upfront, the better Claude Code performs. Update it as your project evolves.
- Use the interrupt. If Claude Code starts heading in a direction you do not want, press Escape and redirect. Catching a wrong approach early saves tokens and time.
- Combine with git. Always work on a branch when letting Claude Code make changes. Review diffs before committing. This gives you a safety net and a clean audit trail.
In the next article, we will dive deep into context management — how Claude Code decides what information to include, how to keep your sessions efficient, and advanced techniques for guiding the model's attention across large codebases.