Claude Code CLI Tutorial 2026: A Beginner's Guide to Terminal AI Coding

Claude Code is Anthropic's command-line tool that brings Claude directly into your terminal. Instead of switching to a browser to ask questions, you work with Claude inside your project folder — reading files, writing code, running commands, and debugging without leaving your shell.

In 2026, Claude Code has become the most popular AI tool for developers to learn, with interest increasing more than 23 times since 2025 according to Pluralsight's Tech Learning Pulse. This guide walks you through installation to daily workflow — no prior AI tooling experience required.

1. What Is Claude Code CLI?

Claude Code is a terminal-based AI assistant that can:

  • Read files in your project and understand their structure
  • Write and edit code across multiple files
  • Run shell commands like npm install or git commit
  • Search the web for documentation and answers
  • Remember context across sessions about your project

It is not a replacement for your IDE — it is a companion that handles the tasks where natural language is faster than typing code: explaining a codebase, generating boilerplate, refactoring across files, or writing tests.

2. Install Claude Code

Claude Code requires Node.js 18 or later. Check your version first:

node --version

If you see v18+, you are good. If not, install Node.js first.

macOS and Linux (Recommended)

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

Windows (PowerShell)

irm https://claude.ai/install.ps1 | iex

Via npm (Cross-platform)

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

Verify the installation:

claude --version

You should see a version number like 0.47.0. If you see "command not found", restart your terminal.

3. Authenticate

Claude Code needs an Anthropic account. You can use:

  • Claude Pro, Max, Team, or Enterprise subscription
  • Claude Console account with API credits
  • Cloud provider (Amazon Bedrock, Google Cloud, Microsoft Foundry)

Start an interactive session:

claude

On first run, this opens a browser for authentication. Log in, approve the connection, and you are done. Your credentials are stored locally — you will not need to log in again.

If you prefer using an API key directly, set it as an environment variable:

export ANTHROPIC_API_KEY="your-key-here"

Add this to your shell profile (~/.zshrc or ~/.bashrc) to persist across sessions.

4. Your First Session

Navigate to a project folder and start Claude Code:

cd /path/to/your/project
claude

You will see the Claude Code prompt with the current model and working directory. Type a message and press Enter:

> Explain what this project does

Claude reads your project files and gives you a summary. Ask it to write code:

> Create a Python function that takes a list of numbers and returns their average

Then save it:

> Save that to a file called math_utils.py

Claude writes the file and confirms. You can now use it in your project.

5. Core Commands

Inside a Claude Code session, these slash commands are available:

CommandWhat It Does
/helpShow all available commands
/loginSwitch accounts or re-authenticate
/resumeContinue a previous conversation
/clearClear the current conversation context
/exitQuit Claude Code

Outside a session, you can run one-off commands:

# Print mode — execute and exit
claude -p "Summarize the README in this directory"

# Pipe content to Claude
cat error.log | claude -p "What is causing these errors?"

# Continue the most recent conversation
claude -c

6. Real Tasks You Can Do

Task 1: Understand a New Codebase

> I just cloned this repo. Give me a high-level overview of the architecture and where the main logic lives.

Claude scans the directory structure, reads key files, and explains the architecture in plain English.

Task 2: Generate a Complete Feature

> Build a command-line tool that takes a CSV file path as input and prints a summary: number of rows, column names, and the first 5 rows. Use Python.

Claude will:

  1. Write the Python script
  2. Install any needed packages (pip install pandas if needed)
  3. Test it with a sample CSV
  4. Show you the output

Task 3: Refactor Across Multiple Files

> Rename the function `get_user_data` to `fetch_user_profile` across the entire codebase and update all imports.

Claude finds every occurrence, edits each file, and shows you a diff before applying changes.

Task 4: Write Tests

> Write pytest unit tests for the `calculate_total` function in orders.py. Cover edge cases like empty cart and negative prices.

Task 5: Debug an Error

> I am getting a TypeError in app.py line 47. Here is the traceback: [paste]. What is wrong and how do I fix it?

