Last updated: February 2026
Claude Code Guide:Anthropic's Agentic Coding CLI
Claude Code is Anthropic's official command-line tool that turns Claude into an agentic coding assistant. It runs in your terminal, reads and writes files across your entire codebase, executes commands, manages git workflows, searches the web, and runs tests autonomously. It is powered by Claude Opus and Sonnet models and works with any programming language, framework, or editor.
I use Claude Code every day to build and maintain this site. This guide covers everything I have learned about making it work in a real development workflow.
What is Claude Code?
Claude Code is Anthropic's official agentic coding tool. It is a command-line interface (CLI) that runs directly in your terminal and gives Claude deep access to your development environment. Unlike chatbot-style AI assistants where you paste code snippets back and forth, Claude Code operates inside your project. It can read every file, understand the full architecture, make coordinated changes across dozens of files, run your test suite, and commit the results to git.
The word "agentic" matters here. Claude Code does not just answer questions about code. It takes action. Tell it to fix a bug and it will search your codebase, identify the problem, edit the relevant files, run the tests to verify the fix, and offer to commit the changes. Tell it to refactor a module and it will update every import, every test, and every reference across your project.
Under the hood, Claude Code is powered by Anthropic's Claude models. It uses Claude Sonnet for fast, routine operations and can escalate to Claude Opus for complex reasoning tasks that require deeper understanding of your codebase. It automatically chooses the right model for the task, though you can configure this.
I started using Claude Code to build and maintain PromptWritingStudio. Every page you see on this site, including this one, has been built or edited with Claude Code running alongside my workflow. It handles the tedious parts (creating boilerplate, updating imports, writing tests) so I can focus on the content and architecture decisions that actually matter.
How to Install Claude Code
Getting Claude Code running takes about five minutes. Here is the step-by-step process.
Install Node.js (if you do not have it)
Claude Code requires Node.js version 18 or higher. Check your version or install it from nodejs.org.
node --versionInstall Claude Code globally via npm
This installs the claude command globally so you can run it from any directory.
npm install -g @anthropic-ai/claude-codeSet up your API key or sign in
You have two options. Set an Anthropic API key as an environment variable, or sign in with your Claude Pro or Max subscription when prompted.
export ANTHROPIC_API_KEY=your-api-key-hereGet your API key from console.anthropic.com. Or skip this step and authenticate via your browser when you first launch Claude Code.
Navigate to your project and start Claude Code
Open your terminal, navigate to your project directory, and run the claude command. That is it. Claude Code will read your project structure and you can start giving it instructions.
cd your-project-directory
claudeTip: On your first run, Claude Code will ask for permission to access your project files and run commands. Accept these permissions so it can work effectively. You can always revoke permissions or adjust them later.
Key Features of Claude Code
Claude Code is not just a chatbot in your terminal. Here is what it can actually do, based on my daily experience using it.
Agentic Coding
This is the core capability. Claude Code does not just suggest code; it reads files, writes changes, searches your codebase, runs tests, and executes terminal commands autonomously. You describe what you want done, and it does the work. It reads files before editing them, searches for related code across the project, makes coordinated changes, and verifies the result.
When I ask it to fix a bug, it starts by reading the relevant files, traces the issue through the code, makes the fix, runs the test suite, and tells me if the tests pass. If they do not, it iterates on the fix. This loop of read, edit, test, repeat is what makes it agentic rather than just conversational.
Multi-File Editing Across Entire Codebases
Claude Code understands your project as a whole, not just individual files. It can rename a function and update every import, every test, and every reference across hundreds of files. It can refactor a component from JavaScript to TypeScript and update every file that uses it.
This is where it pulls ahead of copy-paste chatbot workflows. When I refactored the schema generation system for this site, Claude Code updated the generator functions, every page that imported them, and the corresponding tests in a single operation. Doing that manually would have taken an hour. It took three minutes.
Deep Git Integration
Claude Code treats git as a first-class citizen. It can create branches, stage specific files, write meaningful commit messages based on the actual changes, push to remotes, and create pull requests with detailed descriptions. It follows a safety protocol: it never force-pushes to main, prefers creating new commits over amending, and warns you before destructive operations.
My typical workflow: I make a series of changes with Claude Code, review the diff, then say "commit these changes." It writes a commit message that accurately describes what changed and why, stages the right files, and creates the commit. For pull requests, it generates a summary with bullet points based on the full commit history.
Terminal Command Execution
Claude Code can run any terminal command: npm install, running test suites, building your project, starting dev servers, linting, formatting, and more. It uses command output to inform its next steps. If a build fails, it reads the error, fixes the code, and tries again.
This is particularly powerful for debugging. When a test fails, Claude Code does not just read the test file. It runs the test, reads the failure output, traces the issue to the source, fixes it, and re-runs the test to confirm. That feedback loop makes it significantly more effective than a tool that cannot execute code.
Web Search for Documentation
Claude Code can search the web to look up current documentation, find solutions to specific errors, and research APIs. When it encounters a library it does not have training data about, or when documentation has changed since its training cutoff, it can look up the latest information. You can also give it URLs to fetch and read directly.
Plan Mode for Complex Tasks
For complex changes that affect many parts of your codebase, plan mode is invaluable. Instead of jumping straight into editing, Claude Code first creates a detailed plan: which files need to change, what the changes will be, and in what order. You review and approve the plan before any code is modified.
I use plan mode for anything that touches more than three or four files. It forces Claude Code to think through the full scope of changes before acting, which prevents the kind of half-finished refactors that can leave your codebase in a broken state.
Slash Commands
Claude Code includes built-in slash commands for common operations:
/helpShow available commands and usage information
/clearClear conversation history and start fresh
/compactCompress conversation context to save tokens
/commitStage and commit changes with an AI-generated message
/review-prReview a pull request with detailed feedback
/fastToggle faster output mode for quick operations
MCP Server Integration
Claude Code supports the Model Context Protocol (MCP), which allows you to connect it to external tools and data sources. MCP servers can give Claude Code access to databases, APIs, file systems, and custom tools. This makes it extensible beyond its built-in capabilities. If you have a custom internal tool or API, you can create an MCP server for it and Claude Code will use it naturally as part of its workflow.
IDE Integration (VS Code Extension)
While Claude Code is primarily a terminal tool, it also has a VS Code extension that brings the same capabilities into your editor. You get the agentic workflow, file editing, terminal execution, and git integration directly inside VS Code. The extension opens Claude Code in a panel within your editor, so you can see changes in real time without switching windows. For developers who prefer a visual IDE but want Claude Code's capabilities, this is the best of both worlds.
Background Agents and Parallel Task Execution
Claude Code can run tasks in the background while you continue working on other things. You can kick off a long-running operation like a large refactor or test suite, and Claude Code will notify you when it completes. For teams, this means multiple Claude Code instances can work on different parts of a project simultaneously. You can also spawn background agents for specific tasks, essentially running parallel AI-assisted development workstreams.
How to Use Claude Code Effectively
After months of daily use, here are the workflow practices that make the biggest difference.
Start with Clear, Specific Instructions
Vague instructions produce vague results. Instead of "fix the styles," say "fix the mobile layout on the pricing page where the cards overlap on screens narrower than 768px." The more context you provide about what is wrong and what you want, the better the output.
Include file paths when you know them. Mention the expected behavior. Describe the current behavior. Claude Code is smart, but it is not psychic. The same prompting principles that work with ChatGPT or Claude chat work here. Be specific, be clear, and provide context.
Use Plan Mode for Complex Changes
If a task touches more than a few files, ask Claude Code to plan first. Say "plan how you would add dark mode support to the entire application" before saying "do it." This gives you a chance to review the approach, catch potential issues, and refine the strategy before any code changes.
I have seen Claude Code go down the wrong path on complex refactors when it dives in without planning. Plan mode prevents that. It is the difference between a developer who thinks before coding and one who starts typing immediately.
Let It Read Before It Edits
Claude Code is designed to read files before modifying them. Do not fight this instinct. When it asks to read a file or search the codebase, let it. The more context it gathers, the better its edits will be.
If you are starting a new session and jumping into a complex task, consider opening with something like "read the key files in the authentication system so you understand the current architecture." Giving Claude Code time to understand the codebase before asking it to change things leads to better results.
Use CLAUDE.md for Project Context
Create a CLAUDE.md file in your project root. This is Claude Code's equivalent of onboarding documentation. Include your coding conventions, project architecture, common commands (how to run tests, how to build, how to deploy), and any quirks that are specific to your project.
# CLAUDE.md ## Project Overview Next.js site with Tailwind CSS, deployed on Vercel. ## Key Commands - npm run dev: Start dev server - npm run build: Production build - npm run test: Run test suite ## Conventions - Use functional components only - Tailwind for all styling (no CSS modules) - Brand colors: bg-[#1A1A1A], bg-[#FFDE59], bg-[#F9F9F9] - Import Layout from '../components/layout/Layout' ## Architecture - /pages: Next.js pages - /components: Reusable components - /lib: Utility functions and helpers
Claude Code reads this file automatically at the start of every session. It saves you from repeating the same context every time you start working.
Review Changes Before Committing
Claude Code will not commit changes unless you ask it to. Use this to your advantage. After it makes edits, review the diff. Run your dev server and check the result in the browser. Run your tests. Only then ask it to commit.
This is the same practice you would follow with a human developer. Claude Code is capable and fast, but it can make mistakes. A quick review catches issues before they enter your git history. Treat Claude Code like a skilled junior developer: trust the output, but always review.
Example Prompts and Commands
Here are real prompts I use with Claude Code. Copy any of them and adapt to your project.
Fix the authentication bug where users are logged out after refreshing the page
Add comprehensive unit tests for the user authentication module with at least 90% coverage
Refactor the components in src/components/dashboard/ from JavaScript to TypeScript with proper type definitions
Create a PR for the changes on this branch with a detailed description of what was changed and why
Explain the data flow in src/lib/api.js and how the caching layer works
Add a dark mode toggle to the settings page that persists the user preference in localStorage and applies it globally
Find and fix the performance bottleneck causing slow page loads on the /dashboard route
Update all outdated npm packages to their latest stable versions and fix any breaking changes
Pro tip: The best prompts for Claude Code are the same ones you would give a capable human developer. Describe the desired outcome, include relevant context, and mention any constraints. You do not need special prompt syntax or keywords.
Claude Code Pricing
Claude Code itself is free to install. The cost comes from the AI models powering it. You have two options.
Anthropic API (Pay As You Go)
Best for developers who want flexibility
- +Pay only for what you use, token by token
- +Claude Sonnet: ~$3 per million input tokens, ~$15 per million output tokens
- +Claude Opus: ~$15 per million input tokens, ~$75 per million output tokens
- +Typical daily use: $5 to $20 per month for moderate usage
- +Full control over spending with usage limits
Claude Pro / Max Subscription
Best for heavy daily users
- +Claude Pro: $20/month with generous usage limits
- +Claude Max: $100/month or $200/month for higher limits
- +No per-token billing; predictable monthly cost
- +Access to Claude Code plus the web chat interface
- +Authenticate via browser; no API key management
My experience: I use the API for flexibility. On a typical day of building pages and features for this site, I spend between $2 and $10 in API credits. Heavy refactoring days with Claude Opus can cost more, but those are also the days where Claude Code saves me the most time. The ROI is clear: hours of work compressed into minutes.
Claude Code vs Cursor vs GitHub Copilot
These tools serve different purposes. Here is how they compare across the features that matter.
| Feature | Claude Code | Cursor | GitHub Copilot |
|---|---|---|---|
| Type | Terminal CLI / agentic tool | AI-powered code editor (VS Code fork) | Inline code completion |
| Interface | Terminal (works with any editor) | Standalone IDE | Plugin for existing editors |
| Multi-file editing | Yes, entire codebase | Yes, with Composer | Limited (mostly single-file) |
| Git integration | Deep (commits, PRs, branches) | Basic | None |
| Terminal commands | Yes, runs any command | Limited | No |
| Autonomous agents | Yes (background agents) | Yes (Agent mode) | No |
| Plan mode | Yes | No (manual planning) | No |
| Web search | Yes | Yes (with @web) | No |
| MCP support | Yes (extensible) | Yes | No |
| Codebase search | Built-in grep/glob | Codebase indexing | Basic context window |
| Starting price | API usage (~$5-20/mo) or Claude Pro ($20/mo) | $20/mo (Pro) | $10/mo (Individual) |
| Best for | Complex refactors, git ops, terminal workflows | Daily coding with AI inline | Quick inline completions |
Bottom line: These tools are complementary, not competing. Many developers (including me) use Copilot for inline completions while typing, Cursor for visual editing sessions, and Claude Code for complex multi-file refactors, git operations, and tasks that require terminal execution. The right choice depends on the task at hand.
Who is Claude Code For?
Claude Code is built for people who ship code. Here is where it fits best.
Individual Developers
If you are a solo developer or freelancer, Claude Code is like having a senior engineer available 24/7. It handles the repetitive work (writing tests, updating dependencies, fixing lint errors) so you can focus on architecture and features. It is particularly valuable for solo developers who do not have a team to bounce ideas off of or delegate tedious tasks to.
Best for: full-stack developers, freelancers, indie hackers
Development Teams
For teams, Claude Code accelerates code reviews, automates pull request creation, and helps maintain consistency across a large codebase. Team members can use shared CLAUDE.md files to ensure Claude Code follows the same conventions. Background agents mean multiple tasks can run in parallel across different team members.
Best for: startup engineering teams, agencies, enterprise dev teams
Open Source Maintainers
Open source maintainers deal with a constant stream of issues, pull requests, and contributor questions. Claude Code can triage issues, review PRs, suggest fixes, update documentation, and manage releases. For maintainers who are stretched thin, it handles the operational overhead that burns people out.
Best for: library authors, framework maintainers, community project leads
Frequently Asked Questions
Common questions about Claude Code, answered from hands-on experience
Is Claude Code free to use?+
Claude Code itself is free to install via npm. However, you need either an Anthropic API key with credits or a Claude Pro ($20/month) or Claude Max ($100-200/month) subscription to power the AI behind it. API usage is billed per token, so costs depend on how much you use it. For light use, expect around $5-20 per month in API costs. Heavy daily usage with Opus models can run significantly higher.
What is the difference between Claude Code and Cursor?+
Claude Code runs entirely in your terminal and works with any editor or IDE. Cursor is a standalone code editor (forked from VS Code) with AI built into the interface. Claude Code is better if you prefer working in the terminal, need deep git integration, or want to use your existing editor. Cursor is better if you want a visual IDE with inline AI suggestions. Many developers use both: Cursor for active editing and Claude Code for complex refactors, git operations, and codebase-wide changes.
Does Claude Code work with any programming language?+
Yes. Claude Code works with any programming language or framework. It reads and writes files regardless of the language. It is particularly strong with JavaScript, TypeScript, Python, Rust, Go, Java, C++, Ruby, and PHP, but it can handle anything from Haskell to COBOL. The quality of output depends on how well the underlying Claude model was trained on that language.
Can Claude Code break my project?+
Claude Code can make destructive changes if you let it. It will ask for permission before running dangerous commands, and it follows a safety protocol for git operations (it won't force push to main without explicit permission, for example). That said, always use version control and review changes before committing. Claude Code works best when you treat it like a capable but fallible junior developer: trust but verify.
What is a CLAUDE.md file?+
CLAUDE.md is a special markdown file you place in your project root to give Claude Code persistent context about your project. It can include coding conventions, architecture decisions, common commands, and anything else Claude should know before making changes. Think of it as onboarding documentation for your AI pair programmer. Claude Code reads it automatically at the start of every session.
Can Claude Code create pull requests?+
Yes. Claude Code has deep git integration. It can stage changes, write commit messages, create branches, push to remotes, and open pull requests using the gh CLI. You can say 'create a PR for these changes' and it will handle the entire workflow, including writing a descriptive PR title and body based on the actual code changes.
How does Claude Code compare to GitHub Copilot?+
They serve different purposes. GitHub Copilot provides real-time inline code completions as you type in your editor. Claude Code is an agentic tool that can autonomously read your entire codebase, make multi-file changes, run tests, manage git, and execute terminal commands. Copilot is a typing assistant. Claude Code is closer to a pair programmer who can independently complete tasks. Many developers use both together.
What models does Claude Code use?+
Claude Code is powered by Anthropic's Claude models. It primarily uses Claude Sonnet for fast operations and Claude Opus for complex reasoning tasks. The specific model version updates automatically as Anthropic releases improvements. As of February 2026, it uses Claude Opus 4 for its most capable mode and Claude Sonnet 4 for standard operations.
Can Claude Code access the internet?+
Yes. Claude Code can perform web searches to look up documentation, find solutions to errors, and research APIs. It can also fetch content from URLs when you provide them. This is useful when you need it to reference current documentation or integrate with a new library it might not have training data about.
Is Claude Code safe for production codebases?+
Claude Code is designed for professional use on real codebases. It follows safety protocols including asking permission for destructive operations, never force-pushing without consent, and preferring new commits over amending existing ones. That said, you should always review its changes, run your test suite, and use proper code review practices. Anthropic uses Claude Code internally to build their own products.
More Claude Code Resources
Every guide, comparison, and calculator on this site for people working with Claude Code day-to-day.
Minimum Viable MCP Stack
Five MCP servers that pull their weight, with copy-paste .mcp.json.
Claude Pro vs Max vs API
Which Claude plan fits your usage — Pro, Max 5x, Max 20x, or API.
Claude Plan Picker
Interactive calculator — recommends the cheapest plan that fits your actual usage.
CLAUDE.md Playbook
How to write a CLAUDE.md that keeps Claude Code on-rails.
Claude Code Hooks Recipes
Working hook examples — pre-commit checks, telemetry, guardrails.
Skills vs MCP vs Hooks
When to use each extension point — and when to skip it.
Claude Code vs Cursor
Head-to-head on features, workflow, and price.
Cost Calculator: Claude Code vs Cursor
Monthly API + subscription cost at your usage.
Claude API Prompt Cost
Estimate the cost of a single Claude API call by model and token count.