On this page#
- Before you install anything
- The steps
- A working configuration
- Scope
- Protected data
- Validation
- Git and release boundaries
- What to skip
- First real task
- FAQ
Before you install anything#
Install Claude Code only after you define repository rules, permission boundaries, and a safe first task. The command is the easy part; the durable setup is the contract around it. If you install first and govern later, the agent learns nothing about your invariants and the second engineer inherits undocumented risk.
Claude Code is an agentic coding tool that can inspect files, edit code, and run terminal commands; the official Claude Code overview explains the product model. In a real repository, those capabilities must be constrained by project-owned instructions rather than personal habits.
Use this order:
- Identify protected files, generated code, and irreversible commands.
- Write repository instructions that explain how changes are validated.
- Add narrow, shared permissions.
- Install and authenticate Claude Code.
- assign a bounded task with an observable result.
This order matters because installation is local, while operating rules belong to the repository. A setup hidden in one engineer’s shell history cannot be reviewed, versioned, or handed over.
Do not treat prompts as governance. “Please be careful” is not a boundary. A deny rule for secrets or publishing commands is a boundary; a required validation command in CLAUDE.md is a repeatable expectation.
Photo by Boris K. on Pexels.
The steps#
The correct setup is short: install the official package, create repository instructions, add project-scoped permissions, verify the resulting diff, and only then widen access. Each step below prevents a specific failure that appears when more than one person or one task touches the repository.
-
Install the official CLI globally with
npm install -g @anthropic-ai/claude-code. This prevents a malformed search phrase such asnpm install anthropic-ai/claude codefrom being mistaken for a valid package command. -
Start Claude Code from the repository root. This prevents the agent from operating with the wrong project context or treating a parent directory as its workspace.
-
Create a committed
CLAUDE.mdat the repository root. This prevents build commands, architectural boundaries, and review expectations from living only in one engineer’s prompt history. -
Create
.claude/settings.jsonwith narrow project permissions. This prevents routine work from silently gaining access to secrets, publishing, destructive Git operations, or unrestricted shell execution. -
Review the instructions and permissions as code. This prevents the second engineer from inheriting invisible local exceptions.
-
Run one bounded maintenance task and inspect both the diff and command history. This prevents a successful-looking answer from becoming the only acceptance signal.
The installation behavior itself belongs to npm, whose npm install documentation distinguishes package installation forms and options. Do not improvise the package name from the keyword. The search query npm install anthropic ai claude code describes intent; it is not the command to paste.
For more installation and setup material, use the agent setup hub. Repository policy, however, should remain inside the repository.
A working configuration#
Use two committed files: CLAUDE.md defines how the repository must be handled, while .claude/settings.json limits which sensitive actions can proceed automatically. The first gives the agent context; the second makes dangerous operations stop or request approval even when a prompt is vague.
Paste this into CLAUDE.md and replace only the commands or paths that differ in your repository:
# Repository operating rules

