# How do you set up Claude Code in your project?

Date: 2025-03-06 · Author: Robert Scales · https://guidetoartificialintelligence.com/en/learn/set-up-claude-code-project/

**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:

| Need | Detail |
|---|---|
| Operating system | macOS 10.15 or later, Ubuntu 20.04+ or Debian 10+; on Windows, only through WSL (the Windows Subsystem for Linux) |
| Memory | At least 4 GB of RAM |
| Software | Node.js 18 or later; Git is optional but strongly useful |
| Account | An 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.

```bash
# 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:

```markdown
# 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:

```bash
# 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

- Claude Code overview: https://docs.anthropic.com/en/docs/agents-and-tools/claude-code/overview
- Claude 3.7 Sonnet and Claude Code: https://www.anthropic.com/news/claude-3-7-sonnet
