Sub topic 4
Installing and signing in
This chapter covers installing the three tools and signing in to each. It assumes you can use a shell, have Node.js and npm installed, and know what a terminal coding agent is from the earlier chapters.
Installing the tools
All three tools ship as npm packages. A global install puts each command on your PATH.
npm install -g @anthropic-ai/claude-code
npm install -g @openai/codex
npm install -g @github/copilot
cd my-project
claude # start Claude Code
codex # start Codex CLI
copilot # start Copilot CLIStart each tool from the root of the project you want to work on. The agent treats the current directory as its workspace, so the directory you start in decides which files it can see and edit.
Signing in
The first run in a new environment asks you to authenticate. Each tool offers a few ways to do it, and the exact options change between versions. Check each tool's current documentation before you rely on a specific flow.
| Tool | Usual account | Typical sign-in |
|---|---|---|
| Claude Code | Anthropic subscription or API account | Browser login on first run |
| Codex CLI | ChatGPT plan or OpenAI API key | Sign in with ChatGPT, or an API key |
| Copilot CLI | GitHub Copilot subscription | GitHub login on first run |
Your account decides what you can use. Copilot CLI needs a Copilot plan that allows it. Codex CLI and Claude Code can bill either against a subscription or against API usage, and the two billing modes have different limits and costs.
Checking the install
If a command is not found after installation, the usual cause is that npm's global bin directory is not on your PATH. Run npm prefix -g to find the prefix. The executables are in its bin directory on macOS and Linux.
npm prefix -g
claude --version
codex --version
copilot --versionIf a global install fails with a permissions error, do not use sudo. Point npm at a directory you own, or use a Node version manager, so that global packages install under your home directory.
Common problems
- Old Node.js version. These packages require a recent Node.js release. Upgrade Node if the install or the first run reports an engine error.
- Wrong directory. Starting the agent in your home directory gives it a much larger workspace than you intend. Always
cdinto the project first. - Credentials in the wrong place. Never paste API keys into prompts or commit them to a repository. Keep them in environment variables or the tool's own credential store.
- Headless machines. A browser login does not work well over SSH. In that case, use an API key or the tool's device-code or headless login option if it has one.
Exercise
You installed Codex CLI globally, but your shell says codex: command not found. What is the most likely cause, and how do you find the fix?
Show answer
npm's global bin directory is probably not on your PATH. Run npm prefix -g to find the global prefix, then add its bin directory to your PATH. Avoid sudo npm install -g. Use a user-owned prefix or a Node version manager instead.
Exercise
Why should you run claude, codex, or copilot from the project root and not from your home directory?
Show answer
The agent treats the starting directory as its workspace. Starting in the project root limits it to that project's files. Starting in your home directory exposes much more of your system to reads and edits.