Lesson 1.1 — Install Claude Code and Verify Authentication
Module 1 — Environment Setup & First Session
ClaudeForge | Hands-On Claude Code & Claude Skills
The Naive Approach Trap
Most developers discover Claude Code the same way: they Google "Claude
terminal", find the npm package, run npm install -g @anthropic-ai/claude-code,
copy their API key from console.anthropic.com, export it into their shell,
and assume they are done. This works — Claude Code starts up — but they
have just wired every terminal session for the rest of the course to bill
per-token at API rates instead of using their flat-rate Pro subscription.
The failure is invisible. Claude Code never logs "you are in API mode."
There is no warning when ANTHROPICAPIKEY is present. A typical Module 3
batch-processing session that touches a 50-file Python codebase can consume
300,000–600,000 tokens. At Sonnet 4 API pricing that is $0.90–$1.80 per
run. Run it a few times while debugging and you have spent more than a
month of Pro. The Pro subscription costs $20/month and covers all of that
usage under a shared quota — but only if the env var is absent.
The second trap is sudo npm install -g on macOS. It installs cleanly but
sets the global package directory owner to root. Every subsequent npm install
-g for other packages — including @modelcontextprotocol/inspector in
Lesson 4.5 — throws EACCES permission errors until you fix the npm prefix.
The Failure Mode
The ANTHROPICAPIKEY override is documented but easy to miss. When
Claude Code starts, it checks for the env var before checking for a stored
OAuth token. The precedence order is:
ANTHROPIC_API_KEYenv var — API billing, takes priorityStored OAuth token from
claude login— Pro subscription billing
If ANTHROPIC_API_KEY is exported in your .bashrc or .zshrc — perhaps
set weeks ago for a different project — Claude Code silently uses it. You
will see ✓ Connected either way. The difference only appears on your
Anthropic console billing page at the end of the month.
The npm permission failure manifests as:
npm error code EACCES
npm error path /usr/local/lib/node_modules
npm error errno -13
This happens because sudo npm install -g installs to /usr/local/lib
with root ownership. Fix: configure npm to use a user-owned prefix before
the first global install.
Node version mismatch is the third common failure. Claude Code requires
Node.js 18+. Running on Node 16 (still the default on some Ubuntu 22.04
installs) produces:
error: The engine "node" is incompatible with this module.
Expected version ">=18". Got "16.x.x"
The ClaudeForge Architecture
Lesson 1.1 establishes the authentication foundation that every subsequent
lesson depends on. Nothing in the ClaudeForge system works until this is
correct.
[Developer Machine]
├── Node.js 20 LTS
├── Claude Code CLI (global npm package)
│ ├── Auth path A: OAuth token (claude login) ──→ Pro subscription
│ └── Auth path B: ANTHROPICAPIKEY env var ──→ API billing
└── CLAUDE.md (added in Lesson 1.4)
Lesson 1.2 builds directly on this: the claude interactive session only
opens if auth is valid. Lesson 1.4's CLAUDE.md is read at every session
start — but only after auth succeeds. Module 3's headless -p calls and
Module 4's MCP servers both inherit whichever auth path you establish here.
For Modules 1–7 and the Capstone: use OAuth (claude login).
For Module 8 Artifact lessons only: set ANTHROPICAPIKEY.
Never have both active simultaneously unless you intend API billing.