No history yet

Setup and Authentication

Installation and Authentication

Claude Code is an agentic CLI tool that lives in your terminal. As such, the first step is installing it globally using npm. This makes the claude command available from any directory. You'll need Node.js (version 16 or higher) installed on your system for this to work.

npm install -g @anthropic-ai/claude-code

With the tool installed, the next step is authentication. Claude Code needs your API key to connect to Anthropic's models. You can get this key from your Anthropic account dashboard. The recommended way to provide it is by setting an environment variable named ANTHROPIC_API_KEY. This keeps your key separate from your code and out of your shell history.

For security, avoid pasting your API key directly into your terminal. Instead, add the export command to your shell's configuration file, like .zshrc, .bash_profile, or .bashrc.

# Add this line to your shell's config file
export ANTHROPIC_API_KEY='your-api-key-here'

# Then, run this command in a new terminal session
claude auth

Running claude auth verifies that your ANTHROPIC_API_KEY is set correctly and can connect to the service. A success message means you're ready to start using Claude Code.

Initializing a Project

Once authenticated, you need to initialize Claude Code within your project's root directory. Navigate to your local code repository and run the init command.

claude init

This command does two important things. First, it creates a CLAUDE.md file. Think of this as a project README specifically for the AI agent. You can add high-level context, style guides, testing instructions, or information about the project's architecture here. Claude Code reads this file to get up to speed quickly on your codebase.

Second, claude init creates a .claudeignore file. This is crucial for managing which parts of your project the agent can access. It works just like a .gitignore file, allowing you to specify files and directories that Claude should not read. This is essential for both privacy and performance.

Your developers can move seamlessly from discussing architecture in Claude.ai to implementing solutions in their terminal with Claude Code.

Configuring Project Scope

By default, the .claudeignore file is populated with common patterns to exclude sensitive information and unnecessary clutter. You should review and customize this file for your specific project.

# Example .claudeignore

# Ignore compiled output and dependencies
node_modules/
dist/
build/

# Ignore environment variables and secrets
.env
*.pem
*.key

# Ignore Git directory
.git/

# Ignore large assets
*.mp4
*.zip

Properly configuring this file prevents the agent from reading secret keys, API credentials, or personal configuration files. It also stops it from wasting time (and tokens) analyzing large dependency folders or build artifacts, keeping it focused on your source code.

PatternPurpose
node_modules/Excludes all package dependencies.
.envHides environment variables and secrets.
*.logIgnores application log files.
build/Excludes compiled output directories.

With installation, authentication, and project initialization complete, your environment is now fully configured. You have a secure session and a correctly scoped workspace, ready for you to start collaborating with the Claude Code agent.

Quiz Questions 1/4

What is the primary prerequisite for installing the Claude Code CLI tool using npm?

Quiz Questions 2/4

After running claude init in your project, you'll find a new CLAUDE.md file. What is the main purpose of this file?