← Back to Blog

How to Set Up Claude Code CLI: A Practical Guide

Published on: March 1, 2026


Claude Code is Anthropic's official command-line interface that brings Claude's reasoning directly into your terminal and editor. Instead of switching to a browser tab, you can ask questions, write code, debug, and even run shell commands — all within your existing workflow. This guide walks you through getting it set up from scratch.


Prerequisites

Before installing, make sure you have the following in place:


Step 1: Install Claude Code

Install the CLI globally via npm:

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

Once installed, verify it worked:

claude --version

Step 2: Set Your API Key

Claude Code needs your Anthropic API key to authenticate. The cleanest way to set it is via an environment variable so it persists across sessions. Add this line to your shell profile (~/.zshrc, ~/.bashrc, or equivalent):

export ANTHROPIC_API_KEY="sk-ant-your-key-here"

Then reload your shell:

source ~/.zshrc

Alternatively, you can run claude for the first time and it will prompt you to enter your key interactively — it stores it in ~/.claude automatically.


Step 3: Start Your First Session

Navigate into any project directory and launch Claude Code:

cd ~/my-project
claude

You'll land in an interactive REPL. Claude can see your current directory, read files you reference, and run shell commands you approve. Try something simple to start:

> explain the structure of this project
> find all TODO comments in the codebase
> write a unit test for the login function in auth.py

Step 4: Run One-Off Commands (No REPL)

For quick, scripted use you don't need the interactive session. Pass a prompt directly with -p:

claude -p "summarise the changes in the last git commit"

This is useful for integrating Claude into shell scripts or CI pipelines.


Step 5: IDE Integration (VS Code)

If you use VS Code, you can open Claude Code directly from the editor's integrated terminal. There's no separate plugin needed — it reads your open files and workspace context automatically. Just run claude in the terminal panel.

For an even tighter loop, you can use the /ide command inside a session to have Claude open and edit files in your active editor window:

> /ide

Key Commands to Know

Once you're inside a session, these slash commands are the most useful ones to start with:


Tips for Getting the Most Out of It

A few things that make a real difference in day-to-day use:


Conclusion

Claude Code CLI bridges the gap between conversational AI and actual engineering work. Once it's wired into your terminal, the friction of context-switching to a browser disappears — you get a reasoning partner sitting right inside your codebase. The setup takes under five minutes, and the compounding productivity gains show up almost immediately.

Give it a week of daily use and it becomes as natural as any other dev tool in your stack.