Show HN: Bash4LLM+ – A lightweight, dependency-free Bash wrapper for LLM APIs
2 days ago (github.com)
Bash4LLM is a single-file Bash wrapper for interacting with LLMs from the terminal. I created it because I wanted something simple that worked without installing Python, Node, or any other runtime.
It uses only Bash, curl, and jq. You can send prompts, start a small chat, process files line by line, stream output, and save session metadata in JSON format.
I tried to make it safe and predictable: no use of the system /tmp, no use of eval. Groq is supported by default, and other providers can be added with dedicated Bash scripts in the extras/providers/ folder.
Example:
echo "explains the command: ls -l" | ./bash4llm
Heh, I just wrote something very similar - bash, curl, and jq scripts that wrap local Ollama calls to produce a REPL/agent: https://github.com/cloudkj/llayer
Seems like the core idea is the same, but I took it farther down the Unix philosophy line of thinking and tried to make the individual components small and composable.
Feel free to check it out and compare!
You really should either just write it manually, or at least clean it up, 5kLOC of bash for POSTing and reading/writing files is a bit overkill (the code is extremely repetitive, verbose and just hard to follow).
Yes, the code is big and bulky, i know. But i am a single person, not a team. I write simple and clear for me, because i need to mantain it. Only Bash, zero dependencies, i like this.
thank you for your comment!
> I write
You mean the LLM writes the code based on your instructions (that's fine, I guess, but 5KLOC is huge for this kind of script).
3 replies →
Why are you posting this if you know it is of poor quality then?
It's certainly not because you are proud of yourself, it has been generated.
So I genuinely wonder why?
1 reply →
[flagged]
I agree. What is with the random precore/core stuff anyways. But on the flip side, this thing seems to be doing a lot. I chugged through a couple thousand lines and there seems to be some amount of context management, I saw mentions of a history file, attachments, etc.
The macro sections/sections/sub-sections in the code are not random, I intentionally decide that. In brief: PRECORE_BOOT - for initialization PRECORE_RUN - persistency, history, cache PROVIDER - embedded provider (groq) CORE_SETUP - global runtime configuration, parsing parameters, LLM whitelist, user configuration CORE_PROVIDER - providers validation, prompt assembly, chat sessions, models tuning
The macro sections has two functions: 1, for me, to navigate the code 2, for LLMs, to understand my structure
The project does many things, so i need a clear sections structure to separate responsibilities.
You can see more information on the documentation, but the architectural spec is only in Italian.
oh! I thought this was like bash w/o verbosity. That is a tool I would love to see. bash4llm . May be llike Gandhi said - I should be the change you want to see!
English idioms are hard for me (I'm Italian), so I can misunderstand your point. bash4llm is long because it uses pure Bash, and making Bash-only reasonably safe and consistent for LLM calls it's difficult. For me, that's exactly what I like in the project.
I've applied a set of corrections, on Bash4LLM core, to reduce redundancy and make the flow more deterministic. Optimized safe_mkdir to eliminate superfluous calls to chmod, simplify temp file management by removing a redundant pre‑validation, remove repeated controls on ensure_run_tmpdir, unified internal standards but with backward compatibility, to correct duplications on providers management caused by a second redundant scan of provider modules, preserved diagnostic mode (CLI and environment variables). These are small jobs, but useful for clean and consistent runtime.
You need to figure out how to prompt to get much more concise code.
This is just a casual scroll through for 2 seconds at function names i recognize and can tell are crap.
https://github.com/kamaludu/bash4llm/blob/d7258163dc1cbeb6ae...
https://github.com/kamaludu/bash4llm/blob/d7258163dc1cbeb6ae...
https://github.com/kamaludu/bash4llm/blob/d7258163dc1cbeb6ae...
Sorry but this is crap. If you trust it to be an entirely self-contained abstraction that is fine. But if I'm building a brick house, and smash open 1 of the bricks, i dont want it to look this shoddy.
Any LLM you point at it, is going to be drastically dumber in editing it or auditing it because it needs to first parse all the crap a previous LLM generated. The fewer lines of code things use the better - it keeps models smarter when it matters. Plus it saves money in the long run.
Thank you very much for your attention and for your time. The problems that you have seen are real. Inspired by your feedback, I proceed to work on it, and I will fix the hollow redundancies and the bad duplications.
well, i write Bash4LLM to be:
. Portable - You need only: bash, coreutils, findutils, util-linux, gawk, curl, jq. No Python (slow), no Node (heavy), no Golang (need too many binaries, one for each OS, hard to maintain for one single person like me).
. Single file - only one. I write many extras, but all are optional.
. Idempotent - you copy it where you want and go!
. Transparent - open the file and read.
. Extras for all, and all optional: help file, extra providers, improved session engine, small GUI/CGI, etc...
Default (embedded) provider is Groq, because when I start the project, was the best free API service for AI.
I'm ready to answer to your question... with my terrible english...
Cristian (kamaludu)
Have you actually tested the portability? MacOS ships an ancient bash version and neither mac or BSDs use GNU version of coreutils.
I'm also very doubtful performance of this would be faster than python, bash is very slow.
I work with termux on Android, and it works fine. For now, I've not tested bash4llm on other environments, but I think it does work because the required packages are the minimum common denominator for all environments, ad with this requirements installed it should work on bsd-like too. I tried python too, at the start, and it was too slow.
[flagged]
Why is this flagged?
The text got classified as genai, which is not allowed on HN itself - see https://news.ycombinator.com/item?id=47340079.
We invited the user to rewrite it and I've moved that text to the top now, and re-upped the post so it gets its full time on /newest.