Live data from Hacker News

How to code Claude Code in 200 lines of code

mihaileric.com

171–180 of 249 posts

Re: How to code Claude Code in 200 lines of code

#171
post #154

Yea.. our startup greatly overestimated how hard it is to make a good agent loop. Handling exit conditions, command timeouts, context management, UI, etc is surprisingly hard to do seamlessly.

I'm curious which startup, if you wouldn't mind sharing? For reciprocity, I work at Imbue, and we can also attest to the real work complexities of this domain.

Called Ziva[0], we do AI agents for game development. If you want to jump on a call and discuss strategies, my email is in my bio

https://ziva.sh/

Re: How to code Claude Code in 200 lines of code

#172

Something I would add is planning. A big "aha" for effective use of these tools is realizing they run on dynamic TODO lists. Ex: Plan mode is basically bootstrapping how that TODO list gets seeded and how todos ground themselves when they get reached, and user interactions are how you realign the todo lists. The todolist is subtle but was a big shift in coding tools, and many seem to be surprised when we discuss it -…

I run evals and the Todo tool doesn't help most of the time. Usually models on high thinking would maintain Todo/state in their thinking tokens. What Todo helps is for cases like Anthropic models to run more parallel tool calls. If there is a Todo list call, then some of the actions after are more efficient.

What you need to do is to match the distribution of how the models were RL-ed. So you are right to say that "do X in 200 lines" is a very small part of the job to be done.

Re: How to code Claude Code in 200 lines of code

#173
I think some of the commenters are missing the point of this article. Claude Code is a low level harness around the model. Low level thin wrappers are unreasonably effective at code editing. My takeaway is that imagine how good code editing systems will be once our tools are not merely wrappers around the model. Once we have tall vertical systems that use engineering+llms to solve big chunks of problems. I could imagine certain classes of software being "solved".

Imagine a SDK that's dedicated to customizing tools like claude code/cursor cli to produce a class of software like b2b enterprise saas. Within the bounds of the domain(s) modeled these vertical systems would ultimately even crush the capabilities of thin low level wrappers we have today.

Re: How to code Claude Code in 200 lines of code

#174

Yea.. our startup greatly overestimated how hard it is to make a good agent loop. Handling exit conditions, command timeouts, context management, UI, etc is surprisingly hard to do seamlessly.

Do you mean they underestimated how hard it is?

No, overestimated. You can make a terrible CC in 200 LoC, but after using it for 3 minutes you'll realize how much more goes into it

Re: How to code Claude Code in 200 lines of code

#176
This feels like a pretty deceptive article title. At the end, he does say:

"What We Built vs. Production Tools This is about 200 lines. Production tools like Claude Code add:

Better error handling and fallback behaviors Streaming responses for better UX Smarter context management (summarizing long files, etc.) More tools (run commands, search codebase, etc.) Approval workflows for destructive operations

But the core loop? It’s exactly what we built here. The LLM decides what to do, your code executes it, results flow back. That’s the whole architecture."

But where's the actual test cases of the performance of his little bit of code vs. Claude Code? Is the core of Claude Code really just what he wrote (he boldly asserts 'exactly what we built here')? Where's the empirical proof?

Re: How to code Claude Code in 200 lines of code

#178
Why limit it to few tools from a tool registry when running in a full sandbox using QEMU or thinner like Podman/Docker literally takes 10 lines of code? You can still use your real files with a mount point to a directory.

To be clear I'm not implying any of that is useful but if you do want to go down that path then why not actually do it?

Re: How to code Claude Code in 200 lines of code

#179

> This is the key insight: we’re just telling the LLM “here are your tools, here’s the format to call them.” The LLM figures out when and how to use them. This really blew my mind back then in the ancient times of 2024-ish. I remember the idea of agents just reached me and I started reading various "here I built an agent that does this" articles, and I was really frustrated at not understanding how the hell LLM "know…

Tools documentation is in text, either directly e.g. tool -h or indirectly e.g. man tool plus they are countless examples of usage online, so it seems clear that a textual mapping between the tool and its usage exists in text form already.

Re: How to code Claude Code in 200 lines of code

#180

Here's the bigger question. Why would you? Claude code feels like the first commodity agent. In theory its simple but in practice you'll have to maintain a ton of random crap you get no value in maintaining. My guess is eventually all "agents" will be wipped out by claude code or something equivalent. Maybe not the companies will die but that all those startups will just be hooking up a generic agent wrapper and let…

Because you don't trust Anthropic or you like to learn how the tools you rely on work?
Post reply on HN