You’ve heard about Claude Code. Maybe you’ve seen demos of it writing entire features, running tests, and deploying code — all from natural language. But when you open the terminal for the first time, where do you actually start?
This Claude Code tutorial for beginners walks you through building a real project from scratch. No theory dumps. No feature lists. Just hands-on steps you can follow along with right now.
By the end, you’ll have a working project built with Claude Code, and the confidence to use it on your own codebase.
Prerequisites
Before we start, you need three things:
- Node.js 18 or higher — check with
node --version - A terminal — Terminal.app (Mac), Windows Terminal, or any Linux terminal
- A Claude account — either an Anthropic API key or a Claude Max subscription
That’s it. No VS Code extensions. No special IDE. Claude Code runs in any terminal.
Step 1: Install Claude Code
Open your terminal and run:
npm install -g @anthropic-ai/claude-code
Verify the installation:
claude --version
You should see the version number printed. If you get a “command not found” error, make sure your npm global bin directory is in your PATH.
Step 2: Authenticate
Run Claude Code for the first time:
claude
It will walk you through authentication. You have two options:
- API key: Paste your Anthropic API key from console.anthropic.com
- Claude Max: Log in with your Anthropic account for subscription-based usage
Once authenticated, you’ll see Claude Code’s prompt. Type /help to confirm everything is working, then exit with Ctrl+C — we’ll come back after creating our project.
Step 3: Create Your Project
Let’s build something real: a REST API for a task manager. We’ll use Node.js and Express because they’re simple and widely understood.
First, create the project directory:
mkdir task-api && cd task-api
Now launch Claude Code inside the project:
claude
Step 4: Generate the Project Scaffold
Here’s where Claude Code shines. Instead of manually creating files, tell it what you want:
Create a Node.js REST API project with Express. Set up the following:
1. package.json with express, cors, and uuid as dependencies
2. A src/index.js entry point that starts an Express server on port 3000
3. A src/routes/tasks.js file with CRUD endpoints for tasks (GET all, GET by ID, POST, PUT, DELETE)
4. Tasks stored in-memory as an array
5. A .gitignore for node_modules
6. An npm start script
Use CommonJS modules (require/module.exports).
Claude Code will create all these files for you. Watch the output — it shows each file being created and its contents. Review each one before approving.
After it finishes, you should have a project structure like:
task-api/
├── package.json
├── .gitignore
└── src/
├── index.js
└── routes/
└── tasks.js
Step 5: Install Dependencies and Run
Tell Claude Code to install and start the server:
Run npm install, then start the server
Claude Code will execute both commands. You should see output like:
Server running on http://localhost:3000
Open a new terminal tab and test it:
curl http://localhost:3000/api/tasks
You should get an empty array []. Your API is running.
Step 6: Add Your First Feature
Let’s add input validation. Instead of writing the code yourself, describe what you want:
Add input validation to the POST /api/tasks endpoint:
- title is required and must be a non-empty string
- Return 400 with a clear error message if validation fails
- Add a "createdAt" timestamp to each new task
Claude Code will edit src/routes/tasks.js to add validation logic. It shows you the diff — the exact lines added and removed. Review it carefully.
Test the validation:
# This should fail with 400
curl -X POST http://localhost:3000/api/tasks \
-H "Content-Type: application/json" \
-d '{}'
# This should succeed with 201
curl -X POST http://localhost:3000/api/tasks \
-H "Content-Type: application/json" \
-d '{"title": "Learn Claude Code"}'
Step 7: Write Tests
Testing is where Claude Code saves the most time for beginners. You don’t need to know testing syntax — just describe what to test:
Add tests for the tasks API using the built-in Node.js test runner (node:test). Create src/tests/tasks.test.js that tests:
1. GET /api/tasks returns empty array initially
2. POST /api/tasks creates a task and returns 201
3. POST /api/tasks with empty body returns 400
4. GET /api/tasks/:id returns the correct task
5. DELETE /api/tasks/:id removes the task
Use the native fetch API for HTTP requests. Start the server in beforeEach and close it in afterEach.
Claude Code creates the test file and may also modify src/index.js to export the server instance for testing.
Run the tests:
Run the tests
Claude Code executes the test command. If any tests fail, it will read the error output, identify the problem, and fix it — often in the same turn.
Step 8: Add Error Handling
Production APIs need proper error handling. Tell Claude Code:
Add centralized error handling:
1. Create a middleware in src/middleware/errorHandler.js
2. Handle 404 for unknown routes
3. Handle unexpected errors with a 500 response
4. Log errors to console with timestamps
5. Wire it into the Express app
Claude Code creates the middleware and updates src/index.js to use it. This is a pattern you’ll use constantly — describe the architecture you want and let Claude Code implement it.
Step 9: Set Up Your CLAUDE.md
Now that the project has taken shape, create a CLAUDE.md file so Claude Code understands your project’s conventions:
Create a CLAUDE.md file for this project that documents:
- The project structure
- That we use CommonJS modules
- That tests use the Node.js built-in test runner
- That the server runs on port 3000
- The API endpoint patterns
In future sessions, Claude Code reads this file automatically and follows your conventions without being reminded.
Step 10: Initialize Git and Make Your First Commit
Initialize a git repository. Stage all files and create an initial commit with the message "feat: initial task API with CRUD, validation, tests, and error handling"
Claude Code runs git init, git add, and git commit. You now have version-controlled code with a clean commit history.
What You Just Built
In about 30 minutes, you created:
- A REST API with full CRUD operations
- Input validation with proper error responses
- Automated tests with the Node.js test runner
- Centralized error handling middleware
- A CLAUDE.md project configuration
- A clean git repository
You didn’t write any of the code by hand. But you made every architectural decision — what framework to use, how to structure the project, what validation rules to apply, how to handle errors. Claude Code was the executor; you were the architect.
Common Beginner Questions
”Can Claude Code break my existing project?”
It can, which is why you should always:
- Work on a git branch, not
main - Review every diff before approving
- Run your tests after each change
Claude Code is powerful. Treat it like a very fast junior developer — capable, but needs supervision.
”How do I undo a change?”
If Claude Code made an edit you don’t like:
- Immediately: Tell Claude Code to revert the change
- After approving: Use
git checkout -- <file>to restore the file - Multiple files: Use
git stashorgit reset --hard HEAD
”Is it better than Cursor or Copilot?”
Different tools for different workflows. Cursor and Copilot work inside an IDE with autocomplete. Claude Code works in your terminal with full agent capabilities — it can run commands, create PRs, and manage multi-file changes. For a detailed comparison, read our Claude Code vs Cursor vs Copilot breakdown.
”How much does it cost?”
Claude Code uses Anthropic API tokens. A typical development session costs $0.50–$5.00 depending on codebase size and task complexity. Claude Max subscribers get Claude Code included in their subscription.
”What languages does it support?”
All of them. Claude Code works with any language or framework — JavaScript, Python, Rust, Go, Ruby, Java, C#, Swift, PHP, and more. It reads your files and adapts to whatever stack you’re using.
Level Up: Skills for Beginners
Once you’re comfortable with the basics, skills make Claude Code dramatically more useful. Instead of writing detailed prompts every time, you invoke a skill by name:
| Skill | What It Does |
|---|---|
/generate-tests | Writes comprehensive tests for any code |
/code-review | Reviews changes for bugs, security, and style |
/explain | Explains complex code in plain language |
/refactor | Improves code structure without changing behavior |
/security-audit | Checks for OWASP vulnerabilities |
Claude Skills 360 offers 360 free skills to get started, or you can unlock 2,350+ skills for $39 — a one-time purchase with lifetime updates.
Next Steps
You’ve completed your first Claude Code project. Here’s where to go from here:
- Try it on your own codebase — launch Claude Code in an existing project and ask it to explain the architecture
- Read the how to use Claude Code guide — covers advanced patterns, MCP servers, and cost management
- Check out the getting started quickstart — a condensed reference for developers who want the essentials fast
- Explore autonomous agents — build agents that handle complex multi-step workflows
- Set up MCP servers — connect Claude Code to databases, APIs, and cloud platforms
The hardest part is already done — you’ve started. Everything from here is iteration.