Using the Claude Code CLI
Learn how to use Claude Code from inside a terminal
TLDR:
Claude Code can be used from the Desktop app with a user-friendly UX or from directly within your terminal. Follow below to learn how to use it in your terminal.
Installing the CLI and using it are incredibly simple and give you a very powerful tool to work with that can manage your filesystem and build projects for you.
Itās not without its risks though as prompt injection can make it act maliciously, yet limiting access and privileges will reduce the likelihood of this.
Lately Iāve been seeing a lot of non-coders getting into using traditionally coder-centric environments like terminals and IDEs (Integrated Development Environments) because AI has made it much easier to do so!
So for this weekās post I decided to show how simple it is to use Claude Code through its CLI (Command Line Interface) within a terminal.
If this post resonates with you and you enjoy the content then please share it with a friend and get rewarded for doing so!
This blog goes out weekly to over 20,000 subscribers. Please message me if youāre interested in sponsorships or partnerships.
Claude Code CLI
A few weeks back I made quite a long and detailed post on how to build with Claude Code where I explained what Claude Code is, how to get started with it, how to use it to generate code, and then finally run and use what youāve built.
Iād recommend you read this original post above if you havenāt, but as a quick recap Claude Code is an Anthropic product that lets users interact with Claude directly within their computer such that it can manage files on their filesystem and write code for them.
In my original post we used the Claude desktop app because itās the most user-friendly way to interact with Claude and itās what Iād recommend for most people.
However, lately Iāve been seeing a lot of non-coders getting into using traditionally coder-centric environments like terminals and IDEs (Integrated Development Environments) because AI has made it much easier to do so.
So this week I decided to run through how to install and use Claude Codeās Command Line Interface (CLI) directly from your computerās terminal so that you can learn how to do it yourself and most importantly to show you that itās not particularly scary.
Installing Claude Code CLI
Installing the Claude Code CLI is super easy. First you need to open your terminal (follow this for Mac or and this for Windows) then go to the Claude Code product page to see the line of code it shows:
curl -fsSL https://claude.ai/install.sh | bash
Next just copy and paste this line into your terminal!
Youāll see the terminal show a few messages as Claude Code is being set up before you get an āInstallation completeā message.
As you can see in the message about it explicitly said I needed to run the following command, so I did!
echo āexport PATH=ā$HOME/.local/bin:$PATHāā >> ~/.bashrc && source ~/.bashrc
With just that youāll have installed Claude Code! To then check that Claudeās working you can run a simple command like:
claude āsay helloā
This will then bring up a visualisation to get you started with the Claude Code CLI.
First you need to set your theme, then on hitting Enter itāll ask you to select your subscription method.
Select the first option to connect with your Claude subscription and the browser will pop up with a new screen where you can authorise the Claude Code CLI to user your subscription, and after this youāll be prompted to paste a code back into the terminal.
You should then see a āLogin successfulā message and a following āSecurityā message, which you can select Enter to skip through and then youāre ready to go!
The final message youāll see before we get started is about accessing your workspace as Claude will regularly try to ask you if itās ok for it to take an action for you.
Youāll just want to hit Enter for it so that it can ātrust this folderā.
You may spot it says ā/rootā at the top, this is because in my example I am using a VPS with ārootā access, in your machine though youāll likely be doing this through your own user access which is safer and more recommended.
Note that if for some reason your installation didnāt succeed then you can check the documentation. The AI space moves so fast and by the time youāre reading this the installation process my have slightly changed.
Using the CLI
With the Claude Code CLI installed and logged in letās now make use of it!
Youāll first see that our earlier āsay helloā command has been replied to by Claude, in my case Claude replied with āHello! How can I can help you today?ā.
Now letās ask it to do something for us, for example let me ask it to create a folder for us to work in, which Iām going to call pretty uncreatively āScript Test Folderā.
In doing this itāll ask for your permission to create the folder, just hit Enter and itāll finish up the job for you!
Next letās get it to write a super simple script within that folder that grabs the live price of Bitcoin, Ethereum and Solana.
Once again itāll ask you for permssion to create the file and we should hit Enter to let it generate that file within the folder.
And now letās ask Claude to literally ārun the script you just createdā.
There we have it, the latest BTC, ETH and SOL prices!
See how easy and powerful the Claude Code CLI is, with just 3 prompts we created a folder and a little script.
We could do far more interesting things here like get it to build out full projects if we wanted to, with the example above weāre literally just scratching the surface.
Use your new powers wisely
You now know how to use Claude Codeās CLI. Itās important to note though that Claude Code can in principle do anything the user can, so itās not without its risks.
Theoretically Claude Code can suffer from prompt injection when reading something online that forces it to download malicious software to your computer, delete important folders, or steal some of your credentials.
However, as you saw Claude has been programmed to constantly ask for permission before it goes off and takes any action. This is a guardrail that Anthropic has put in place to reduce the chance of it doing something malicious, yet although it reduces the risk it isn't a hard technical barrier and it can still be gamed.
Nonetheless in practical terms itās incredibly unlikely that Claude will be able to string together a set of complex tasks that download and install something without you noticing, the more realistic concern is it stealing credentials as that can be done by just reading a file and copying the value over the Internet to another computer.
The easiest way to avoid this is to just not give Claude ārootā access or too many privileges, and to not run it from within a folder with secret information like passwords. By simply doing this youāll generally avoid most of the problems that can arise.
Now Iāve kept this post intentionally simple and short just to get you started, especially given Iāve already shown how powerful Claude Code is in my previous post.
So take this newfound knowledge and go out and explore your new coding powers!
Whenever youāre ready, these are the main ways I can help you:
Want high returns? Earn up to 14% APY with Yieldseeker!
Love Web3 & AI insights? Follow @afoxinweb3 on X!
New to crypto? Join our beginners community to master crypto fast!
Building a Web3 app? Get our expert product development support!













