Build with AI

How do you set up Claude Code in your project?

· By Robert Scales · 3 min read

Short answer

Install it with npm, open a terminal in your project folder, type claude, and sign in once with an Anthropic Console account that has billing turned on. Then ask it to summarize the project, run /init to create a CLAUDE.md project guide, commit that file, and approve each command or edit it proposes until you know which ones are safe to allow permanently.

Claude Code is Anthropic's command-line coding agent, released as a limited research preview alongside Claude 3.7 Sonnet on February 24, 2025. "Command-line" means it runs in your terminal, the text window where you type commands, rather than in a browser. "Agent" means it does more than suggest code: it can search and read your files, edit them, run tests and other commands, and create Git commits, asking for your approval along the way. By default it uses the claude-3-7-sonnet-20250219 model.

Setting it up takes a few minutes. Doing it carefully, so the agent knows your project and cannot do anything you did not intend, is what this guide covers.

Before you install

Check the requirements in Anthropic's documentation:

NeedDetail
Operating systemmacOS 10.15 or later, Ubuntu 20.04+ or Debian 10+; on Windows, only through WSL (the Windows Subsystem for Linux)
MemoryAt least 4 GB of RAM
SoftwareNode.js 18 or later; Git is optional but strongly useful
AccountAn Anthropic Console account with active billing

Claude Code is paid by usage through the Anthropic API, not by a subscription. The documentation gives typical costs of $5 to $10 per developer per day, and warns that heavy use can go above $100 an hour. Setting a spending limit in the Console before you start is a sensible first step.

Step-by-step: install and first session

Run these in your terminal. Replace my-project with your own folder.

# 1. Install (do not use sudo)
npm install -g @anthropic-ai/claude-code

# 2. Go to your project
cd my-project

# 3. Start Claude Code
claude

The first time you run claude, it walks you through a one-time OAuth sign-in (a standard way to authorize an app) with your Console account. The docs warn against installing with sudo, the command that runs something with administrator rights, because it can cause permission problems and security risks; if npm complains about permissions, follow the fix in the configuration section of the docs instead.

Once you see its prompt, start by reading, not changing:

Prompt
summarize this project: what it does, how it's organized, and how to run the tests

Then run the slash command /init. It writes a file called CLAUDE.md, a project guide for Claude. Open it, correct anything wrong, and add what a new teammate would need: how to install dependencies, the test command, style rules, folders that must not be touched. A short illustrative example:

# Project guide
- Run tests with: npm test
- Code style: 2-space indentation, no semicolons
- Never edit files in /legacy without asking first
- Write a short test for every bug you fix

Commit CLAUDE.md to your repository, as the docs recommend, so everyone who uses Claude Code on the project starts from the same guide.

A few other commands are worth knowing on day one: /cost shows how many tokens the session has used, /compact shrinks a long conversation to save tokens, and /clear starts fresh between unrelated tasks.

Try it: On a copy of a small project, ask Claude Code to "find and explain the function that handles user input, then propose one test for it without writing any files." Read its proposal, then let it write the test and run it, approving each step.

How do you give it permissions safely?

Claude Code uses tiered permissions. Reading files, listing folders and searching code need no approval. Running a shell command needs your approval each time, and if you answer "Yes, don't ask again," that choice is remembered for that command in that project folder. Editing or creating files also needs approval, and "don't ask again" for edits lasts only until the session ends.

Start strict. For the first sessions, approve each action individually and read what it wants to run. You will soon see which commands are routine and harmless, typically your test or lint command. Allow only those, by name, in the project settings:

# Let the test command run without asking
claude config add allowedTools "Bash(npm test)"

# Keep the agent out of folders it never needs
claude config add ignorePatterns "node_modules/**"

Keep anything with lasting effects on manual approval: deleting files, installing packages, pushing to GitHub, or commands that touch databases or servers. Work on a Git branch so every change can be reviewed and undone.

Be careful with outside content. A web page, an issue or a file from someone else can contain hidden instructions aimed at the AI, an attack called prompt injection. Claude Code blocks commands such as curl and wget that fetch arbitrary web content by default and asks before sensitive operations, but the docs advise reviewing proposed commands, not piping untrusted text into Claude, and checking changes to important files. Finally, the --dangerously-skip-permissions flag removes all prompts; Anthropic says to use it only inside a Docker container without internet access, never on your everyday machine.

Sources

  1. Claude Code overview — Anthropic (documentation), March 5, 2025
  2. Claude 3.7 Sonnet and Claude Code — Anthropic, February 24, 2025

Get the free Guide to Artificial Intelligence

Sign up for the weekly newsletter and receive the free guide: what changed in AI this week, one lesson, one prompt to try. Unsubscribe in one click.

How we handle your address

Back to top

Display

Your choices are saved in this browser only. No data is sent.

Text size
100%
Colours
Reading
More settings
Accessibility statement