How to Get Started with Claude Code CLI: A Practical Guide
I’ve been poking at AI coding tools for a while now—GitHub Copilot, Cursor, you name it. But when Anthropic dropped Claude Code CLI, I figured it was just another chatbot wrapper. I was wrong. After a weekend of messing around, I realized this thing is genuinely useful for certain kinds of work. Here’s what I learned, from signup to actually shipping code.
What Claude Code CLI Actually Is
It’s a command-line tool that lets you talk to Claude (Anthropic’s model) directly from your terminal. No web app, no IDE plugin—just a prompt in your shell. You can ask it to write code, debug, refactor, explain things, or even run shell commands. Think of it as a coding assistant that lives in your terminal and can see your project files.
Who’s it for? Developers who are comfortable in a terminal and want to offload boilerplate, debugging, or quick scripts without switching contexts. If you’re a VS Code person who never touches the command line, this might feel weird. But if you live in tmux or iTerm, it’s gold.
Signing Up and Getting Set Up
First, you need an Anthropic account. Go to console.anthropic.com and sign up. You’ll get some free credits—enough to play around for a couple days. After that, it’s pay-as-you-go. I burned through maybe $5 in my first week of heavy use, so it’s not expensive unless you’re generating entire codebases nonstop.
Once you’re in, grab an API key from the dashboard. Then install the CLI. I’m on macOS, so I used Homebrew:
brew install claude-code
If you’re on Linux or Windows (via WSL), you can use npm:
npm install -g @anthropic-ai/claude-code
After installation, authenticate:
claude login
It’ll ask for your API key. Paste it in, and you’re good. I also set an environment variable so I don’t have to log in every time:
export ANTHROPIC_API_KEY="sk-ant-..."
I added that to my .zshrc for convenience.
Real Tasks I Did with It
I didn’t want to just run demos. I wanted to see if this thing could actually help me with real work. Here are four tasks I threw at it.
Task 1: Generate a Quick API Client
I needed a Python script to hit a REST API and dump some data into a CSV. Normally, I’d write it myself in 10 minutes, but I was lazy. I opened my terminal and typed:
claude "Write a Python script using requests to fetch paginated data from https://api.example.com/users. It should handle pagination with a 'next' link in the response, and save the results to users.csv. Include error handling and rate limiting."
Claude spit out a complete script in about 15 seconds. It used requests.Session, had a time.sleep() between pages, and even added a retry decorator. I tested it against a mock server—it worked first try. Only change I made was to add a user-agent header because the API required it. I asked Claude to add that, and it did.
Takeaway: For small, well-defined tasks, it’s faster than writing from scratch. But you still need to know what you’re doing to validate the output.
Task 2: Refactor a Messy JavaScript File
I had a 400-line Node.js function that parsed CSV files. It was a tangled mess of callbacks and nested conditionals. I pointed Claude at it:
claude "Look at csv-parser.js in the current directory. Refactor it to use async/await, break the main function into smaller helper functions, and add JSDoc comments. Keep the same public API."
It read the file, analyzed it, and returned a refactored version in about 30 seconds. The new code was cleaner, had proper error propagation, and even included comments explaining edge cases I hadn’t documented. I had to tweak one variable name (it renamed data to parsedData which broke a downstream call), but that was a 2-second fix.
Takeaway: Claude is great at refactoring because it sees the whole file context. But always diff the changes before committing—it sometimes renames things arbitrarily.
Task 3: Debug a Weird SQL Query
I was working on a PostgreSQL query that was supposed to find duplicate email addresses in a user table. My query returned zero rows, but I knew there were duplicates. I pasted the schema and query into Claude:
claude "Here's my schema and query. Why is this returning no results? Schema: users(id, email, created_at). Query: SELECT email, COUNT(*) FROM users WHERE COUNT(*) > 1 GROUP BY email;"
It immediately pointed out the error: WHERE COUNT(*) > 1 is invalid in SQL—you need HAVING instead. Then it offered the corrected query and explained why. Saved me 10 minutes of head-scratching.
Takeaway: Claude is surprisingly good at SQL, especially for spotting syntax errors and suggesting optimizations. I’ve since used it to optimize several slow queries.
Task 4: Write a Bash Script for Deployment
I needed a script to deploy a static site to an S3 bucket with CloudFront invalidation. I gave Claude a rough description:
claude "Write a bash script that syncs a local 'dist' folder to an S3 bucket named 'my-site-bucket', then invalidates the CloudFront distribution with ID 'XYZ123'. Use AWS CLI, handle errors, and print progress."
It generated a script with set -e, progress messages, and even a trap for cleanup. I ran it against a test bucket—it worked. The only issue was it used aws s3 sync without --delete, so old files stayed. I asked it to add that, and it did.
Takeaway: For shell scripting, Claude saves time on boilerplate but you still need to understand the underlying commands. It’s not magic—it’s a faster way to write the boring parts.
Tips and Tricks I Picked Up
After a week, here’s what made a difference:
- Be specific about your environment. If you’re using Python 3.12, say so. If you’re on macOS, mention it. Claude’s answers are better when it knows the context.
- Use the
--contextflag for large projects. You can point it to a directory:claude --context ./srcand it’ll read files automatically. This is huge for refactoring. - Ask for explanations, not just code. When something goes wrong, I ask “Explain the error in this log” and paste it. Claude often spots things I miss.
- Iterate. Don’t expect perfect output on the first try. I usually ask for the code, then say “Add error handling” or “Make it work with Python 3.12” and it adjusts.
- Use
--no-streamfor long outputs. By default, Claude streams tokens like a chatbot. For code, I prefer--no-streamso it outputs the full response at once. Less distracting.
What I Wish I Knew Before Starting
A few things that would have saved me time:
- The free tier runs out fast. I burned through my initial credits in a day because I was generating long responses. Set a budget in the Anthropic console early.
- It doesn’t have internet access. Claude can’t fetch URLs or check package versions. If you ask it to use a library, it might suggest an outdated one. Always verify.
- It can’t run code for you. Claude writes code and gives instructions, but it won’t execute anything. You need to run tests yourself. Some tools like Cursor can run code—this one is purely a generator.
- It’s not great for UI code. I tried asking it to generate a React component with complex state management. It worked, but the output was verbose and needed heavy editing. For backend logic, scripts, and data processing, it shines.
- The context window is generous but not infinite. If your project has 50 files, Claude won’t see them all unless you specify. Use
--contextwisely, or break tasks into smaller pieces.
Final Thoughts
Claude Code CLI isn’t a replacement for knowing how to code. It’s a tool that makes you faster at the parts of coding that are tedious or repetitive. I still write my own architecture decisions and review every line it outputs. But for generating boilerplate, debugging syntax, or writing quick scripts, it’s become part of my daily workflow.
If you’re comfortable in a terminal and want to speed up your coding without leaving the command line, give it a shot. Just don’t expect it to build your app for you. It’s a pair programmer who never sleeps and doesn’t judge your messy code—but it also doesn’t know your business logic.
Start with a small task, see how it feels, and go from there. I’m glad I did.