...

/

Installing and Launching Claude Code

Installing and Launching Claude Code

Install, authenticate, and configure Claude Code for instant, hassle-free use in future lessons.

We’ve established the core principle of tool use that gives Claude Code its power. Now it’s time to get that power working on your machine. By the end of this lesson, you’ll have Claude Code installed, authenticated, and running.

Press + to interact

This process is straightforward, but precision is key. We’ll walk through it step-by-step.

How to install Claude Code

Before installing anything, verify that your system is ready. Skipping this quick check can turn minor issues into major headaches.

First, ensure the environment meets these minimum requirements mentioned below.

  • Operating system: macOS 10.15 or later, a modern Linux distribution. Another option can also be Windows 10 or later, with WSL or Git Bash.

  • Hardware: At least 4 GB of RAM.

Next, the most important software dependency is Node.js. Let’s check if you have the correct version. Open your terminal and run this command:

node -v

If you see a version like v18.0.0 or later, you’re good to go. If you see an error or an older version, install or update Node.js from the official website before proceeding.

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

Now, note a critical point. If the command fails with a permission error, do not prefix it with sudo. Using sudo with npm install -g can create permission problems and security risks. Instead, use a Node version manager such as nvm, or configure npm to use a different directory.

How to use Claude Code

With the installation complete, it’s time to run the tool for the first time. In any existing project directory, run:

claude

On first run, Claude Code asks you to authenticate. Choose one of the paths mentioned below.

  • Claude.ai subscription: If you have a Claude Pro or Max subscription, log in with your Claude.ai account.

  • Anthropic Console: This common option opens a browser window for you to log in with your Anthropic account. It requires active billing in the Anthropic Console.

For now, choose the option that fits your account and follow the on-screen instructions.

Ignore the API key fields you see above the terminal for the moment. Start the terminal by selecting “Click to Connect...,” then follow the steps below to complete authentication.

Terminal 1
Terminal
Loading...

Let’s walk through exactly what you should expect to see.

  1. Choose your theme: The first screen is “Welcome,” which asks you to choose a text style for the terminal. Use the arrow keys to select an option and press “Enter.” You can change this later with the /theme command.

  2. Select your login method: Choose either your Claude subscription or an Anthropic Console account, as described above.

  3. Authenticate in your browser: After choosing, Claude Code attempts to open your default browser to an authentication page. If it doesn’t open, the terminal provides a long URL. Copy the URL and paste it into your browser.

  4. Review the security notice: After successful authentication, the terminal displays “Welcome to Claude Code” with two important security notes. These reminders explain that you are responsible for reviewing the code Claude generates and that you should use the tool only in the codebases you trust. Press “Enter” to continue.

  5. Respond to the trust prompt: Claude Code asks, “Do you trust the files in this folder?” To do its job, it needs permission to read and potentially execute files in the current directory. Proceed only in trusted projects. Select “Yes, proceed,” then press “Enter.”

Press + to interact

After you grant trust, you land in the main Claude Code interface. You’ll see a welcome box with helpful commands and tips. The > prompt at the bottom indicates that Claude Code is ready for your first command.

How does the Claude Code authentication normally work?

Now that you’ve successfully authenticated with Claude Code, let’s understand what just happened and how we’ve made this process easier for you in future lessons.

When you run Claude Code for the first time, it requires authentication to connect to Anthropic’s servers. This authentication process involves a few steps, outlined below.

  1. Interactive login: You must manually log in through a browser window every time you set up Claude Code on a new machine.

  2. Token storage: Claude Code stores authentication tokens in hidden files on your system (~/.claude/.credentials.json and ~/.claude.json).

On Educative, each lesson starts with a fresh terminal environment where authentication credentials are not preserved between sessions. Without the solution below, you would need to authenticate in every lesson, creating unnecessary interruptions to the learning process.

To eliminate this repetitive authentication, we've developed a solution that uses environment variables to automatically configure your Claude Code authentication. To take advantage of this streamlined process, you need to configure your environment variables once. Here’s how:

  1. Exit your current Claude Code session by typing /exit and pressing “Enter” to close Claude Code.

  2. Make the setup script executable and run it with the following command:

./variables.sh

This script will show you exactly which environment variables you need to set based on your authentication method (API key vs. subscription). When you run the variables.sh script, it peforms a number of functions, outlined below.

  • Detects your authentication type: Identifies whether you’re using an API key or an OAuth subscription.

  • Shows required variables: Displays only the environment variables you need for your specific setup.

The required environment variables must be filled in in the API key fields located above the terminal interface.

Once you’ve set these environment variables, Claude Code will start instantly in all future lessons without requiring manual authentication.

If you encounter the following error:

API Error: 401 {“type”:“error”,“error”:{“type”:“authentication_error”,“message”:“OAuth tokenhas expired. Please obtain a new token or refresh your existing token.”}}

Log in again and update CLAUDE_ACCESS_TOKEN, CLAUDE_REFRESH_TOKEN, and CLAUDE_EXPIRES_AT with the new values. Then, exit Claude Code in any terminal and run: ./variables.sh.

Additionally, whenever you run a terminal or code widget in this course, you may see a warning about missing fields. This is expected and simply means one of the authentication methods isn’t available for users on a Claude Pro/Max subscription, or those using just an API key. In all cases, you should select “Continue anyway,” and the code will run normally.

Conclusion

Congratulations! You’ve installed Claude Code, completed the initial authentication, and configured Educative’s environment variable setup. Although this took some work, you’ve removed authentication friction for the rest of the course.

Starting with the next lesson, Claude Code will start with a single command, so you can focus on learning AI-powered development instead of wrestling with setup. You now have one of the most powerful AI coding tools at your fingertips, preconfigured and ready to support your software development.

In the remainder of this course, we’ll engage in real coding sessions with Claude Code and explore the fundamental patterns that make AI-assisted development effective.