Claude Code CLI: The Complete Guide to AI-Powered Terminal Development

by Sandlabs Team, Founder, Sandlabs

Claude Code has changed how professional developers write software. Since Anthropic launched it, the CLI has grown into the most powerful AI coding agent available — accounting for roughly 4% of all public GitHub commits and generating over $1B in annualized revenue within its first six months.

At Sandlabs, we use Claude Code on every project we deliver. From fintech platforms to AI agent systems, the CLI has become the core of our development workflow. Our team consistently ships production features in 2-6 weeks that previously took months.

This guide covers everything you need to start using Claude Code AI effectively: installation, essential commands, MCP server integration, real-world workflows, and the productivity tips that separate casual users from developers who are genuinely shipping 10x faster.

What Is Claude Code?

Claude Code is Anthropic's agentic coding assistant that runs directly in your terminal. Unlike browser-based AI chat tools or IDE autocomplete, Claude Code operates as a full AI coding agent — it reads your entire codebase, writes multi-file changes, executes shell commands, runs tests, and iterates on errors autonomously.

Think of it as a senior developer sitting in your terminal who has already read every file in your project and understands how everything connects.

What makes it different from other AI coding tools:

  • Codebase-aware — it indexes your project, follows imports, understands architecture patterns, and respects your code style
  • Agentic execution — it does not just suggest code; it creates files, runs commands, reads output, and self-corrects
  • Terminal-native — no browser tabs, no context switching, no copy-pasting snippets between a chat window and your editor
  • MCP integration — it connects to databases, APIs, GitHub, Jira, and any external tool through the Model Context Protocol
  • Permission model — you approve or deny every file write and command execution, keeping you in control

Claude Code uses Claude's latest models (Opus and Sonnet) under the hood. The CLI handles context management automatically, deciding which files to read and how to break down complex tasks into steps.

Installation and Setup

Getting Claude Code running takes under two minutes.

Prerequisites

  • Node.js 18+ — check with node --version
  • An Anthropic account — either a Max subscription ($20-200/month) or an API key with credits

Install

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

Start your first session

cd your-project
claude

That is it. Claude Code will scan your project structure, build an understanding of your codebase, and present a prompt where you can start giving it tasks.

Authentication

On first launch, Claude Code will prompt you to authenticate. You have two options:

  1. Anthropic Max subscription — sign in through the browser when prompted. Your Max plan includes Claude Code usage with built-in rate limits.
  2. API key — set ANTHROPIC_API_KEY in your environment. You pay per token, which is more cost-effective for heavy usage.
# API key approach
export ANTHROPIC_API_KEY=sk-ant-your-key-here
claude

For team setups, store the API key in your shell profile or use a secrets manager. Never commit API keys to your repository.

Essential Commands and Usage Patterns

Claude Code operates through natural language prompts, but knowing the key commands and flags will make you significantly more productive.

Core CLI Commands

# Start an interactive session in the current directory
claude

# Run a single task without entering interactive mode
claude -p "Explain what this project does"

# Resume the most recent conversation
claude --resume

# Continue from a specific session
claude --resume SESSION_ID

# Pipe input for processing
cat error.log | claude -p "What caused this crash?"

# Run in non-interactive mode (useful for CI/CD)
claude -p "Run all tests and fix any failures" --allowedTools "Edit,Bash"

Slash Commands Inside a Session

Once inside a Claude Code session, these slash commands control behaviour:

CommandWhat it does
/compactCompresses conversation history to free up context window
/clearResets the conversation entirely
/costShows token usage and cost for the current session
/modelSwitch between Claude Sonnet and Opus mid-session
/permissionsReview and modify tool permissions
/memoryEdit the project memory file (CLAUDE.md)
/helpFull list of available commands

The CLAUDE.md Memory File

One of Claude Code's most powerful features is the CLAUDE.md file. Place this in your project root to give Claude persistent context about your project:

