The period of getting to copy-paste code from an AI chat tab into your code editor has come to an finish some time in the past. AI-powered coding assistants have change into more and more subtle, with instruments like Aider exhibiting how highly effective command-line AI integration could be for improvement workflows. As a draw back, these instruments usually require you to be taught particular instructions and syntax to speak successfully with the AI.
Claude Code builds on this basis with a extra intuitive strategy. As an alternative of memorizing instructions, you possibly can describe what you wish to do utilizing pure language.
Getting Began
Obtain the challenge supplies through the Obtain Supplies hyperlink on the prime and backside of this web page. Subsequent, unzip the challenge someplace for later use.
To observe together with this tutorial, you’ll must have the next put in:
With that taken care of, it’s time to take a better have a look at what you are able to do with Claude Code and easy methods to set up it.
What’s Claude Code?
Claude Code is an agentic command line software. That’s a elaborate time period for a CLI program that may perceive what you wish to accomplish after which determine and execute the steps to do it, relatively than simply working one particular command at a time. As an alternative of getting to change forwards and backwards between your code editor and an AI chat tab, you possibly can delegate coding duties on to Claude proper out of your command line.
Consider it as a wise assistant that may enable you with something you should do, with entry to a variety of instruments and assets. It’s designed to streamline your improvement course of by bringing Claude‘s coding capabilities proper the place you’re already working.
Establishing Claude Code
Earlier than delving into the set up, you should know that utilizing Claude Code isn’t free.
Claude Code wants both a Claude subscription or an Anthropic API key to operate. If you happen to can swing it, I’d strongly suggest getting an annual Claude Professional subscription — it’s way more cost-effective than paying per API name since Claude Code can burn by way of tokens shortly.
Unsure if Claude Code is value it? Seize an API key and cargo it with $10 in credit score. That’ll get you thru this tutorial with some tokens left over to experiment.
No matter possibility you go along with, the subsequent step is to put in Claude Code!
Set up
Open a brand new terminal window and run the command beneath to put in Claude Code:
npm set up -g @anthropic-ai/claude-code
It is best to see the next message after the set up is full:
Configuring Claude Code
Whenever you run Claude Code for the primary time, it’s going to ask you to set a colour mode, select no matter appears to be like finest in your terminal. After that, you’ll get requested in your login technique:
If in case you have a Claude Professional or Max account, select possibility 1 right here and it’ll attempt to open an internet browser to check in along with your account. If you happen to choose to make use of your Anthropic Console account, select possibility 2 and enter your API key when requested.
Notice: If the browser window doesn’t open mechanically, you possibly can copy the URL from the terminal and paste it into your browser manually to get the code. Copy that code and paste it again into the terminal when prompted.
When you’re logged in, you’ll get a closing disclaimer. Press Enter to dismiss it and also you’ll be good to go.
If all went effectively, it’s best to see a field with a message asking you should you belief the information within the folder just like the one beneath.
Select no for now and prepare to learn to use Claude Code.
Making a Challenge From Scratch
To get your ft moist, begin by making a recent Python challenge utilizing Claude Code.
Create a brand new folder in your challenge and title it “hello_claude_code“. Open a brand new terminal in that folder and run the next command:
claude
If it asks should you belief the information within the folder, select sure. It is best to now see the welcome message and a immediate enter.
Speaking with Claude
Now you can begin speaking with Claude Code. Kind your immediate and press Enter to ship it to Claude. For a primary immediate, attempt saying “Howdy”.
Claude will “suppose” for a short time earlier than responding.
To get Claude to create a challenge for you, copy and paste the next immediate into the terminal and press Enter:
Create a Mad Libs Python program that:
1. Prompts the consumer for several types of phrases (nouns, verbs, adjectives, and so on.)
2. Shops a enjoyable story template with placeholders
3. Substitutes the consumer's phrases into the story
4. Shows the finished foolish story
5. Consists of enter validation and the choice to play once more
6. Use clear variable names and add useful feedback
Notice: All the time be particular in your prompts, don’t anticipate Claude to learn your thoughts. For the very best outcomes, add clear particulars and context. Brief and obscure prompts will lead to less-than-ideal outcomes.
After a a while, the agent facet of Claude Code will kick in. It gained’t write code within the terminal simply but, however will as a substitute provide you with a plan of motion.
If all goes effectively Claude will wish to write a file. It gained’t do that with out asking in your permission, so that you’ll see the code it needs to write down, adopted by a query just like the one beneath:
You’ve got three choices right here:
- Sure: it will enable Claude to write down this specific file.
- Sure, and don’t ask once more this session: Claude will write this file and gained’t ask you once more if it could write information.
- No: Claude gained’t write the file and can look ahead to a brand new immediate.
Examine if the code appears to be like good after which press Enter to proceed and select the default possibility for now, which is “sure”.
At this level you possibly can examine if the file truly exists within the challenge folder.
For such a easy challenge, there’s an excellent likelihood Claude will use a single file. If it does ask to write down extra, reply with sure.
As soon as Claude is completed, it’s going to write a abstract of what it has completed and directions so that you can observe up. I received the next message:
Strive working the challenge as instructed and examine if all the things works as anticipated. For me, it labored, and I received the next output:
A great begin, however you possibly can refine it to make it higher. For instance, should you thought it wasn’t clear what sort of phrases it needed, suggest so as to add examples to every phrase immediate:
Please add examples to every phrase immediate. It wasn't at all times clear what was anticipated of me.
This time, Claude will ask if it’s alright to edit a file:
Select possibility 2 right here so future edits could be utilized with out having to ask you.
Now attempt working the challenge once more with the enhancements in place.
This back-and-forth is prime to working with Claude Code. Making gradual modifications and iterating on the outcomes is an effective way to refine your code.
Shut the terminal window and prepare to dive deeper. Within the subsequent part, you’ll learn to work with current tasks and easy methods to get essentially the most out of Claude Code.