Ravindra BagaleCourses & study guides Track your progress
AI CODING ASSISTANTS · CHAPTER 2 · SETUP

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

WHY

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

WHAT
  • 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

1 · Install one command 2 · cd into project claude 3 · Sign in browser login, once 4 · /init creates CLAUDE.md 5 · Ask + approve read each edit and command

Install steps

HOW
  1. macOS, Linux or WSL: run curl -fsSL https://claude.ai/install.sh | bash.
  2. Windows PowerShell: run irm https://claude.ai/install.ps1 | iex.
  3. The installer shows no progress bar. Wait, then open a new terminal.
  4. Check: claude --version prints a version number.
  5. Go to your project: cd my-project, then run claude.
  6. Sign in when asked (or later with /login). Check with claude auth status --text.
  7. 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

CommandWhat it does
claudestart 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 -ccontinue the last chat in this folder
claude updateupdate now

Settings inside a session

  1. /init: Claude reads the project and writes a starter CLAUDE.md. Edit it to be short and true.
  2. Permission modes: press Shift+Tab to cycle modes (for example normal, auto-accept edits, plan). Beginners: stay in normal or plan.
  3. /model: switch model. /compact: shrink a long chat. /usage: see what is using your plan.
  4. Esc: stop Claude mid-step. /ide: connect to VS Code or JetBrains for diffs, when you run it in an external terminal.

Configuration files

  1. CLAUDE.md (project root): rules, test command, files to avoid.
  2. ~/.claude/settings.json (you) or .claude/settings.json (shared in the repo): permissions, environment variables, MCP servers.
  3. Deny secret files so Claude never reads them:
.claude/settings.json
{
  "permissions": {
    "deny": ["Read(./.env)", "Read(./secrets/**)", "Bash(rm -rf:*)"]
  }
}

First task (5 minutes)

  1. In a small repo run claude, then type: “Explain this project in 5 lines.”
  2. Then: “Add a test for the add function in utils.py and run pytest.”
  3. Read each proposed edit and command. Approve with care.
  4. Check with git diff yourself. Commit only what you understand.
Rule: never run Claude Code with permission checks turned off on your real machine or on a production server.

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

SMART AI USE

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.

Save these cards

INTERVIEW CARDAI Coding

Claude Code CLI vs VS Code extension?

CLI: any terminal, any editor, SSH, scripts (-p).
Extension: graphical panel and diffs inside VS Code.
Ravindra Bagale · ravindrabagale.com/ai-coding
COMPARISON CARDAI Coding

claude vs claude -p

claude: interactive chat, multi-step.
claude -p: one answer then exit; good for pipes and scripts.
Ravindra Bagale · ravindrabagale.com/ai-coding
REVISION CARDAI Coding

CLI in 4

Install script → new terminal → claude --version.
cd project → claude → sign in.
/init, Shift+Tab modes, deny .env.
Ravindra Bagale · ravindrabagale.com/ai-coding