Getting Started with Claude Code: Installation to Your First Working Script

Get your first Claude Code agent running with practical prompts that deliver real results from session one — no prior AI coding experience required.

Author:
Codapress Publishing
Date:

Claude Code is Anthropic’s terminal-native coding agent — an AI assistant that works inside your project directory, reads and writes files, runs shell commands, and handles multi-step development tasks. Unlike a chat interface, it operates as an autonomous agent: you give it a goal, and it iterates until the job is done. When you run claude in a project, it launches an agent loop — reading your prompt, deciding which tools to use, executing them, and repeating until the task is complete. This guide covers installation, authentication, and your first productive session.

Before you start: prerequisites

RequirementDetails
Node.js 18+Download from nodejs.org or install via your package manager
A modern terminalmacOS Terminal, iTerm2, Windows Terminal, or the VS Code integrated terminal
Anthropic accountFree tier at console.anthropic.com with an initial credit allowance
Internet connectionClaude Code communicates with Anthropic’s API

Installing the Claude Code CLI

Open your terminal and run:

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

The -g flag makes the claude command available globally. On macOS and Linux, you may see permissions errors. If so, use:

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

Or configure npm for global installs without sudo by following the npm EACCES resolution guide.

Confirm the installation:

claude --version

If the command is not found, your npm global bin directory is probably not in your PATH. Run npm bin -g to locate it, then add it to your shell profile:

echo 'export PATH=$(npm bin -g):$PATH' >> ~/.zshrc
source ~/.zshrc

Authenticating with Anthropic

Claude Code needs an API key to communicate with Anthropic’s models. The first time you run claude, it prompts you to authenticate through your browser and handles the key exchange automatically. Alternatively, export the key manually:

export ANTHROPIC_API_KEY=sk-ant-...

Generate a new key from the Anthropic Console, where you can also monitor usage and set spending limits. Add the export to your shell profile (~/.zshrc, ~/.bashrc, or equivalent) for persistence, or use a .env file in your project root for per-project configuration — handy when switching between multiple accounts or teams.

Your first interactive session

Create a fresh directory and start Claude Code:

mkdir ~/projects/claude-first-project
cd ~/projects/claude-first-project
claude

The agent initialises and presents a prompt. Start with a straightforward request:

Initialise this directory as a JavaScript project. Create a package.json,
a main.js file that prints "Hello from Claude Code" to the console,
and a README.md that explains the project. Run the script to confirm
it works, then show me the output.

Claude Code creates the files, runs npm init, and executes the script to verify the output. You see every command it runs and every file it changes. If the result needs adjustment, ask in natural language — no need to re-prompt from scratch.

Writing your first utility script

A todo list manager is a classic first project because it touches file I/O, argument parsing, and user experience.

Create a Node.js script called todo.js that:
- Stores tasks in a JSON file called tasks.json
- Supports three commands: add, list, and done
  - node todo.js add "Buy groceries" adds a task
  - node todo.js list shows all tasks with their status
  - node todo.js done 1 marks the first task as complete
- Uses colours in the terminal output for readability
- Handles errors gracefully (missing file, invalid task number)

Write the script, run each command to verify it works, and show me
the final output.

This is an outcome-based prompt — you describe what the script should do rather than dictating the implementation. The same approach works across popular AI coding tools, and the AI Coding Prompt Playbook covers it in depth.

Prompting effectively from the start

The quality of Claude Code’s output depends more on how you prompt than on the underlying model.

Effective promptIneffective prompt
”Create a Python script that reads a CSV and generates a bar chart — use pandas and matplotlib, handle missing values gracefully""Make a chart from this data"
"Write a React component with a searchable dropdown and keyboard navigation — use TypeScript and Tailwind""Add a dropdown"
"Refactor the auth module to use async/await, preserve existing error handling, and add unit tests""Fix the auth module”

Anthropic’s prompt engineering guide covers chain-of-thought prompting, structured output formats, and multi-shot examples — all applicable whether you are using Claude Code or another LLM-based tool.

Working with an existing project

Claude Code works equally well in established repositories. Running claude inside an existing project gives the agent full codebase context — it reads your files, understands your patterns, and suggests changes that fit.

A good first task:

Read through this project's package.json and main source files, then
tell me:
1. What framework and dependencies this project uses
2. How the routing is structured
3. Where the main entry point is
4. Whether there are test files and what framework they use

Summarise your findings and suggest one improvement.

For a full treatment of AI agents in larger projects, Claude Code Pro covers MCP servers, custom slash commands, and CI/CD integration.

Troubleshooting common setup issues

SymptomMost likely causeFix
command not found: claudenpm global bin not in PATHAdd $(npm bin -g) to your shell config
EACCES permission errorsnpm lacks write accessUse sudo or reconfigure npm global prefix
Authentication failsInvalid or expired API keyGenerate a new key at console.anthropic.com
Slow sessionLarge project context or rate limitsWork in a focused subdirectory; check usage in the Anthropic Console

See the Claude Code documentation for advanced configuration and custom slash commands.

Next steps

You now have a working Claude Code setup, have run your first interactive session, and know how to prompt the agent effectively. From here, consistent use is the fastest path to fluency. Let Claude Code handle scaffolding, boilerplate, and routine tasks while you focus on architecture and decisions.

Start each coding session with claude open in your project directory. Use it to write tests, refactor existing code, generate documentation, and scaffold entire features from a single prompt. The more you delegate to the agent, the more you discover what it handles well and where your oversight adds the most value.

For a comprehensive reference on prompting patterns and team workflows, see A Simple Guide to Claude Code. For production-level patterns and enterprise setup — including MCP servers and custom slash commands — Claude Code Pro covers the full depth of the tool.

The more you use Claude Code, the more natural the workflow becomes. Before long, starting a session feels as routine as opening your editor.

More insights

All Articles