# Project: PaymentSync API

## Tech Stack
- Next.js 14 App Router with TypeScript
- Prisma ORM with PostgreSQL
- Resend for transactional email
- Stripe for payments
- Vitest for testing

## Conventions
- Use server actions for mutations, not API routes
- All database queries go through the repository pattern in src/lib/repositories/
- Error handling uses our custom AppError class in src/lib/errors.ts
- Tests live next to the files they test (component.test.ts)

## Key Architecture Decisions
- Multi-tenant: every query must include organizationId
- Webhook handlers validate signatures before processing
- All monetary values stored as integers (cents)

Claude reads this file at the start of every session. It is the single highest-impact thing you can do to improve Claude Code's output quality. Be specific about your patterns, conventions, and architecture decisions.

MCP Server Integration

The Model Context Protocol is what turns Claude Code from a code generator into a connected development agent. MCP servers let Claude interact with external tools — databases, project management systems, documentation platforms, and your own custom APIs.

How MCP Works with Claude Code

MCP uses a client-server architecture. Claude Code acts as the MCP client, connecting to one or more MCP servers that expose tools. When you give Claude a task like "check the latest deployment status," it discovers available MCP tools, calls the right one, and incorporates the results.

Configuring MCP Servers

MCP servers are configured in your project's .claude/settings.json or globally in ~/.claude/settings.json:

{
  "mcpServers": {
    "github": {
      "command": "npx",
      "args": ["-y", "@anthropic-ai/github-mcp-server"],
      "env": {
        "GITHUB_TOKEN": "your-token-here"
      }
    },
    "postgres": {
      "command": "npx",
      "args": ["-y", "@anthropic-ai/postgres-mcp-server"],
      "env": {
        "DATABASE_URL": "postgresql://user:pass@localhost:5432/mydb"
      }
    },
    "jira": {
      "command": "npx",
      "args": ["-y", "@anthropic-ai/jira-mcp-server"],
      "env": {
        "JIRA_URL": "https://your-org.atlassian.net",
        "JIRA_TOKEN": "your-token"
      }
    }
  }
}

Most Useful MCP Servers for Development

Based on our daily usage at Sandlabs, these MCP servers provide the most value:

  • GitHub — create PRs, review diffs, manage issues, check CI status, all without leaving the terminal
  • PostgreSQL / Supabase — query your database directly. Claude can inspect schemas, run queries, and debug data issues
  • Playwright — run browser automation and end-to-end tests with Claude controlling the browser
  • Slack — post deployment notifications, fetch conversation context, update channels
  • Notion — read documentation, update project wikis, create pages from code analysis

Building Custom MCP Servers

For proprietary tools, you can build custom MCP servers. This is especially valuable for internal CRMs, custom databases, or business-specific APIs that no off-the-shelf connector supports.

from mcp.server.fastmcp import FastMCP

mcp = FastMCP("internal-tools")

@mcp.tool()
async def get_deployment_status(environment: str) -> str:
    """Check the current deployment status for an environment.

    Args:
        environment: The target environment (staging, production)
    """
    status = await fetch_deployment_api(environment)
    return f"Environment: {environment}\nVersion: {status.version}\nStatus: {status.health}"

See our detailed guide on building custom MCP connectors for the full walkthrough, including security, authentication, and deployment patterns.

Real-World Workflows

Here are the five workflows where Claude Code AI delivers the most value. These are the patterns we use daily at Sandlabs across client projects.

1. Code Generation

This is the most common use case. Instead of writing boilerplate from scratch, describe what you need and let Claude generate it in context.

> Create a new API route at /api/invoices that supports GET (list with
> pagination and filtering by status) and POST (create new invoice).
> Use our existing auth middleware and Prisma models. Add input
> validation with Zod.

Claude will read your existing routes, match your patterns, use your actual Prisma schema, and generate production-ready code — not generic templates. It typically produces the route handler, validation schemas, types, and tests in a single pass.

