How to Use Claude Code: The AI Coding Agent in Your Terminal

If you've ever wished you could just describe what you want to build and have an AI figure out how to implement it across your entire codebase, Claude Code is that tool. It's an agentic coding assistant from Anthropic that lives in your terminal, understands your project structure, and can read files, write code, run tests, and even create pull requests—all through natural language commands.

Unlike chat-based AI assistants where you copy and paste code snippets back and forth, Claude Code operates directly in your development environment. It sees your files, understands the relationships between them, and executes real changes. This makes it significantly more powerful for real-world development tasks, but it also requires a different mental model for how to work with it effectively.

This guide will show you how to install Claude Code, configure it for your workflow, and use it productively for everyday development tasks. We'll also cover how it integrates with DeployHQ for automated deployments.


Why Claude Code Matters for Web Developers

Traditional AI coding assistants work in isolation. You describe a problem, get a code snippet, paste it into your editor, and then manually handle all the integration work—imports, dependencies, related files that need updating. This context-switching slows you down and introduces errors.

Claude Code flips this model. When you ask it to add a feature or fix a bug, it searches your codebase to understand the existing patterns, identifies all the files that need to change, makes the edits, and can even run your tests to verify the changes work. You stay in flow while Claude handles the implementation details.

For web developers specifically, this means you can describe features at a higher level. Instead of writing out the exact controller method, view template, and route configuration, you can say "add a user profile page that shows their recent orders" and let Claude figure out how that fits into your existing application architecture.


Step 1: System Requirements

Before installing Claude Code, ensure your system meets these requirements:

Operating Systems: - macOS 10.15 or higher - Ubuntu 20.04+ or Debian 10+ - Windows 10+ (requires WSL 2 or Git Bash)

Hardware: - Minimum 4GB RAM (8GB recommended for larger codebases)

Software: - Node.js 18+ (only required for npm installation method) - Modern terminal (Bash, Zsh, Fish, or PowerShell)

Network: - Active internet connection for authentication and AI processing


Step 2: Install Claude Code

Claude Code offers two installation methods: the native installer (recommended) and npm. Choose the one that works best for your setup.

The native installer doesn't require Node.js and includes automatic updates.

macOS and Linux:

Open your terminal and run:

curl -fsSL https://claude.ai/install.sh | bash

This downloads and installs the latest stable release. To install a specific version:

curl -fsSL https://claude.ai/install.sh | bash -s 1.0.58

Windows (PowerShell):

Claude Code now supports native Windows installation. Open PowerShell and follow the prompts at claude.ai/download, or use WSL 2 for the best experience.

Option B: NPM Installation

If you prefer npm or need more control over the installation:

npm install -g @anthropic-ai/claude-code

Important: Do not use sudo with npm install. If you encounter permission errors, configure a user-level npm directory:

mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrc
source ~/.bashrc

Then retry the installation.

Verify the Installation

After installation, verify everything works:

claude --version

You should see a version number printed without errors.


Step 3: Configure Authentication

Claude Code requires authentication to connect to Claude's API. You have two options:

This is the simplest approach and works well for most developers.

  1. Navigate to your project directory
  2. Run claude
  3. Follow the OAuth prompts to connect through the Claude Console
  4. Complete the authentication in your browser

A "Claude Code" workspace will be automatically created in your console for usage tracking.

Option B: API Key

If you prefer to use an API key directly:

  1. Visit console.anthropic.com
  2. Create an account and navigate to API Keys
  3. Generate a new key (it will start with sk-)
  4. Set the environment variable:
export ANTHROPIC_API_KEY="sk-your-api-key-here"

Add this to your shell profile (.bashrc, .zshrc) to make it persistent:

echo 'export ANTHROPIC_API_KEY="sk-your-api-key-here"' >> ~/.zshrc
source ~/.zshrc

Understanding Costs

