Getting Started: From Zero to Code in Minutes
Getting Started: From Zero to Code in Minutes
Section titled “Getting Started: From Zero to Code in Minutes”Let’s get our hands dirty. This chapter is all about action. We’ll walk through the entire process from checking prerequisites to generating your first piece of code with Claude Code. This is your ‘Hello, World!’ moment with an AI pair programmer.
Prerequisites
Section titled “Prerequisites”Before we begin, ensure your development environment meets the following requirements:
- Operating System: macOS 10.15+, Windows 10+ (with WSL2), or a modern Linux distribution (like Ubuntu 20.04+).
- Node.js: You’ll need Node.js version 18.0 or newer.
- Anthropic Account: An active Anthropic account with billing enabled or a Pro subscription. You will need an API key to communicate with the service.
- A Project Directory: Have a code project you can work in. If you don’t have one, creating an empty directory is fine for now.
The Installation Process
Section titled “The Installation Process”Claude Code is distributed as an npm package, which makes installation a breeze. Open your terminal and run the following command to install it globally on your system:
# Install Claude Code globally using npmnpm install -g @anthropic-ai/claude-codeOnce the installation is complete, you can verify it by running the claude command with the help flag:
claude --helpThe first time you run a command that requires authentication, Claude Code will open a browser window, asking you to log in with your Anthropic account and authorize the CLI. Simply follow the on-screen instructions to connect your account.
Your “Hello, World!” with an AI Pair Programmer
Section titled “Your “Hello, World!” with an AI Pair Programmer”Now for the exciting part. Navigate into a project directory (or any directory) and start the Claude Code interactive session:
# Navigate to your project foldercd /path/to/your-project
# Start the interactive sessionclaudeYou’ll be greeted by the Claude Code prompt. Let’s ask it to write a classic ‘Hello, World!’ function in Python and save it to a file. Type the following prompt and press Enter:
> Create a new file named main.py with a python function that prints 'Hello, AI World!'Claude Code will analyze your request, propose a plan (creating a new file with the specified content), and ask for your permission to proceed. It will look something like this:
I will create the file `main.py` with the following content:
--- main.py+++ main.py@@ -0,0 +1,3 @@+def say_hello():+ print("Hello, AI World!")+
[y]es, [n]o, [a]lways, [e]dit, [d]iff, [m]ore, [?] >Press y and then Enter. Claude Code will execute the plan, creating the main.py file in your directory. You’ve just successfully collaborated with an AI to write code. Congratulations!