Productivity tip: Be specific about what exists. Saying "use our existing auth middleware" triggers Claude to find and follow your patterns. Vague prompts produce generic code.

2. Debugging

Claude Code is exceptionally good at debugging because it can read error output, inspect source code, and test fixes in a loop.

> The /api/payments/webhook endpoint returns 500 on Stripe
> subscription.updated events. Here's the error from the logs:
> TypeError: Cannot read properties of undefined (reading 'plan')
> Find and fix the bug.

Claude will trace the error through your code, identify that the event payload structure differs from what your handler expects, fix the destructuring, and run your test suite to confirm the fix works. The iterative nature — read error, reason, fix, test, repeat — is where Claude Code outperforms chat-based AI tools.

3. Refactoring

Refactoring across multiple files is where Claude Code's codebase awareness matters most.

> Refactor our authentication from the custom JWT implementation
> to use next-auth with the Credentials provider. Update all
> protected routes, middleware, and tests.

Claude will map every file that touches authentication, plan the migration order, make changes across the codebase, and update tests. For a task like this, expect Claude to modify 15-30 files in a coordinated change. You review each file modification before it is applied.

4. Test Writing

Writing comprehensive tests is tedious and time-consuming. Claude Code generates tests that actually match your codebase.

> Add unit tests for the InvoiceService class. Cover all public
> methods including edge cases: empty arrays, invalid IDs,
> concurrent updates, and permission checks. Use our existing
> Vitest setup with the test database helper.

Claude reads your service class, understands the dependencies, and writes tests using your actual test utilities and patterns — not generic mock setups from documentation examples.

5. Git Workflows

Claude Code handles the entire git workflow, from staging through to pull request creation.

> Review all my changes, create a well-structured commit with a
> descriptive message, push to a new branch, and create a PR
> with a summary of changes.

With the GitHub MCP server connected, Claude can create the branch, write commit messages that follow your team's conventions, push, and open a pull request — complete with a description that explains the "why" behind the changes.

Tips for Maximum Productivity

After hundreds of hours using Claude Code across real projects, these are the practices that make the biggest difference.

Write Detailed CLAUDE.md Files

This is the single most impactful thing you can do. A well-written memory file eliminates 80% of the "that's not how we do it in this project" corrections. Include your tech stack, file structure conventions, naming patterns, and architectural decisions.

Use /compact Aggressively

Long sessions degrade Claude's performance as the context window fills up. Run /compact after completing a task to compress the conversation history. This frees up context for the next task without losing critical information.

Chain Tasks, Don't Batch Them

Instead of asking Claude to do five unrelated things at once, chain them sequentially. Complete one task, review the output, then start the next. Claude performs better with focused, single-objective prompts.

Leverage Non-Interactive Mode for CI/CD

Use claude -p in your CI/CD pipeline for automated tasks:

# Auto-fix lint errors before committing
claude -p "Fix all ESLint errors in the staged files" --allowedTools "Edit,Bash"

# Generate changelog entries from recent commits
claude -p "Generate a changelog entry for the commits since last tag"

# Review PR for security issues
claude -p "Review the diff in this PR for security vulnerabilities"

Use Extended Thinking for Complex Tasks

For architecture decisions, complex debugging, or multi-step refactoring, enable extended thinking by choosing the Opus model. Claude will reason through the problem more carefully before generating code, producing significantly better results on hard problems.

Provide Examples When Introducing New Patterns

If you want Claude to follow a pattern it has not seen in your codebase, show it an example:

> Create a new service for OrderProcessing following the exact same
> pattern as src/services/InvoiceService.ts — same error handling,
> same repository injection, same logging approach.

Pointing to existing code as a template produces better results than describing the pattern abstractly.

Limitations to Know About

Claude Code is powerful, but knowing its limits helps you use it effectively.

Context window boundaries — very large codebases exceed Claude's context capacity. Claude Code manages this through selective file reading, but it may miss connections in projects with hundreds of files. Use /compact and keep sessions focused.

Non-deterministic output — the same prompt can produce different code on different runs. For critical code paths, review carefully and run your test suite. Do not assume correctness.

Rate limits — depending on your plan, you will hit rate limits during heavy sessions. The Max Pro plan ($200/month) provides the highest throughput. For teams, API key billing with a shared account is often more economical.

Limited long-term memory — each session starts relatively fresh. The CLAUDE.md file and conversation resume help, but Claude does not build a deep understanding of your project over weeks the way a human developer does. Be prepared to re-explain context after long breaks.

Security and permissions — Claude Code executes real commands on your machine. Always review file changes and command executions before approving. Never run Claude Code with elevated privileges, and be cautious with destructive operations like database migrations on production.

Newer frameworks and libraries — Claude's training data has a cutoff. For very new libraries or breaking changes in recent framework releases, you may need to paste relevant documentation or API references into the conversation.

Frequently Asked Questions

What is Claude Code CLI and how does it work?

Claude Code CLI is Anthropic's terminal-based AI coding agent. It runs in your terminal, reads your entire project, and executes multi-step development tasks autonomously. You give natural language instructions and Claude writes code, runs tests, fixes errors, and manages git — all while respecting your existing codebase patterns and conventions.

Is Claude Code free to use?

Claude Code requires either an Anthropic Max subscription starting at $20 per month or an API key with credits. There is no free tier, though the base Max plan includes generous usage limits. For heavy development use, the Pro plan at $100 per month or API billing typically offers better value and higher rate limits.

How does Claude Code compare to GitHub Copilot?

GitHub Copilot focuses on inline code completion — it suggests the next few lines as you type. Claude Code is a full AI coding agent that reads your entire codebase, writes multi-file features, runs tests, debugs errors, and executes shell commands. Copilot helps you write code faster line by line. Claude Code handles entire tasks end to end, from feature creation to PR submission.

Can Claude Code connect to external tools and databases?

Yes, through the Model Context Protocol. Claude Code supports MCP servers that connect it to GitHub, PostgreSQL, Slack, Jira, Notion, Playwright, and hundreds of other tools. You can also build custom MCP servers for proprietary internal systems. This makes Claude Code a connected development agent, not just a code generator.

What programming languages does Claude Code support?

Claude Code works with all major programming languages including TypeScript, JavaScript, Python, Go, Rust, Java, C++, Ruby, PHP, Swift, and Kotlin. It is strongest in TypeScript and Python due to training data volume. Language-specific features like type inference, framework patterns, and testing conventions are well-supported across the most popular ecosystems.

Start Building with Claude Code

Claude Code AI is the most productive development tool we have adopted in the past decade. It does not replace developers — it removes the friction between having an idea and having working code.

If you are a developer, install it today and start with small tasks. Fix a bug. Write a test file. Generate a new API route. You will find your rhythm within a few sessions.

If you are a founder or product team looking to ship faster — we build production AI applications in 2-6 weeks, fixed price. Sandlabs is an AI development studio based in Australia. We use Claude Code, MCP, and agentic AI systems every day across fintech, legal tech, and enterprise SaaS projects.

Talk to us about your project and we will scope it in a free written AI audit.

More articles

Claude AI Pricing (October 2026): Every Plan in USD + AUD

Claude Pro is US$20/mo (A$34 in Australia), Max US$100-$200, Team from US$20/seat with a 2-seat minimum. Every plan, API rate and GST rule, re-checked 20 Oct 2026.

Read more

Claude Code Pricing 2026: Pro vs Max vs Team vs API (USD + AUD)

Claude Code has no price of its own and is not free: it comes with Pro (US$20, A$34 in Australia), Max, Team or the API. Headroom by plan, and when the API is cheaper.

Read more

Let's build something great together.

Melbourne, Australia — serving founders worldwide. [email protected]