Claude Code charges based on API usage, which can add up quickly with complex tasks. Anthropic reports that average spend is around $6/day for active users. For regular use, a Claude Max subscription provides higher usage limits at a fixed monthly cost and may be more economical.


Step 4: Start Using Claude Code

Now that Claude Code is installed, let's walk through how to use it effectively.

Basic Workflow

Navigate to your project directory and launch Claude Code:

cd your-project
claude

You'll enter an interactive session where you can give natural language commands. Type your request, and Claude will analyze your codebase and take action.

Example Tasks

Understand a codebase: What does this project do? Explain the main architecture.

Add a feature: Add a user settings page where users can update their email and password. Follow the existing patterns in this codebase.

Fix a bug: Users are reporting that the checkout page crashes when their cart is empty. Find and fix this bug.

Refactor code: Refactor the UserController to use service objects instead of putting business logic in the controller.

Write tests: Write unit tests for the OrderProcessor class covering the main success and failure scenarios.

Using Thinking Modes

Claude Code supports different "thinking" levels for complex problems. Use these phrases to trigger deeper analysis:

  • think — Standard extended thinking
  • think hard — More thorough analysis
  • think harder — Even deeper consideration
  • ultrathink — Maximum thinking budget for the most complex problems

Example: Think hard about how to implement rate limiting across all our API endpoints without breaking existing functionality.


Step 5: Advanced Features

Slash Commands

Claude Code includes built-in slash commands for common operations:

  • /help — Show available commands
  • /clear — Clear the conversation context
  • /bug — Report an issue to Anthropic
  • /compact — Condense conversation history

Custom Commands

You can create custom slash commands for repeated workflows. Store prompt templates as Markdown files in .claude/commands/:

mkdir -p .claude/commands

Create a file like .claude/commands/review.md:

Review the most recent changes for:
- Security vulnerabilities
- Performance issues
- Code style consistency
- Missing tests

Provide specific, actionable feedback.

Now you can invoke this with /review in your Claude Code session.

MCP Server Integration

Claude Code can connect to MCP (Model Context Protocol) servers to extend its capabilities. Add servers to your project's .mcp.json file:

{
  "mcpServers": {
    "context7": {
      "command": "npx",
      "args": ["-y", "@upstash/context7-mcp@latest"]
    }
  }
}

This example adds Context7 for up-to-date library documentation. You can also add servers for Puppeteer (browser automation), databases, or your own custom tools.

Headless Mode for CI/CD

Claude Code can run non-interactively in CI pipelines or GitHub Actions:

claude -p "Run the test suite and fix any failing tests" --allowedTools Edit,Bash

The -p flag provides the prompt, and --allowedTools restricts which tools Claude can use for safety.


Step 6: Best Practices for Effective Use

These patterns come from Anthropic's internal teams and developers using Claude Code across various projects.

Give Context Before Asking for Implementation

Instead of immediately asking Claude to write code, first have it research and plan:

  1. Ask Claude to investigate the codebase and understand relevant patterns
  2. Ask for a plan of what changes it will make
  3. Ask for implementation
  4. Ask for tests and documentation

This three-step approach (research, plan, implement) significantly improves results for complex changes.

Use Test-Driven Development

TDD becomes even more powerful with Claude Code:

  1. Ask Claude to write tests based on expected behavior
  2. Have it commit the failing tests
  3. Ask it to implement code to make the tests pass
  4. Review and iterate

The tests serve as a specification that Claude can verify its own work against.

Be Specific About Constraints

If you have preferences about how something should be implemented, state them explicitly:

Add pagination to the products list. Use Kaminari since that's what we use elsewhere in the app. Keep the existing filtering and sorting functionality working.

Let Claude Verify Its Work

After Claude makes changes, ask it to verify them:

Run the tests for the files you just modified and make sure everything passes.

Or:

Check that the changes you made follow our linting rules.

Use Sub-Agents for Complex Problems

For particularly challenging problems, ask Claude to investigate multiple approaches:

