Overview
A fresh repository needs three things before Claude Code is productive: an install that works, a short CLAUDE.md, and a backlog file the agent can read and update. This guide installs the CLI, writes the anchor files, and lands one PR with checkable acceptance criteria. Hooks, permissions, and subagents are covered in claude-code.
Prerequisites
- A Git repository with a build or test command that exits non-zero on failure.
ghauthenticated (gh auth status) if Claude Code should open PRs.- A Pro, Max, Team, Enterprise, or Console account; the free claude.ai plan does not include Claude Code.
Steps
1. Install and sign in
curl -fsSL https://claude.ai/install.sh | bash # macOS, Linux, WSL
claude --version
claude doctorOn Windows PowerShell use irm https://claude.ai/install.ps1 | iex; Homebrew (brew install --cask claude-code) and WinGet (winget install Anthropic.ClaudeCode) also work but do not auto-update. npm install -g @anthropic-ai/claude-code installs the same native binary and needs Node 22 or newer; never use sudo with it. Run claude in the repo and finish the browser login.
2. Generate CLAUDE.md, then cut it
Run /init inside a session. It reads the codebase and drafts build commands and conventions. Edit the draft down to what Claude cannot infer from the code: commands, non-default conventions, and a “how to add a X” checklist. Target under 200 lines; longer files cost context and lower adherence. Move path-specific rules to .claude/rules/*.md with paths: frontmatter. See write-claude-md-from-scratch for the section list.
3. Add TODO.md
# TODO
## Active
- [ ] Wire CI to run lint on pull requests.
## Backlog
- [ ] Add an /about page.Commit both files so humans and the agent share one backlog.
4. Land the first PR with acceptance criteria
Give the agent a brief that names files, steps, and checks it can run:
Add a /health endpoint.
Acceptance:
- [ ] `npm test` exits 0
- [ ] `curl localhost:3000/health` returns 200
Non-goals: no auth changes.
Review the diff, then let it open the PR with gh pr create.
Verify it worked
claude --version && git ls-files CLAUDE.md TODO.mdStart a session and run /context; CLAUDE.md should appear under Memory files.
Common errors
claude: command not found. The install directory is not onPATH; open a new terminal or follow the PATH fix in the install troubleshooting page.- Claude ignores a rule.
CLAUDE.mdis context, not enforcement. Make the rule concrete (“use 2-space indentation”), remove contradictions, and move must-run behavior into a hook. - Instructions vanish after
/compact. Only the rootCLAUDE.mdis re-read from disk; conversation-only instructions are lost, so write them into the file. - Secrets in
.claude/settings.json. Keep secrets out of every settings file and read them from environment variables; personal, uncommitted settings belong in.claude/settings.local.json.
FAQ
Which plans include Claude Code?
Pro, Max, Team, Enterprise, and Console accounts include it; the free claude.ai plan does not.
Should I install Claude Code with npm or the native installer?
Prefer the native installer (curl -fsSL https://claude.ai/install.sh | bash). Homebrew and WinGet do not auto-update, and the npm package needs Node 22 or newer and must never run with sudo.
How long should CLAUDE.md be?
Target under 200 lines, keeping only what Claude cannot infer from the code; longer files cost context and lower adherence.
Why does Claude Code ignore a rule in CLAUDE.md?
CLAUDE.md is context, not enforcement. Make the rule concrete, remove contradictions, and move must-run behavior into a hook.
Do instructions survive /compact?
Only the root CLAUDE.md is re-read from disk, so conversation-only instructions are lost; write them into the file.