How to Use Claude Code in the Terminal (CLI Setup, Step by Step)
Claude Code also runs as a command-line tool. Type claude in any terminal, in any editor, even on a server over SSH. It reads your project, edits files and runs commands with your permission.
In short: install with one command, run claude in your project folder, sign in, run /init to create CLAUDE.md, and keep permission prompts on.
Why use the CLI
The terminal works everywhere: Neovim, Vim, Emacs, IntelliJ's terminal, a remote Linux box. You are not tied to one editor. You can also script it with claude -p for one-shot jobs.
What you need
- A supported system: macOS 13+, Windows 10 1809+, Ubuntu 20.04+, Debian 10+ or Alpine 3.19+. 4 GB+ RAM.
- An Anthropic account: a paid Claude plan (Pro, Max, Team, Enterprise) or a Claude Console account (pay per use).
- A terminal: Bash, Zsh, PowerShell or CMD. Internet is required.
How it flows
Install steps
- macOS, Linux or WSL: run
curl -fsSL https://claude.ai/install.sh | bash. - Windows PowerShell: run
irm https://claude.ai/install.ps1 | iex. - The installer shows no progress bar. Wait, then open a new terminal.
- Check:
claude --versionprints a version number. - Go to your project:
cd my-project, then runclaude. - Sign in when asked (or later with
/login). Check withclaude auth status --text. - Native installs update themselves. To update by hand:
claude update.
curl -fsSL https://claude.ai/install.sh | bash claude --version cd my-project claude
Daily commands
| Command | What it does |
|---|---|
claude | start a chat in this folder |
claude "explain this project" | start with a first prompt |
claude -p "..." | one answer, then exit (good for scripts) |
cat log.txt | claude -p "explain" | send a file's text in |
claude -c | continue the last chat in this folder |
claude update | update now |
Settings inside a session
- /init: Claude reads the project and writes a starter
CLAUDE.md. Edit it to be short and true. - Permission modes: press Shift+Tab to cycle modes (for example normal, auto-accept edits, plan). Beginners: stay in normal or plan.
- /model: switch model. /compact: shrink a long chat. /usage: see what is using your plan.
- Esc: stop Claude mid-step. /ide: connect to VS Code or JetBrains for diffs, when you run it in an external terminal.
Configuration files
- CLAUDE.md (project root): rules, test command, files to avoid.
- ~/.claude/settings.json (you) or .claude/settings.json (shared in the repo): permissions, environment variables, MCP servers.
- Deny secret files so Claude never reads them:
{
"permissions": {
"deny": ["Read(./.env)", "Read(./secrets/**)", "Bash(rm -rf:*)"]
}
}First task (5 minutes)
- In a small repo run
claude, then type: “Explain this project in 5 lines.” - Then: “Add a test for the add function in utils.py and run pytest.”
- Read each proposed edit and command. Approve with care.
- Check with
git diffyourself. Commit only what you understand.
Quick quiz
1. What command installs Claude Code on macOS or Linux?
curl -fsSL https://claude.ai/install.sh | bash.
2. Which command creates a starter CLAUDE.md?
/init inside a session.
3. How do you get one answer and exit, for scripts?
claude -p "your question".
4. Which key cycles permission modes?
Shift+Tab.
Save tokens and money
Start Claude in the right subfolder, not your whole home folder. Use claude -p with piped input for small jobs. Run /compact or start a fresh session for each new task. Keep CLAUDE.md short.