Research three different ways we could implement caching for our API responses. Investigate each approach in parallel, then summarize the tradeoffs and recommend one.

Step 7: IDE Integration

While Claude Code is designed for the terminal, it also integrates with popular IDEs.

VS Code Extension

Install the Claude Code extension from the VS Code marketplace. This provides a sidebar interface where you can see Claude's changes as visual diffs while keeping all the power of the terminal tool.

Search for "Claude Code" in the Extensions panel and install the official Anthropic extension.

Cursor and Windsurf

Since Cursor and Windsurf are VS Code forks, the same extension works there. Install it the same way through the extensions marketplace.

JetBrains IDEs

Native extensions are available for IntelliJ, WebStorm, RubyMine, and other JetBrains IDEs. Check the plugin marketplace for "Claude Code".


Step 8: Deploy with DeployHQ

Once Claude Code helps you build and refine your features, you need a reliable deployment pipeline. DeployHQ automates the process of getting your code from Git to your servers.

Why This Combination Works

Claude Code operates on your local codebase and can create commits and pull requests directly. When you merge those changes to your main branch, DeployHQ can automatically deploy them to your staging or production servers. This creates a tight feedback loop:

  1. Describe features or fixes to Claude Code
  2. Review and commit the changes
  3. Push to your repository
  4. DeployHQ automatically deploys

Setting Up the Pipeline

  1. Create a DeployHQ project and connect it to your repository

  2. Configure your server with your hosting details (SFTP, SSH, or your preferred connection method)

  3. Enable automatic deployments to trigger when you push to specific branches

  4. Use build commands if your project needs compilation—DeployHQ can run npm build, bundle install, or any other setup steps before transferring files

Example Workflow

Here's what a typical workflow looks like:

# Start Claude Code in your project
cd my-rails-app
claude

# Ask Claude to add a feature
> Add a webhook endpoint that receives Stripe payment events and updates 
> order status in our database. Include signature verification.

# Claude implements the feature across multiple files

# Ask Claude to write tests
> Write integration tests for the webhook endpoint covering successful 
> payment, failed payment, and invalid signature scenarios.

# Ask Claude to commit
> Commit these changes with a descriptive message

# Push to your repository
git push origin main

# DeployHQ automatically deploys to your server

The entire flow from idea to production can happen in minutes.


Step 9: Troubleshooting

Common Issues

"Command not found" after installation:

Add the installation directory to your PATH:

echo 'export PATH="$(npm config get prefix)/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc

Permission errors during npm install:

Never use sudo with npm. Instead, configure a user-level npm directory as shown in the installation section.

Authentication failures:

Run claude doctor to diagnose configuration issues. This command auto-detects most problems and suggests fixes.

High API costs:

Use the --allowedTools flag to restrict what Claude can do, or consider a Claude Max subscription for predictable costs.

Getting Help

  • Use /bug within Claude Code to report issues directly to Anthropic
  • Join the Claude Developers Discord for community support
  • File issues on the GitHub repository

Conclusion

Claude Code represents a shift in how developers interact with AI assistants. Rather than a chat window where you exchange code snippets, it's an agent that operates directly in your development environment, understanding your codebase and executing real changes.

The learning curve comes from thinking in terms of goals rather than implementations. Instead of writing code yourself and asking the AI to review it, you describe what you want and let Claude figure out how to achieve it within your existing codebase patterns.

Combined with DeployHQ for automated deployments, you get a workflow where you can describe features in natural language, have Claude implement them following your existing patterns, and see those changes live on your servers minutes later.

Start with small tasks—bug fixes, test writing, code explanation—to build intuition for how Claude Code interprets your requests. As you develop that intuition, you'll find yourself tackling increasingly complex features with confidence.


Ready to try it? Install Claude Code using the instructions above, navigate to one of your projects, and start with something simple like "Explain the architecture of this project" or "Find any potential security issues in the authentication code." Build from there as you learn how Claude Code thinks about your codebase.