5 ms·
Show HN: Pu.sh – a full coding-agent harness in 400 lines of shell
I originally was just messing with pi-autoresearch. Gave it a sample task to build the most portable coding agent.
First cut was 6 KB of shell. Great for one-shots, unusable interactively. I was shocked it actually worked.
Started building up -- adding features — but with a self-imposed rule: no new dependencies, and sub 500 LOC. This thing had to be truly portable. Just sh, curl, awk. System primitives only.
Which means I did some genuinely disgusting things in awk, including JSON parsing and the OpenAI
Responses tool loop with reasoning items carried across turns.
It's now ~400 lines. In the box: Anthropic + OpenAI, 7 tools (bash, read, write, edit, grep, find, ls),
REPL, auto-compaction, checkpoint/resume, pipe mode, 90 no-API tests. Not in the box: TUI, streaming,
images, OAuth, Windows, dignity.
Two honest things:
1. I stole/modified the system prompt and the architecture. Pi/Claude/Codex wrote the awk. I cannot read most of this code. This wasn't possible for me a year ago.
2. Heavily inspired by Pi (pi.dev) — same 7-tool surface, same exact-text edit model. Credit where it's
due. Pi is awesome -- you should probably use them.
The agent loop itself is tiny. Almost everything else in a "real" agent CLI is DX and hardening. You can
probably build your own harness exactly how you like it. Mario Zechner's AI Engineer talk on taking back control of
your tools nudged me here.
The name is because it's a .sh file. The other thing it sounds like is, regrettably, also accurate.
- petcat 5mo agoyour 500 LOC requirement has made this thing completely and unnecessarily inscrutable and unreadable. Pass.
- hkt 5mo agoI love it. I think I'm going to have fun with this and possibly learn a bit, too. I'm pondering a container based dev environment at the moment and might throw it in with busybox and see how far I get :)
- ricardobeat 5mo agoReally like the looks of it, but minifying the code to achieve the “400 lines” marketing gimmick is a huge turn-off. It’s also a security nightmare, and ensures it remains 100% vibe coded. Would rather have a readable source with an honest line count.
- sudb 5mo agoI think it's fine that it's minified, code-golf style, but yes I agree that this would be much more convincing and useful with an unminified source.
- cachius 5mo agoIsn’t unwrapping and commenting just one prompt away?
- StableAlkyne 5mo agoAssuming the agent doesn't forget or misinterpret anything. It would be much better to just have a deterministic minification script.
- malicka 5mo ago… no, you shouldn’t use AI for simple reformatting of code without the newlines. We have syntax parsers and reformatters for this. Use them, then put that into the LLM for commenting, if you really want to.
- nahimn 5mo agoCaught by surprise by the people who want to read the code -- and thank you for the great ideas. Slapped together an 'unminified version' that has been ran against the test suite. Hopefully has more educational value https://github.com/NahimNasser/pu/blob/main/pu-unminified.sh https://github.com/NahimNasser/pu/blob/main/pu-unminified.sh
- petcat 5mo ago
- deleted 5mo ago[deleted]
- flog 5mo agoI'd love to learn how to build something like this, but unfortunately the code is unreadable. If author could write a heavily commented version that would be amazing.
- nahimn 5mo agohttps://github.com/NahimNasser/pu/blob/main/pu-unminified.sh https://github.com/NahimNasser/pu/blob/main/pu-unminified.sh
- freakynit 5mo agoI built full agentic-loop from scratch with full MCP support and session save and resume capabilities just this week. The intent was to learn by building full system from scratch, and share the learnings with others. Working demo: https://asciinema.org/a/983581 https://asciinema.org/a/983581 Code: https://github.com/freakynit/agentic-loop https://github.com/freakynit/agentic-loop Tutorial: https://building-an-agent.pagey.site/ https://building-an-agent.pagey.site/
- Imustaskforhelp 5mo agoInterested in something like this if the code can be more readable, it would be interesting to see it in languages like lua etc. too in future.
- kkovacs 5mo agoI love this. This is the grown-up brother of my one-liner bash+python at https://github.com/kkovacs/kkrc/blob/ecff1f65d5ccfa24d5f6695e27defcbd1de37323/inject-ai-func.txt https://github.com/kkovacs/kkrc/blob/ecff1f65d5ccfa24d5f6695... :)
- kweiza 5mo ago[dead]
- tecoholic 5mo agoKudos. I set on this exact journey a couple of days back and Pi is what I started reading for inspiration as well. I really can't stand the text boxes and the animations of the mainstream harnesses.
- cachius 5mo agoDoes it work in just-bash? https://github.com/vercel-labs/just-bash/blob/main/packages/just-bash/README.md https://github.com/vercel-labs/just-bash/blob/main/packages/...
- mjuarez 5mo agoCould you post the initial 6KB version? I'd love to have a version that I can actually read and understand. I don't care if it's 2K LOC.
- TacticalCoder 5mo ago> Could you post the initial 6KB version? I'd love to have a version that I can actually read and understand. I don't care if it's 2K LOC. I don't think that even with APL you could get an average of three characters per line of code to get a 6 Kb file in 2 K LOC.
- greenavocado 5mo agoMaybe in Wényán lang?
- nahimn 5mo agoheh... i'm afraid i didn't commit it -- as it was in the original pi-autoresearch yolo'ing phase.
- 0gs 5mo agowhy the LOC limit? just because?
- nahimn 5mo agoOriginally a metric to drive prioritization and constraints on the project (amongst others, like zero deps, etc) -- but clearly ended up getting abused
- qavey 5mo ago[dead]
- kestiny 5mo ago[flagged]
- zackham 5mo agoif you are looking for a customizable agent harness that provides everything except a tui (cli, acp, embeddable python package) i built and use this for a handful of projects where i needed a vendor-agnostic replacement for claude agent sdk: https://github.com/zackham/aloop https://github.com/zackham/aloop
- Amber-chen 5mo agoI like the small-surface-area approach. The question I’d use to evaluate this is how well the harness records/replays tool calls and failure modes, since that is where debugging agent behavior usually gets messy.
- Oxlamarr 5mo ago[dead]
- nielsbosma 5mo ago[dead]
- ArielTM 5mo ago[dead]
- suyavuz 5mo ago[dead]
- laxmena 5mo ago[dead]
- migrevdolseg 5mo agothis inspired me to build something similar. i like the idea but i wanted slightly different constraints: - one file - zero dependencies (other than node) - <1k loc - ascii only - suckless configuration - works with ollama models - more readble sourcecode - pretty markdown output - toggle-able read-only mode https://willhanlen.com/~~/outbox/26/5/ai.js/?code https://willhanlen.com/~~/outbox/26/5/ai.js/?code took me only a few hours. amazing times we live in!
- Amber-chen 5mo ago[dead]
- deleted 5mo ago[deleted]
- kage18 5mo agoIn only a time someone will do it in shell ---- oh wow you did it!!!
- JadaQ2026 5mo ago[flagged]
- kambizhoma 5mo ago[flagged]
- paurerir 5mo ago[dead]