Step-by-step guide to using Claude Code for AI-assisted development. Installation, setup, commands, prompts, and tips for getting the most out of Anthropic's coding tool.
How to Use Claude Code: Complete Beginner's Guide
Claude Code is Anthropic's terminal-based AI coding assistant. It's powerful but different from tools like Copilot or Cursor.
This guide walks you through everything: installation, setup, essential commands, effective prompting, and real workflows.
Prerequisites
Before installing Claude Code, you need:
- Node.js 18+ - Check with
node --version
- Claude Pro subscription - $20/month at claude.ai
- Terminal comfort - Basic command line skills
- A code editor - VS Code, Vim, whatever you prefer
Installation
Option 1: npm (Recommended)
npm install -g @anthropic-ai/claude-code
Option 2: Homebrew (Mac)
brew install claude-code
Option 3: Direct Download
Visit the Claude Code releases page and download for your platform.
Verify Installation
claude --version
You should see the version number. If not, check your PATH.
First-Time Setup
1. Authenticate
Run Claude Code for the first time:
claude
It will open a browser for authentication. Log in with your Claude Pro account.
2. Navigate to Your Project
cd /path/to/your/project
claude
Claude Code automatically reads your project structure.
3. Start Chatting
You'll see a prompt:
>
Type your question or task. Claude Code is now ready.
Essential Commands
Chat Commands
| Command |
What It Does |
/help |
Show all commands |
/clear |
Clear conversation |
/compact |
Summarize and free context |
/cost |
Show token usage |
/quit or Ctrl+C |
Exit Claude Code |
Context Commands
| Command |
What It Does |
/add <file> |
Add file to context |
/remove <file> |
Remove file from context |
/files |
Show files in context |
Mode Commands
| Command |
What It Does |
/chat |
Conversation mode (no edits) |
/edit |
Allow file editing |
/agent |
Full autonomous mode |
Basic Usage
Asking Questions
Just type your question:
> How does authentication work in this app?
Claude Code reads relevant files and explains.
Requesting Changes
Be specific about what you want:
> Add a logout button to the navbar component
Claude Code will:
- Find the navbar component
- Propose changes
- Ask for confirmation
- Apply the edit
Reviewing Changes
Before any edit, Claude Code shows a diff:
+ <button onClick={handleLogout}>Logout</button>
Type y to accept, n to reject, or ask for modifications.
Effective Prompting
Bad Prompts
> make it better
> fix the bugs
> add some features
Too vague. Claude Code can't read your mind.
Good Prompts
> Add input validation to the user registration form.
Validate email format, password length (min 8 chars),
and show inline error messages.
Specific, actionable, with clear requirements.
Best Prompts
> Add input validation to the user registration form:
- Email: valid format, unique check against database
- Password: min 8 chars, 1 uppercase, 1 number
- Display errors inline under each field
- Use our existing ErrorMessage component
- Add tests for all validation rules
Comprehensive context, references existing patterns, includes testing.
Real Workflow Examples
Example 1: Add a Feature
> Add a dark mode toggle to the settings page.
Store preference in localStorage and apply
CSS variables for theming.
Claude Code will:
- Create theme CSS variables
- Add toggle component
- Implement localStorage persistence
- Update settings page
- Apply theme on page load
Example 2: Debug an Issue
> Users report that form submission fails silently
on mobile. The submit button is in ContactForm.tsx.
Find and fix the issue.
Claude Code will:
- Read the form component
- Trace the submission flow
- Identify the mobile-specific issue
- Propose a fix
Example 3: Refactor Code
> Refactor the user service to use the repository
pattern. Keep the same public interface but
separate data access logic.
Claude Code will:
- Analyze current implementation
- Create repository interface
- Implement repository
- Update service to use repository
- Ensure tests still pass
Example 4: Learn a Codebase
> Explain the data flow from when a user clicks
"Purchase" to when the order is saved in the database.
Claude Code will:
- Trace the click handler
- Follow API calls
- Explain backend processing
- Show database interactions
Tips for Best Results
1. Provide Context
If something is unusual about your project, say so:
> We use a custom ORM called DataLayer instead of Prisma.
Add a new model for blog posts.
2. Reference Existing Patterns
> Add a UserProfile component following the same
pattern as the existing UserCard component.
Claude Code will match your conventions.
3. Ask for Explanations
> Before making changes, explain your approach
and any trade-offs.
Great for learning or validating decisions.
4. Iterate
Start broad, then refine:
> Add user notifications
[Claude Code proposes solution]
> Also add email notifications for important ones
[Claude Code extends solution]
5. Use Git
Always commit before big operations:
git add -A && git commit -m "checkpoint before refactor"
If Claude Code makes mistakes, you can revert.
Common Workflows
Daily Development
- Start Claude Code in your project
- Work in your editor normally
- When stuck, ask Claude Code
- Accept helpful changes
- Continue coding
Code Review
> Review the changes in src/services/payment.ts
for security issues and potential bugs.
Documentation
> Generate JSDoc comments for all exported
functions in the utils folder.
Testing
> Write unit tests for the OrderService class.
Cover happy path and error cases.
Troubleshooting
"Context too long"
Your project is huge. Options:
- Use
/compact to summarize
- Focus on specific directories
- Add a
.claudeignore file
Slow responses
Complex tasks take time. For faster responses:
- Be more specific
- Work on smaller chunks
- Check your internet connection
Wrong file edited
Claude Code sometimes picks the wrong file. Be explicit:
> Edit src/components/Button.tsx (not the one in tests)
Authentication issues
Re-authenticate:
claude logout
claude login
Advanced Usage
Custom Instructions
Create .claude/config.json in your project:
{
"instructions": "Always use TypeScript. Prefer functional components. Follow existing ESLint rules."
}
Ignore Files
Create .claudeignore:
node_modules/
dist/
*.log
secrets.json
Hooks
Claude Code supports hooks for automation:
{
"hooks": {
"post-edit": "npm run lint --fix"
}
}
Runs linter after every edit.
Claude Code vs Other Tools
When to Use Claude Code
- Complex, multi-file tasks
- Deep reasoning required
- Refactoring at scale
- Understanding unfamiliar code
When to Use Other Tools
- Quick inline completions → GitHub Copilot
- Full IDE experience → Cursor
- Simple one-off questions → Claude.ai
Quick Reference
Start Claude Code
cd your-project
claude
Common Tasks
| Task |
Prompt |
| Add feature |
"Add [feature] to [component]" |
| Fix bug |
"Fix [description] in [file]" |
| Refactor |
"Refactor [thing] to [pattern]" |
| Explain |
"Explain how [thing] works" |
| Test |
"Write tests for [component]" |
| Document |
"Add documentation to [file]" |
Key Commands
| Command |
Purpose |
/help |
All commands |
/clear |
Fresh start |
/compact |
Save context |
/cost |
Token usage |
y |
Accept change |
n |
Reject change |
Next Steps
- Install Claude Code and authenticate
- Try it on a small project to get comfortable
- Build a feature with Claude Code's help
- Tackle a complex refactor to see its full power
- Integrate into daily workflow as a power tool
Claude Code has a learning curve, but the payoff is significant. Developers who master it report 2-5x productivity gains on complex tasks.
Need help setting up AI development workflows for your team? Cedar Operations helps companies integrate AI tools effectively. Book a consultation →
Related reading: