TL;DR
KaizenSQL is a CLI tool written in Go, it analyzes SQL code and supports three modes Mentor/Performance/Security. To give it AI-powered capabilities I used Groq api for free LLM tokens.
Overall, the main concern and goal with this project was to make the tool fast and pleasant to use. Every decision to be implemented had to take that into account.
In this post I'll share the faced scenarios, the good parts and bad ones. Code repo link at the end. β
HI fellow developer, pal, buddy, maybe a friend reading this π.
I'm Juan Huanaco, a Systems Engineering student from Peru. π΅πͺ
Today's post is about a small project: KaizenSQL, a Go based CLI tool that analyzes SQL code.
First question: Why? Do I need it? Not for now haha, I do not deal with tons of SQL these days.
This time it's not about the final product but the pillars and process experience while building it.
I like how reliable some CLI based programs are. Just type the command with some arguments and zapβ‘! The result is at your screen. "QuΓ© genial, quiero crear algo asΓ..." was my thought.
So I wanted to create a tool that reads a file/directory, sends that to an LLM for feedback AND has an intuitive and good-looking UI. On top of that, it had to be fast (as much as it could, I'm looking at you APIs falling several times lol).
That's it, up next are the key decisions that made me pause and think through each implementation step.
AI Agent brain - No need to think much
I use Gemini chat, is smart enough to help me find good resources and give advices. But I didn't want to spend money on trying the API version. Their free tier limits leaves you sweating.
For that reason I chose another LLM provider for this project. πͺ
That's Groq API, it has a generous limit to use it properly as a sandbox for testing your AI interactions. Also it was designed to be mostly compatible with OpenAI's client library, so you can switch/scale with them or OpenAI APIs in the future without doing lots of changes on connections. It's fast and best part, no need to share card data for their free account.
[2026.10.04] ADR-001: Modes definition for inspection
After having the initial code for connecting with Groq API successfully, I had an LLM agent ready to deal with text.
Now, "...tool to analyze SQL code...", great but what exactly should we monitor? Speed? Security? Both? If so, should it be a single scan for all? One of the constraints was that the specific model I used offered 8k tokens per minute.
So I had to ensure to leave enough space for SQL code (which could be pretty big) but also injecting enough proper system prompt. Also this introduces a good reason to add command flags to my tool. The flag module comes in handy:
import "flag"
func main() {
showBanner()
checkModeMentor := flag.Bool("m", false, "Use mentor mode [Default]")
checkModePerf := flag.Bool("p", false, "Use performance mode")
checkModeSec := flag.Bool("s", false, "Use security mode")
var chosenMode Mode
flag.Parse()
and depending on the selected mode (btw they don't add up), we sent a different system prompt to the agent.
Also I added a Mentor mode, its value is that it does not solve the problem, but guides you a clue so that you can find the answer yourself. Since developers are directly responsible for coming up with the solution, the new concept is easily sticks in their mind.
[2026-10-04] ADR-002: Output tokens limit excedeed when calling the agent π«£
Well... this one was on me haha
Of my three executions just one showed the error.
Up to this point, I hadn't checked the output limits for qwen/qwen3.8-27b. To my surprise only 1k tokens were offered (7k in / 1k out).
Time to change model? Nope, I liked how qwen performed, I used it on another project where I connected Foxit PDF API to a CLI tool. Btw i have a video about that, you can check it π here (warning: behold, just pure and good spanish there π§ββοΈ)
the fix? just to set the limit explicitly, that's ok for this little project's scope
response, err := client.CreateChatCompletion(ctx, openai.ChatCompletionRequest{
Model: k.agentModel,
+ MaxCompletionTokens: 900,
Messages: []openai.ChatCompletionMessage{...}
}
The rest of the Journey
Animated banner - Adding Bubbletea
I was scrolling on blogs and found one about Github Copilot CLI.
I knew some CLI tools add a nice-looking banner to their programs, however an animated one was something I didn't see too much. Easy to say I was impressed first time I saw this:
In their blog they mentioned the use of Ink π (a React renderer for building CLIs with JSX). Seemed like a great fit, if only that's wasn't just for NodeJS based tools. π
After some googling I found bubbletea (a TUI framework), this awesome open-source solution was the speedtrack I was looking for.
But things get better, because Cameron Foxly (principal brand designer at GitHub) created Ascii Motion a website to create ascii animations through an intuitive UI and export them to many formats, one of them was bubbletea anim.
Wrapping up
This concludes the developing journey for this little project.
I hope you enjoyed this post as much as I did writing it. βοΈ
The repo: KaizenSQL by jhuanaco
Setup instructions and the binary -ready to use- live happily there.
What's next
While coding I noted these:
- Add interactive file selection: Instead of passing the filename as a command-line argument, why not list all the .sql files on the current directory and let the user choose taking advantage of bubbletea keyboard interaction.
- Heuristic pre-analysis: If we start to inject more rules into the system prompt, eventually we might exceed the ITPM (input token per minute) limit. A pre-analysis on found keywords (JOIN, SINGLE, INSERT, etc) might be used to inject on the prompt just as needed rules. A next step to that approach would be to implement a RAG solution.
Will I add these ? Nah, lol
The project scope is over, and I know myself enough to tell you that if I not set scope limits, I might keep refactoring, adding, removing code in an unhealthy loop π. Also I have other project ideas I want to cook. ππ§βπ³
Thanks β€οΈ
Special thanks to the people on the open-source world, it was a fun dev experience to work with their great software.
And thank you for reading this post.
Until the next one.
- Go-OpenAI by sashabaranov - Used for communicating with Groq API
- Bubbletea by charmbracelet - Text User Interface framework used to add a nice banner.
- Ascii Motion by CameronFoxly - Awesome ascii-art animation software
Top comments (1)
tr.ee/dev-to