Claude Code: how it works and why it changes the way you program
Claude Code is an AI terminal agent that reads your code, modifies it, runs commands, and debugs autonomously. Practical guide: installation, basic commands, real use cases.
Published: June 3, 2025
GitHub Copilot suggests the next line as you type. Claude Code is different: it’s an agent that lives in the terminal, reads your entire project, modifies files, runs shell commands, reads the output, fixes errors and iterates — on its own.
The concrete difference: with Copilot you write // function that sorts array and it completes the function. With Claude Code you write “add JWT authentication to this Express app” and it reads all the files, understands the structure, installs missing dependencies, modifies what needs changing, and tells you what it did. Cursor is closer to Claude Code, but stays inside the editor and doesn’t run shell commands autonomously.
Installation
Node.js 18+ required. Then:
npm install -g @anthropic-ai/claude-code
claude --version
On first launch it authenticates via browser OAuth with your Anthropic account. No config files to touch.
Start in a project:
cd /my/project
claude
You’re in the interactive REPL. Talk to the agent in natural language.
How to use it in practice
Useful slash commands to know:
/add src/ → adds files/folders to context
/clear → clears the context
/status → shows files in current context
/commit → creates a git commit with a generated message
/bash <cmd> → runs a specific shell command
Real example. You have an Express app with no authentication:
> /add src/
> Add JWT authentication. Use jsonwebtoken and bcryptjs.
Create /auth/register and /auth/login endpoints.
Protect existing routes with middleware.
Claude Code reads src/, understands the existing routes, installs the packages via npm, creates the middleware, modifies app.js, adds the protection. If there’s a syntax error or a missing dependency, it sees it in the output and corrects itself before showing you the result. You haven’t written a single line of code.
Same approach for sysadmin tasks:
> Write a bash script that checks every 5 minutes if nginx is running,
restarts it if needed, logs everything to /var/log/nginx_monitor.log with timestamps
It writes the script, makes it executable, and suggests how to add it to cron.
When to use it and when not to
It works well on medium-sized projects with a clear structure. If you have 500,000 lines of undocumented legacy code, context gets lost — better to isolate the portion you’re working on.
Don’t give it access to production databases with real data. Don’t use it if your security posture doesn’t allow code going to cloud servers — Claude Code sends files to Anthropic’s servers.
For autonomous edits: always run git diff before each commit to see exactly what it changed. The agent works autonomously, but you need to stay in the loop.
Pricing
Claude Pro ($20/month): includes Claude Code with rate limiting. Enough for occasional use.
Claude Max ($100/month): unlimited use, more powerful models. If you use it 2–3 hours a day, it pays for itself in time saved.
Pay-per-use API: you pay per token. An average refactoring task costs a few cents. Great for evaluating the tool before subscribing.
What to do
- Install with
npm install -g @anthropic-ai/claude-codeand open a project you know well. - Try a simple task first: “add error handling to this function” or “write a test for this module.”
- Scale complexity only after you understand how the agent works — and always check the diff before committing.