7. Using Skills

Skills are pre-configured modes that make Claude especially good at specific tasks. They are Markdown files stored in ~/.claude/skills/ and invoked with a slash command.

Built-in skills you can use immediately:

SkillCommandUse Case
Test-Driven Development/tddWrite tests first, then implementation
Frontend Design/frontend-designGenerate UI components and CSS
PDF Processing/pdfProcess and generate PDF documents
Supermemory/supermemoryStore context that persists between sessions

Example — using the TDD skill:

/tdd Write tests for my math_utils.py file

Example — storing project context:

/supermemory Remember that this project uses ES modules (import/export), not CommonJS

In a future session:

/supermemory What are the module conventions for this project?

8. Tips for Daily Use

Tip 1: Start with a CLAUDE.md

Create a CLAUDE.md file in your project root. Claude reads this automatically on every session. Use it for:

  • Project conventions (naming, architecture decisions)
  • Environment setup steps
  • Common commands and scripts
  • API keys or config locations (do not commit secrets)

Tip 2: Be Specific in Requests

Vague: "Fix the bug"
Specific: "The login endpoint returns 500 for users with Unicode names. The error is in auth.py. Fix the encoding handling."

Tip 3: Review Before Accepting

When Claude proposes file changes, it shows a diff. Read it. Claude is confident even when wrong. You are the final reviewer.

Tip 4: Use Print Mode for Scripts

For CI/CD or automation, use claude -p instead of interactive mode. It runs the command and exits with a clean output.

Tip 5: Keep Sessions Focused

Long conversations drift. For a new task, start fresh with /clear or exit and re-enter. Context window is finite — do not waste it on solved problems.

9. Common Mistakes

Mistake 1: Trusting Claude's Confidence Blindly

Claude sounds certain even when guessing. Always verify generated code, especially for security-critical sections like authentication or payment handling.

Mistake 2: Running Commands Without Review

Claude can execute shell commands. By default it asks before running destructive operations, but review every command before approving.

Mistake 3: Using Interactive Mode in CI/CD

Interactive mode hangs in non-TTY environments. Use claude -p for automation and scripts.

Mistake 4: Not Using CLAUDE.md

Without a project context file, Claude relearns your conventions every session. A 50-line CLAUDE.md saves hours of repeated explanations.

Mistake 5: Expecting Claude to Know Your Private APIs

Claude can search the public web. It cannot access your internal documentation or private repositories unless you paste the content into the conversation.

Frequently Asked Questions

Is Claude Code free?

Claude Code requires a Claude subscription (Pro, Max, Team, Enterprise) or Console API credits. There is no free tier as of September 2026.

Does Claude Code work offline?

No. Claude Code sends your prompts and file contents to Anthropic's servers for processing. It requires an internet connection.

Can Claude Code access my entire filesystem?

Claude Code can only read and write files within the directory where you started the session and its subdirectories. It cannot access files outside the project folder unless you explicitly provide paths.

How does Claude Code compare to GitHub Copilot?

Copilot is an IDE extension that suggests code as you type. Claude Code is a terminal tool for broader tasks: understanding codebases, refactoring across files, running commands, and writing documentation. They complement each other — many developers use both.

Can I use Claude Code with my own API key?

Yes. Set the ANTHROPIC_API_KEY environment variable. This is useful for team accounts or when you want to manage billing separately from a Claude subscription.

Does Claude Code support Windows?

Yes, via PowerShell or WSL. Native Windows support improved significantly in 2026. For the best experience, Git for Windows is recommended so Claude can use Bash commands.

Bottom Line

Claude Code is the fastest way to get AI assistance inside your existing terminal workflow. It does not replace your IDE — it handles the tasks where a conversation is faster than typing code: understanding codebases, generating boilerplate, refactoring, and debugging.

Start with a small project, create a CLAUDE.md with your conventions, and use /tdd or /frontend-design skills when they fit. Review every change before accepting. Within a week, it will feel as natural as git status.