*Photo by Al Nahian on [Pexels](https://www.pexels.com/photo/computer-program-on-computer-screen-7325498/).*
## Scope
- Work only inside this repository.
- Make the smallest change that satisfies the task.
- Do not modify generated files directly.
- Do not change public interfaces unless the task explicitly requires it.
## Protected data
- Never read, print, copy, or modify `.env` files or anything under `secrets/`.
- Never add credentials, tokens, private keys, or production data to code or logs.

*Photo by Jakub Zerdzicki on [Pexels](https://www.pexels.com/photo/close-up-of-programmer-typing-code-on-laptop-36496927/).*
## Validation
- Run `npm run lint` after changing source files.
- Run `npm test -- --runInBand` before declaring the task complete.
- If either command fails, report the failure; do not weaken or delete the check.
## Git and release boundaries
- Do not push, publish, force-reset, or rewrite history.
- Do not create or modify releases.
- End with a concise summary, validation results, and remaining risks.Each block has one job:
- Scope limits change size and protects generated or public surfaces.
- Protected data states an invariant that should also be enforced by permissions.
- Validation defines completion in commands, not prose.
- Git and release boundaries keep repository inspection separate from external side effects.
Then add .claude/settings.json:
{
"permissions": {
"allow": [
"Bash(npm run lint)",
"Bash(npm test -- --runInBand)",
"Bash(git status --short)",
"Bash(git diff -- *)"
],
"ask": [
"Bash(npm install *)"
],
"deny": [
"Read(./.env)",
"Read(./.env.*)",
"Read(./secrets/**)",
"Bash(git push *)",
"Bash(git reset --hard *)",
"Bash(npm publish *)",
"Bash(rm -rf *)"
]
}
}The configuration is deliberately asymmetric:
| Line or group | What it protects |
|---|---|
| allow | Pre-approves only repeatable validation and read-only Git inspection. |
| ask | Makes dependency changes visible because they can alter manifests and lockfiles. |
| Read(./.env...) and Read(./secrets/**) | Blocks common secret locations even when a task asks for broad investigation. |
| Git, publish, and removal denials | Blocks external or difficult-to-reverse consequences. |
Do not copy commands that your repository does not have. A permission for a fictional test command creates ceremony, not safety. The Claude Code documentation should be the reference for supported settings, while the repository remains the authority for its own validation commands and protected paths.
If you want a fuller handoff system rather than two starter files, the PairFoundry Agent Operating Kit is the natural next step. The point is not more configuration; it is a reviewable operating contract.
What to skip#
Skip setup steps that create activity without creating a durable boundary. Most tutorials optimize for reaching the first prompt quickly. That is the wrong success metric for a repository with secrets, generated artifacts, release controls, or multiple maintainers.
Do not waste time on these:
- Do not create a giant global instruction file. Repository-specific rules become stale or contradictory when mixed across projects.
- Do not pre-approve unrestricted Bash. Convenience is not worth collapsing every command into one permission boundary.
- Do not paste the keyword as a command.
npm install anthropic-ai/claude codeandnpm install anthropic ai claude codedo not identify the official scoped package. - Do not duplicate the entire README in
CLAUDE.md. Include agent-relevant invariants, commands, and prohibitions; link or point to existing project documentation for everything else. - Do not add every possible deny rule on day one. Start with actual secret paths and irreversible commands, then tighten rules when a concrete task exposes a gap.
- Do not install “skills” before the base contract works. Extra automation magnifies weak permissions and unclear repository instructions.
- Do not accept “tests passed” without command output and a diff review. The result must be inspectable by someone other than the agent.
Engineers who need the underlying workflow before adopting a packaged system can follow the free PairFoundry foundations track. The broader PairFoundry packs overview shows the available operating packages without turning this setup into a tool-shopping exercise.
First real task#
Make the first task a bounded repository diagnosis that produces a small, reviewable patch. Do not begin with a migration, dependency overhaul, authentication change, or release. Your first task should reveal whether instructions, permissions, validation commands, and handoff output work together.
A good first prompt is:
Find one source file with a clear local cleanup opportunity.
Propose the smallest safe change before editing.
Do not change dependencies or public interfaces.
After editing, run the repository-required lint and test commands.
Finish with the changed files, validation results, and remaining risks.This task exercises file discovery, reasoning, editing, tests, and reporting without requiring broad authority. If Claude Code requests an unexpected command, stop and decide whether the task genuinely needs it. Do not approve it merely to keep the session moving.
The acceptance test is not “Claude Code completed the prompt.” It is that another engineer can inspect CLAUDE.md, review .claude/settings.json, reproduce the validation, and understand why every changed line exists.
Related reading#
- Getting started with Claude Code — the setup that survives a real repo
- How to set up Claude Code in fifteen minutes, and what to skip
FAQ#
How to install claude code in terminal with npm?#
Run npm install -g @anthropic-ai/claude-code, then launch Claude Code from the repository root. The npm install reference explains npm’s installation forms; the repository configuration above handles the part npm cannot: operational safety.
How to install Anthropic claude code?#
Install the official scoped package, not a package name reconstructed from search keywords. After installation, follow the official Claude Code overview for product onboarding, then commit repository-specific instructions and permissions before assigning real work.
How to install Anthropic skills in claude code?#
Do not install skills first. Establish CLAUDE.md, narrow permissions, and a successful bounded task before adding reusable capabilities. A skill inherits the quality of the operating boundary around it; it does not repair an unsafe repository setup.
How to update claude code installed via npm?#
Use npm to install the current official package globally again, then review the Claude Code documentation for any configuration changes. Treat an update as a tooling change: verify startup, permissions, and one bounded task before normal use.
How to run npm install anthropic ai claude code?#
Do not run that phrase literally. It is a search query, not a valid official installation command. Use npm install -g @anthropic-ai/claude-code, then add the repository-owned configuration described above.