Claude CLI: The Complete Guide to the Command Line AI Assistant
Amine Lahmary·Aug 3, 2026·5 min read
What is the Claude CLI?
The Claude CLI is a command-line tool made by Anthropic. You start it in any project folder, and Claude can:
- Read and understand your whole codebase.
- Edit files and write new code.
- Run tests and commands for you.
- Explain bugs, review changes, and suggest fixes.
- Work with git, tools, and APIs. It works in three ways:
- Interactive mode — a chat-like session in your terminal.
- One-time queries — ask a question and get an answer, then exit.
- Piped input — feed it a file or log to analyze.
How to install the Claude CLI
Installation is quick. Choose the method for your system.
Windows
Open PowerShell and run:
irm https://claude.ai/install.ps1 | iex
If you prefer the Windows package manager:
winget install Anthropic.ClaudeCode
macOS and Linux
curl -fsSL https://claude.ai/install.sh | bash
On macOS you can also use Homebrew:
brew install --cask claude-code
With npm
If you already use Node.js:
npm install -g @anthropic-ai/claude-code
Check the installation
claude --version
You should see a version number followed by (Claude Code).
Log in and start your first session
The Claude CLI needs an account. Open your terminal, go to your project folder, and run:
claude
On first use, Claude will ask you to log in. After that, you can start working immediately.
Tip: Install Git for Windows on native Windows so Claude can use the Bash tool. Otherwise, Claude automatically uses PowerShell.
Essential Claude CLI commands
Here are the commands you will use every day.
Start and resume sessions
CommandWhat it doesclaudeStart an interactive sessionclaude "fix the build error"Start a session with a taskclaude -p "explain this function"Run a one-time query, then exitclaude -cContinue the most recent conversationclaude -rResume a previous conversationcat logs.txt | claude -p "explain"Analyze a file with Claude
The -p (print) flag is perfect for quick questions. Use -c to continue yesterday's work, and -r to pick a specific old session.
Commands inside a session
Type these with a leading slash inside Claude Code:
CommandWhat it does/helpShow all available commands/clearClear the conversation history/initCreate a CLAUDE.md memory file/statusShow your current session info/modelSwitch the AI model/compactSummarize a long conversation to save context/exitLeave Claude Code
Useful Claude CLI flags
Flags change how Claude starts. These are the ones you will use most.
--model
Choose which model to use for the session:
claude --model claude-sonnet-5
You can also use short names like sonnet, opus, or haiku.
--permission-mode
Control how much Claude can do without asking:
claude --permission-mode plan
claude --permission-mode acceptEdits
plan is great for a first pass: Claude explains what it will do without changing files.
--dangerously-skip-permissions
Runs Claude without asking for permission on every action. Use it only in safe environments, like a sandbox or CI:
claude --dangerously-skip-permissions "refactor the login component"
--add-dir
Let Claude read and edit code from other folders:
claude --add-dir ../shared-components
--bg(background)
Start a session in the background and keep working:
claude --bg "investigate the flaky test"
Claude gives you a session ID so you can check the result later.
Set up your project memory
Claude can remember your project's rules. Run /init inside a session and Claude creates a CLAUDE.md file. Use it to store:
- The commands to run tests and builds.
- Your coding style and conventions.
- The project structure.
- Common pitfalls to avoid.
A good
CLAUDE.mdmakes every future session faster and more accurate.
Daily workflow tips
Here is a simple workflow that works well for most developers:
- Plan first. Start with
claude --permission-mode planand ask Claude to explain its approach before it touches code. - Give one clear task. Instead of "fix the app", say "fix the login bug where the form submits before validation".
- Continue, don't restart. Use
claude -cto keep context between tasks in the same project. - Use print mode for quick questions.
claude -p "what does this function do?"is faster than opening a full session. - Review before you trust. Always read the diff. Claude is fast, but you are responsible.
- Add memory. Keep
CLAUDE.mdupdated so Claude improves over time.Extend Claude with skills and tools
Once you are comfortable, Claude Code gets even more powerful:
- Skills — folders with a
SKILL.mdfile that teach Claude your team's patterns. Run them with/skill-name. - Subagents — specialized assistants for tasks like code review.
- MCP servers — connect Claude to databases, browsers, or your own APIs.
- Hooks — run scripts automatically when Claude performs certain actions. Start with the essentials first. The power comes later, once the basics feel natural.
Troubleshooting quick tips
claudeis not recognized → close and reopen your terminal, or reinstall with the installer above.- Login problems → run
claude auth loginagain. - Slow or long sessions → use
/compactto summarize the conversation and free up space. - Wrong project rules → edit your
CLAUDE.mdfile and restart the session.Start using the Claude CLI today
The Claude CLI turns your terminal into a coding partner. Install it in five minutes, learn the essential commands, and let Claude handle the repetitive work while you focus on the hard problems.
Try this right now: open your project, run claude, and ask it to explain your codebase. You will see the power of an AI assistant that lives where you work.
This post was written in August 2026 based on the latest Claude Code documentation. Features and commands evolve quickly, so check the official docs for updates.