DEV Community

Khushiii
Khushiii

Posted on

Building My First CLI Tool — Messy but Worth It!

It wasn’t perfect, but I built it — and that’s the vibe🌼

Image description

Hellooo Devs👋
It’s me, Khushi — A curious kid just figuring things out 🌸

This is not some expert tutorial.
This is just a lil story about how I learned to build a CLI (Command Line Interface) tool — in my own messy, random way 😭✨

🌼Where I Started
I just started with the basics — JavaScript vibes only.
Learning how to play with strings, arrays, and the console.

This gave me the lil push to actually try something on my own.

💭My First Thought:
What if I build a CLI that counts how many lines are there in my .txt file?

Sounds simple right? Let’s gooo.

For this, I used the Commander library 👉https://www.npmjs.com/package/commander?activeTab=readme
It helped me create and print commands easily.

Here’s what it looked like 👇

Image description

The code👀: -
Image description

✨ Level Up: Gimme Some Colors!
After this lil project, I thought — let’s build something cuter and more interactive.

So I built a CLI that:

Basically, a whole vibe.

Outcome👀: -
Image description

🚧 The Problem I Faced (Yup, Struggled)
Okay, this one actually got me 😵‍💫

I had issues with type: module in package.json.
At first, my CLI wasn’t working because I was mixing Node.js modules and ES modules 💀

So I had to figure it out:

  1. Use .cjs instead of .js (yeah that works!)

  2. OR update package.json to support both module types.

Here’s a lil screenshot of that chaos:
Image description

When I saw that I can actually make my terminal look cute with colors and banners, I was sold 😂✨

🔗GitHub Repo link : - https://github.com/khushikumari239/CLI-Node.js.git

⚙️What I Built (the basic starter pack)

  • Showed a cool banner
  • Asked the user their name
  • Greeted them back with colorful text (obviously)

All this — in the terminal.
Running it in Node.js was actually not that scary once I broke it down into small lil steps.

Also had to figure out promises, callbacks, and async code (not gonna lie, it fried my brain a bit but we survived 🫠)

🌸What I Learned (aka life lessons lol)

  • Breaking stuff into tiny steps is literally the hack
  • Using ready-made libraries is NOT cheating — it’s smart
  • You learn the most by just TRYING and tweaking random stuff

If you’ve been thinking about building a CLI — just do it. Start small, keep it fun, don’t overthink.
Trust me, you’ll vibe.

So yeah — figuring this out was a whole mission but I did it 🤌

💌 Let’s Talk!
That’s my messy lil CLI story, straight from me to you 🤍
Not perfect, but definitely worth it.

Are you building something? Tell me in the comments!!
I wanna see your journey too — let’s build, fail, laugh, and vibe together 🫶
Big thanks to GeeksforGeeks (GFG)💚

Top comments (16)

Collapse
 
rohan_sharma profile image
Rohan Sharma

Hey Khushi, that's a great write up. Keep it up.

Btw did you write this blog from mobile phone? I see you added the mobile captured images.

Collapse
 
khushimehappy profile image
Khushiii

Thank you so much Rohan for the support 🌻✨
Nope I used my laptop.... The images I clicked with my phone then Added them using my laptop...

Collapse
 
rohan_sharma profile image
Rohan Sharma

try capturing screenshots directly from laptop. Use the built in snipping tool

Thread Thread
 
khushimehappy profile image
Khushiii

OKKKK Rohan thanks for the suggestions i will do that from the next time

Collapse
 
simbo1905 profile image
Simon Massey • Edited

That is super cool. Looks like gemini cli having nice colours. I run that cli tool as 'npx https://github.com/google-gemini/gemini-cli and that will pull into a temp location and running it; so a zero install way of always running the latest tool. you can make an alias for such cli tools like yours.

Collapse
 
khushimehappy profile image
Khushiii

That’s such a cool trick — running it via npx straight from the GitHub repo is honestly the smoothest way to stay up-to-date without installs 🔥
Hadn’t thought of creating an alias for mine, but now it’s on my to-do list 😄
Thanks for sharing this — I am gonna do thisss!

Collapse
 
ansellmaximilian profile image
Ansell Maximilian

Great job! I like your writing style — it's got a lot of personality!

Collapse
 
khushimehappy profile image
Khushiii

Appreciate that a lot! Just trying to keep it fun, honest, and a little bit chaotic — like my dev journey 😅

Collapse
 
henri_joseamani_8280cb1a profile image
henri jose amani

Great job !

Collapse
 
khushimehappy profile image
Khushiii

Thank You ⭐

Collapse
 
dotallio profile image
Dotallio

This is so real, the whole module chaos got me the first time too! Curious, what's your favorite npm library so far for CLI stuff?

Collapse
 
khushimehappy profile image
Khushiii

Aahhh thank you, Datallio! 😭 Of course, that module chaos… oh my god, it hit me hard too, but it’s finally workingg 😮‍💨
I’m really new to all these CLI things, but I gotta say — I loved gradient-string for the colorss 😅✨
Also, I just dropped another blog about Gemini CLI — it's pretty cool if you're into that kind of CLI's : - dev.to/khushimehappy/too-broke-for...

Collapse
 
matyasjay profile image
Matyas Angyal

Not sure how I got here, but "The Code" made my day. Thanks!

Collapse
 
khushimehappy profile image
Khushiii

The algorithm knew what it was doing 😌
Happy to hear the code made your day!

Collapse
 
galacticcircuit profile image
Galactic Circuit

Very cool! love the design.

Collapse
 
khushimehappy profile image
Khushiii

Thank Youuu🙌