Installing and configuring Claude Code

Get the terminal agent running, give it project instructions it will actually follow, and set permissions before you need them.

Install and authenticate

Claude Code is an agentic coding assistant that runs in your terminal, inside the directory you start it from. It reads files, edits them, runs commands and uses git, so the first decision is which directory you launch it in - everything it can reach by default follows from that.

# install the CLI
npm install -g @anthropic-ai/claude-code
claude --version

# run it from the project root, not from your home directory
cd ~/work/my-service
claude
# first launch: sign in, then verify the working directory it reports
  • Sign in with a Claude subscription or an Anthropic Console API key; the credential is stored outside the repository.
  • Run it in the repository root so project instructions and settings are discovered automatically.
  • Add the local settings file and any credential files to .gitignore before the first commit that touches them.
  • Check the reported model and directory at the start of a session. Most confusing behaviour is a session pointed at the wrong folder.

Instructions and permissions

<!-- CLAUDE.md, at the repository root, committed with the code -->
# Working agreement

- Run `npm test` before claiming any task is complete; paste the summary.
- Never edit files under dist/ or any generated file.
- Prefer the existing helpers in src/lib/ over new dependencies.
- Two-space indentation, no semicolons, single quotes.

<!-- These are instructions, not enforcement. Permissions decide what can run. -->
{
  "permissions": {
    "allow": ["Bash(npm test)", "Bash(npm run lint)", "Read(./src/**)"],
    "deny":  ["Read(./.env)", "Read(./secrets/**)", "Bash(curl:*)"],
    "ask":   ["Bash(git push:*)", "Bash(npm install:*)"]
  }
}
LayerFileCommittedPurpose
Project instructionsCLAUDE.mdYesConventions, commands and boundaries for everyone
Personal instructions~/.claude/CLAUDE.mdNoYour own preferences across every project
Project settings.claude/settings.jsonYesShared allow, ask and deny rules
Local settings.claude/settings.local.jsonNoYour machine-specific permissions
Tool servers.mcp.jsonUsuallyExternal tools and data sources the agent may call
💡
Instructions guide, permissions enforce. A line in CLAUDE.md asking the agent not to read a file is a suggestion the model may miss; a deny rule in settings is checked by the tool layer and does not depend on the model cooperating. Put anything that must hold in the permission rules.

FAQ

Where does it keep state between sessions?
Configuration and credentials live under your home directory, project instructions live in the repository, and session transcripts are stored locally so you can resume. Nothing important should exist only in a transcript.
Can I use it on a monorepo?
Yes, and it is worth adding a nested instruction file in each large package so the agent gets the conventions of the subproject it is working in rather than the whole repository's rules at once.

A typical editing workflow What Codex is and how to set it up

Last refreshed 2026-09-18.