11 ms·
How to code Claude Code in 200 lines of code
- deleted 9mo ago[deleted]
- bjacobso 9mo agohttps://www.youtube.com/watch?v=aueu9lm2ubo https://www.youtube.com/watch?v=aueu9lm2ubo
- vrosas 9mo agoUnless there's context, I'm never clicking on a naked youtube link.
- pests 9mo agoAre you worried google is going to hack you or something?
- handfuloflight 9mo agoHe was told they were never gonna give up.
- prodigycorp 9mo agoThis article was more true than not a year ago but now the harnesses are so far past the simple agent loop that I'd argue that this is not even close to an accurate mental model of what claude code is doing.
- splike 9mo agoI'm interested, could you expand on that?
- prodigycorp 9mo agoOff the top of my head: parallel subagents, hooks, skills, and a much better plan mode. These features enable way better steering than we had last year. Subagents are a huge boon to productivity.
- rtgfhyuj 9mo agoare subagents just tools that are agents themselves?
- dkdcio 9mo agopretty much…they have their own system prompts, you can customize the model, the tools they use, etc. CC has built in subagents (including at least one not listed) that work very well: https://code.claude.com/docs/en/sub-agents#built-in-subagents https://code.claude.com/docs/en/sub-agents#built-in-subagent... this was not the case in the past, I swore off subagents, but they got good at some point
- dkdcio 9mo agoit seems to have changed a ton in recent versions too — I would love more details on what exactly I find it doing what I in the past had to interrupt and tell it to do fairly frequently now
- terminalshort 9mo agoFor one thing it seems to splitting up the work and making some determination of complexity, then allocating it out to a model based on that complexity to save resources. When I run Claude with Opus 4.5 and run /cost I see tokens for Opus 4.5, but also a lot in Sonnet and Haiku, with the majority of tokens actually being used by Haiku.
- nyellin 9mo agoHaiku is called often, but not always the way you think. E.g. every time you write something CC invokes Haiku multiple times to generate the 'delightful 1-2 word phrase used to indicate progress to the user' (Doing Stuff, Wizarding, etc)
- dkdcio 9mo agoit’s also used in the Explore agent and for other things too
- lukan 9mo agoThe article was also published one year ago on january 2025. (Should have 2025 in the title? Time flies)
- llmslave2 9mo agoClaude Code didn't exist in January 2025. I think it's a typo and should be 2026.
- prodigycorp 9mo agoYou’re right. No wonder the date felt odd. iirc Claude code was released around march.
- dkdcio 9mo agolate Feb. 2025: https://www.anthropic.com/news/claude-3-7-sonnet https://www.anthropic.com/news/claude-3-7-sonnet
- alright2565 9mo agoBut does that extra complexity actually improve performance? https://www.tbench.ai/leaderboard/terminal-bench/2.0 https://www.tbench.ai/leaderboard/terminal-bench/2.0 says yes, but not as much as you'd think. "Terminus" is basically just a tmux session and LLM in a loop.
- prodigycorp 9mo agoI'm not a good representative for claude code because I'm primarily a codex user now, but I know that if codex had subagents it would be at least twice as productive. Time spent is an important aspect of performance so yup, the complexity improved performance.
- nyellin 9mo agoNot necessarily true. Subagents allow for parallelization but they can decrease accuracy dramatically if you're not careful because there are often dependencies between tasks and swapping context windows with a summary is extremely lossy. For the longest time, Claude Code itself didnt really use subagents much by default, other than supporting them as a feature eager users could configure. (Source is reverse engineering we did on Claude code using the fantastic CC tracing tool Simon Willison wrote about once. This is also no longer true on latest versions that have e.g. an Explore subagent that is actively used.)
- prodigycorp 9mo agoYou’re right that subagents were more likely to cause issues than be helpful. But, when properly understood, lead to so much time saved through parallelization for tasks that warranted it. I was having codex organize my tv/movie library the other day by having it generate. most of the files were not properly labeled. I had codex generate transcripts, manually search the movie db to find descriptions of show episodes, and match the show descriptions against the transcripts to figure out which episode/season the show belonged to. Claude Code could have parallelized those manual checks and finished that task at 8x the speed.
- 9mo ago
- qsort 9mo agoObviously modern harnesses have better features but I wouldn't say it invalidates the mental model. Simpler agents aren't that far behind in performance if the underlying model is the same, including very minimal ones with basic tools. I'd say it's similar to how a "make your own relational DB" article might feature a basic B-tree with merge-joins. Yeah, obviously real engines have sophisticated planners, multiple join methods, bloom filters, etc., but the underlying mental model is still accurate.
- prodigycorp 9mo agoYou’re not wrong but I still think that the harness matters a lot when trying to accurately describe Claude Code. Here’s a reframing: If you asked people “what would you rather work with, today’s Claude Code harness with sonnet 3.7, or the 200 line agentic loop in the article with Opus 4.5, which would you choose?” I suspect many people would choose 3.7 with the harness. Moreover, that is true, then I’d say the article is no longer useful for a modern understanding of Claude Code.
- rfw300 9mo agoAny person who would choose 3.7 with a fancy harness has a very poor memory about how dramatically the model capabilities have improved between then and now.
- prodigycorp 9mo agoI’d be very interested in the performance of 3.7 decked out with web search, context7, a full suite of skills, and code quality hooks against opus 4.5 with none of those. I suspect it’s closer than you think!
- CuriouslyC 9mo agoSkills don't make any difference above having markdown files to point an agent to with instructions as needed. Context7 isn't any better than telling your agent to use trafilatura to scrape web docs for your libs, and having a linting/static analysis suite isn't a harness thing. 3.7 was kinda dumb, it was good at vibe UIs but really bad at a lot of things and it would lie and hack rewards a LOT. The difference with Opus 4.5 is that when you go off the Claude happy path, it holds together pretty well. With Sonnet (particularly <=4) if you went off the happy path things got bad in a hurry.
- CuriouslyC 9mo agoLess true than you think. A lot of the progress in the last year has been tightening agentic prompts/tools and getting out of the way so the model can flex. Subagents/MCP/Skills are all pretty mid, and while there has been some context pruning optimization to avoid carrying tool output along forever, that's mainly a benefit to long running agents and for short tasks you won't notice.
- prodigycorp 9mo agoAll of these things you mentioned are put into a footnote of the article.
- pama 9mo agoAgreed. You can get a better model using the codex-cli repo and having an agent help you analyze the core functionality.
- deleted 9mo ago[deleted]
- kirjavascript 9mo agohere's my take, in 70 lines of code: https://github.com/kirjavascript/nanoagent/blob/master/nanoagent.js https://github.com/kirjavascript/nanoagent/blob/master/nanoa...
- fragmede 9mo agoI mean, if you take out the guard rails, here's codex in 46 lines of bash: #!/usr/bin/env bash set -euo pipefail # Fail fast if OPENAI_API_KEY is unset or empty : "${OPENAI_API_KEY:?set OPENAI_API_KEY}" MODEL="${MODEL:-gpt-5.2-chat-latest}" extract_text_joined() { # Collect all text fields from the Responses API output and join them jq -r '[.output[]?.content[]? | select(has("text")) | .text] | join("")' } apply_writes() { local plan="$1" echo "$plan" | jq -c '.files[]' | while read -r f; do local path content path="$(echo "$f" | jq -r '.path')" content="$(echo "$f" | jq -r '.content')" mkdir -p "$(dirname "$path")" printf "%s" "$content" > "$path" echo "wrote $path" done } while true; do printf "> " read -r USER_INPUT || exit 0 [[ -z "$USER_INPUT" ]] && continue # File list relative to cwd TREE="$(find . -type f -maxdepth 6 -print | sed 's|^\./||')" USER_JSON="$(jq -n --arg task "$USER_INPUT" --arg tree "$TREE" \ '{task:$task, workspace_tree:$tree, rules:[ "Return ONLY JSON matching the schema.", "Write files wholesale: full final content for each file.", "If no file changes are needed, return files:[]" ] }')" RESP="$( curl -s https://api.openai.com/v1/responses \ -H "Authorization: Bearer $OPENAI_API_KEY" \ -H "Content-Type: application/json" \ -d "$(jq -n --arg model "$MODEL" --argjson user "$USER_JSON" '{model:$model,input:[{role:"system",content:"You output only JSON file-write plans."},{role:"user",content:$user}],text:{format:{type:"json_schema",name:"file_writes",schema:{type:"object",additionalProperties:false,properties:{files:{type:"array",items:{type:"object",additionalProperties:false,properties:{path:{type:"string"},content:{type:"string"}},required:["path","content"]}}},required:["files"]}}}')" )" PLAN="$(printf "%s" "$RESP" | extract_text_joined)" apply_writes "$PLAN" done
- dave1010uk 9mo agoImpressive! Here's an agent in 24 lines of PHP, written in 2023. But it relies on `llm` to do HTTP and JSON. https://github.com/dave1010/hubcap https://github.com/dave1010/hubcap
- ulaw 9mo agoHow many Claudes could Claude Code code if Claude Code could code Claude?
- tuhgdetzhh 9mo ago"if Claude Code could code Claude?" Claude Code already codes Claude Code. The limit is set by the amount of GPUs and energy supply.
- handfuloflight 9mo agoThe human element of the Anthropic organization also has some limits placed there.
- Okkef 9mo agoClaude has a nice answer to your riddle: Claude Code could code all the Claudes Claude Code could code, because Claude Code already coded the Claude that codes Claude Code. Or more philosophically: The answer is recursively infinite, because each Claude that gets coded can then help code the next Claude, creating an ever-improving feedback loop of Claude-coding Claudes. It's Claudes all the way down!
- deleted 9mo ago[deleted]
- nyellin 9mo agoThere's a bit more to it! For example, the agent in the post will demonstrate 'early stopping' where it finishes before the task is really done. You'd think you can solve this with reasoning models, but it doesn't actually work on SOTA models. To fix 'early stopping' you need extra features in the agent harness. Claude Code does this with TODOs that are injected back into every prompt to remind the LLM what tasks remain open. (If you're curious somewhere in the public repo for HolmesGPT we have benchamrks with all the experiments we ran to solve this - from hypothesis tracking to other exotic approaches - but TODOs always performed best.) Still, good article. Agents really are just tools in a loop. It's not rocket science.
- rtgfhyuj 9mo agowhy would it early stop? examples?
- embedding-shape 9mo agoNot all models are trained with long one-shot task following by themselves, seems many of them prefer closer interactions with the user. You could always add another layer/abstraction above/below to work around it.
- fastball 9mo agoCan't this just be a Ralph Wiggum loop (i.e. while True)
- embedding-shape 9mo agoSure, but I think just about everyone wants the agent to eventually say "done" in one way or another.
- mickeyp 9mo agoModels just naturally arrive at a conclusion that they are done. TODO hints can help, but is not infallible: Claude will stop and happily report there's more work to be done and "you just say the word Mister and I'll continue" --- this is a RL problem where you have to balance the chance of an infinite loop (it keeps thinking there's a little bit more to do when there is not) versus the opposite where it stops short of actual completion.
- hazrmard 9mo agoThis reflects my experience. Yet, I feel that getting reliability out of LLM calls with a while-loop harness is elusive. For example - how can I reliably have a decision block to end the loop (or keep it running)? - how can I reliably call tools with the right schema? - how can I reliably summarize context / excise noise from the conversation? Perhaps, as the models get better, they'll approach some threshold where my worries just go away. However, I can't quantify that threshold myself and that leaves a cloud of uncertainty hanging over any agentic loops I build. Perhaps I should accept that it's a feature and not a bug? :)
- nyellin 9mo agoRe (1) use a TODOs system like Claude code. Re (2) also fairly easy! It's just a summarization prompt. E.g. this is the one we use in our agent: https://github.com/HolmesGPT/holmesgpt/blob/62c3898e4efae69b4262f4d75e3f8943507278a2/holmes/plugins/prompts/conversation_history_compaction.jinja2#L4 https://github.com/HolmesGPT/holmesgpt/blob/62c3898e4efae69b... Or just use the Claude Code SDK that does this all for you! (You can also use various provider-specific features for 2 like automatic compaction on OpenAI responses endpoint.)
- nyellin 9mo agoForgot to address the easiest part: > - how can I reliably call tools with the right schema? This is typically done by enabling strict mode for tool calling which is a hermetic solution. Makes llm unable to generate tokens that would violate the schema. (I.e. LLM samples tokens only from the subset of tokens that lead to valid schema generation.)
- jackfranklyn 9mo ago[flagged]
- dfajgljsldkjag 9mo ago[flagged]
- shpongled 9mo agoUnclear why you think this is ChatGPT, doesn't read like it at all to me. Many people - myself included - use punctuation to emphasize and clarify.
- dfajgljsldkjag 9mo agoThat comment has tons of AI tells, not simply a few punctuation.
- shpongled 9mo agoNo, it doesn't. The "I'm an expert at AI detection" crowd likes to cite things like "It's not X, it's Y" and other expression patterns without stopping to think that perhaps LLMs regurgitate those patterns because they are frequently used in written speech. I assign a <5% probability that GP comment was AI written. It's easy to tell, because AI writing has no soul.
- NitpickLawyer 9mo agoThe message is 100% AI written. And if you click on their username and check their comment history you'll see that ALL their comments are "identical". Just do it, you'll see it by the 5th message. No one talks like that. No one talks like that on every message.
- shpongled 9mo agoLooking at their profile I'm inclined to agree. But I think in isolation, this one post isn't setting off enough red flags for me. At the very least, they aren't just using default prompts.
- _andrei_ 9mo agoyes, it's an agent
- erichocean 9mo agoThe tip of the sphere in agentic code harnesses today is to RL train them as dedicated conductor/orchestrator models. Not 200 lines of Python.
- aszen 9mo agoCan you elaborate on this?
- 8note 9mo agoas a comparison, the gemini cli agent with gemini 2 half the time writes its own tool call parameters incorrectly. it didnt quite know when to make a tool call, which tool result was the most recent(it always assumed the first one was the one to use, rather than the last one, when multiple reads of the same file were in context) etc. gemini 3 has pretty clearly been trained for this workflow of text output, since it can actually get the right calls in the first shot most of the time, and pays attention to the end of the context and not just the start. gemini 3 is sitting within a format of text that it has been trained to be in, where for gemini 2, it only had the prompt to tell it how to work within the tool
- erichocean 9mo agoHere you go: https://research.nvidia.com/labs/lpr/ToolOrchestra/ https://research.nvidia.com/labs/lpr/ToolOrchestra/ Big models (like Claude Opus 4.5) can (and do) just RL-train this into the main model.
- libraryofbabel 9mo agoIt's a great point and everyone should know it: the core of a coding agent is really simple, it's a loop with tool calling. Having said that, I think if you're going to write an article like this and call it "The Emperor Has No Clothes: How to Code Claude Code in 200 Lines of Code", you should at least include a reference to Thorsten Ball's excellent article from wayyy back in April 2025 entitled "How to Build an Agent, or: The Emperor Has No Clothes" (https://ampcode.com/how-to-build-an-agent https://ampcode.com/how-to-build-an-agent)! That was (as far as I know) the first of these articles making the point that the core of a coding agent is actually quite simple (and all the deep complexity is in the LLM). Reading it was a light-bulb moment for me. FWIW, I agree with other commenters here that you do need quite a bit of additional scaffolding (like TODOs and much more) to make modern agents work well. And Claude Code itself is a fairly complex piece of software with a lot of settings, hooks, plugins, UI features, etc. Although I would add that once you have a minimal coding agent loop in place, you can get it to bootstrap its own code and add those things! That is a fun and slightly weird thing to try. (By the way, the "January 2025" date on this article is clearly a typo for 2026, as Claude Code didn't exist a year ago and it includes use of the claude-sonnet-4-20250514 model from May.) Edit: and if you're interested in diving deeper into what Claude Code itself is doing under the hood, a good tool to understand it is "claude-trace" (https://github.com/badlogic/lemmy/tree/main/apps/claude-trace https://github.com/badlogic/lemmy/tree/main/apps/claude-trac...). You can use it to see the whole dance with tool calls and the LLM: every call out to the LLM and the LLM's responses, the LLM's tool call invocations and the responses from the agent to the LLM when tools run, etc. When Claude Skills came out I used this to confirm my guess about how they worked (they're a tool call with all the short skill descriptions stuffed into the tool description base prompt). Reading the base prompt is also interesting. (Among other things, they explicitly tell it not to use emoji, which tracks as when I wrote my own agent it was indeed very emoji-prone.)
- KellyCriterion 9mo agocan you show us the >>core of a coding agent which is, according to your words, >>really simple and would you mind sharing a URL so I could check it out then?
- 9mo ago
- rcarmo 9mo agoI think mine have a little more code, but they also have a lot more tools: - https://github.com/rcarmo/bun-steward https://github.com/rcarmo/bun-steward - https://github.com/rcarmo/python-steward https://github.com/rcarmo/python-steward (created with the first one) And they're self-replicating!
- dana321 9mo ago[flagged]
- tomhow 9mo agoPlease don't fulminate on HN. The guidelines make it clear we're trying for something better here. https://news.ycombinator.com/newsguidelines.html https://news.ycombinator.com/newsguidelines.html
- ofirpress 9mo agoWe (the SWE-bench team) have a 100 line of code agent that is now pretty popular in both academic and industry labs: https://github.com/SWE-agent/mini-swe-agent https://github.com/SWE-agent/mini-swe-agent I think it's a great way to dive into the agent world
- oli5679 9mo agohttps://github.com/mistralai/mistral-vibe https://github.com/mistralai/mistral-vibe This is a really nice open source coding agent implementation. The use of async is interesting.
- tptacek 9mo agoWhat's interesting to me about the question of whether you could realistically compete with Claude Code (not Claude, but the CLI agent) is that the questions boil down to things any proficient developer could do. No matter how much I'd want to try, I have no hope of building a competitive frontier model --- "frontier model" is a distinctively apt term. But there's no such thing as a "frontier agent", and the Charmbracelet people have as much of a shot at building something truly exception as Anthropic does.
- embedding-shape 9mo ago> No matter how much I'd want to try, I have no hope of building a competitive frontier model A single person, probably not. But a group of dedicated FOSS developers who together build a wide community contributing to one open model that could be continuously upgraded? Maybe.
- maurycy 9mo agoMaybe not necessarily and the Claude model is fine-tuned for `claude`, so no one can really replicate the experience without unlocking some secret mode in the model. The other comments about editing files hint at this.
- libraryofbabel 9mo agoThis is a great point, although I would add that Anthropic has a possible slight advantage, as they can RLVR the Claude LLMs themselves on Claude Code tool calls and Claude Code tasks. Having said that, it's not clear how much that really matters at all for making the Claude Code CLI specifically better-performing than other coding agents using the same LLM (the tool calls are fairly generic and the LLMs are good at plenty of tool calls they weren't RLVRed on too). The other advantage Anthropic have is just that they can sell CC subscriptions at lower cost because they own the models. But that's a separate set of questions that don't really relate to technical capabilities. Anyhow, to follow up on your point, I do find it surprising that Claude Code is still (it seems?) definitively leading the pack in terms of coding agents. I've tried Gemini CLI and Codex and they feel distinctly less good, but I'm surprised we haven't seen too many alternatives from small startups or open source projects rise to the top as well. After all, they can build on all the lessons learned from previous agents (UX, context management, features people like such as Skills etc.). Maybe we will see more of this in 2026.
- nxobject 9mo agoI'll admit that I'm tickled pink by the idea of a coding agent recreating itself. Are we at a point where agents can significantly and autonomously improve themselves?
- lmeyerov 9mo agoSomething 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 -- most seem to focus on whether to use plan mode or not, but todo lists will still be active. I ran a fun experiment last month on how well claude code solves CTFs, and disabling the TodoList tool and planning is 1-2 grade jumps: https://media.ccc.de/v/39c3-breaking-bots-cheating-at-blue-team-ctfs-with-ai-speed-runs https://media.ccc.de/v/39c3-breaking-bots-cheating-at-blue-t... . Fwiw, I found it funny how the article stuffs "smarter context management" into a breeze-y TODO bullet point at the end for going production-grade. I've been noticing a lot of NIH/DIY types believing they can do a good job of this and then, when forced to have results/evals that don't suck in production, losing the rest of the year on that step. (And even worse when they decide to fine-tune too.)
- btown 9mo agoI'm unsure of its accuracy/provenance/outdatedness, but this purportedly extracted system prompt for Claude Code provides a lot more detail about TODO iteration and how powerful it can be: https://gist.github.com/wong2/e0f34aac66caf890a332f7b6f9e2ba8f#task-management https://gist.github.com/wong2/e0f34aac66caf890a332f7b6f9e2ba... https://gist.github.com/wong2/e0f34aac66caf890a332f7b6f9e2ba8f#todoread https://gist.github.com/wong2/e0f34aac66caf890a332f7b6f9e2ba... I find it fascinating that while in theory one could just append these as reasoning tokens to the context, and trust the attention algorithm to find the most recent TODO list and attend actively to it... in practice, creating explicit tools that essentially do a single-key storage are far more effective and predictable. It makes me wonder how much other low-hanging fruit there is with tool creation for storing language that requires emphasis and structure.
- lmeyerov 9mo agoI find in coding + investigating there's a lot of mileage to being fancier on the todo list. Eg, we make sure timestamps, branches, outcomes, etc are represented. It's impressive how far they get with so little! For coding, I actually fully take over the todo list in codex + claude: https://github.com/graphistry/pygraphistry/blob/master/ai/prompts/PLAN.md https://github.com/graphistry/pygraphistry/blob/master/ai/pr... In Louie.ai, for investigations, we're experimenting with enabling more control of it, so you can go with the grain, vs that kind of wholecloth replacement
- afarah1 9mo agoReminds me of this 2023 post "re-implementing LangChain in 100 lines of code": https://blog.scottlogic.com/2023/05/04/langchain-mini.html https://blog.scottlogic.com/2023/05/04/langchain-mini.html We did just that back then and it worked great, we used it in many projects after that.
- prodigycorp 9mo agoHow was this three years ago ;_;
- m-hodges 9mo agoAlso relevant: You Should Write An Agent¹ and, How To Build An Agent.² ¹ https://fly.io/blog/everyone-write-an-agent/ https://fly.io/blog/everyone-write-an-agent/ ² https://ampcode.com/how-to-build-an-agent https://ampcode.com/how-to-build-an-agent
- johnsmith1840 9mo agoHere'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 it do its thing directly. My bet is that that the company that would win this is the one with the most training data to tune their agent to use their harness correctly.
- utopiah 9mo agoBecause you don't trust Anthropic or you like to learn how the tools you rely on work?
- mudkipdev 9mo agoIs this not using constrained decoding? You should pass the tool schemas to the "tools" parameter to make sure all tool calls are valid
- floppyd 9mo ago> 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 "knows" how to call a tool, it's a program, but LLMs just produce text! Yes I see you are telling LLM about tools, but what's next? And then when I finally understood that there's no next, no need to do anything other than explaining — it felt pretty magical, not gonna lie.
- utopiah 9mo agoTools 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.
- naasking 9mo agoIt would seem magical if you think of LLMs as token predictors with zero understanding of what they're doing. This is evidence that there's more going on though.
- voidhorse 9mo agoRunning a command in a shell is a string of text. LLMs produce text and it's easy to write a program that then executes that text as a process. I don't see what's magical about it at all.
- duncancarroll 9mo ago> "But here’s the thing" This phrase feels like the new em dash...
- OsrsNeedsf2P 9mo agoYea.. 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.
- bjt12345 9mo agoDo you mean they underestimated how hard it is?
- OsrsNeedsf2P 9mo agoNo, 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
- lemontheme 9mo agoGotta admit, the phrasing tripped me up as well. You underestimated the effort that ultimately went into it
- nvader 9mo agoI'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.
- OsrsNeedsf2P 9mo agoCalled 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/ https://ziva.sh/
- cadamsdotcom 9mo agoThe devil is in the details, so actually, the Emperor in this analogy most definitely does have clothes. For example, post-training / finetuning the model specifically to use the tools it’ll be given in the harness. Or endlessly tweaking the system prompt to fine-tune the model’s behavior to a polish. Plus - both OpenAI and Qwen have models specifically intended for coding.
- joshmlewis 9mo agoThis is cool but as someone that's built an enterprise grade agentic loop in-house that's processing a billion plus tokens a month, there are so many little things you have to account for that greatly magnify complexity in real world agentic use cases. For loops are an easy way to get your foot in the door and is indeed at the heart of it all, but there are a multitude of a little things that compound complexity rather quickly. What happens when a user sends a message after the first one and the agent has already started the tool loop? Seems simple, right? If you are receiving inputs via webhooks (like from a Slack bot), then what do you do? It's not rocket science but it's also not trivial to do right. What about hooks (guardrails) and approvals? Should you halt execution mid-loop and wait or implement it as an async Task feature like Claude Code and the MCP spec? If you do it async then how do you wake the agent back up? Where is the original tool call stored and how is the output stored for retrieval/insertion? This and many other little things add up and compound on each other. I should start a blog with my experience from all of this.
- handfuloflight 9mo ago> I should start a blog with my experience from all of this. Please do.
- visarga 9mo agoA quick glance over the 200 LOC impl - I see no error handling. This is the core of the agent loop, you need to pass some errors back to the LLM to adapt, while other errors should be handled by the code. There is also no model specific code for structured decoding. This article could make for a good interview problem, "what is missing and what would you improve on it?"
- joebates 9mo agoPlease do! This sounds way more interesting than a simple coding loop agent (not to knock the blog)
- loeg 9mo agoWould be nice to have a different wrapper around Claude, even something bare bones, as long as it's easy to modify. Claude code terminal has the jankiest text editor I've ever used -- holding down backspace just moves the cursor. It's something about the key repeat rate. If you manually press backspace repeatedly, it's fine, but a rapid repeat rate confuses the editor. (I'm pretty sure neither GNU readline nor BSD editline do this.) It makes editing prompts a giant pain in the ass.
- thierrydamiba 9mo agoWhat editor are you using?
- loeg 9mo agoWhatever interface you get running the claude cli.
- thierrydamiba 9mo agoTry ghostty, wterm, or kitty as the terminal you run Claude code from. Much better experience.
- dangoodmanUT 9mo agoThis definitely will handle large files or binary files very poorly
- andai 9mo agofrom ddgs import DDGS def web_search(query: str, max_results: int = 8) -> list[dict]: return DDGS().text(query, max_results=max_results)
- schmuhblaster 9mo agoAs an experiment over the holidays I had Opus create a coding agent in a Prolog DSL (more than 200 lines though) [0] and I was surprised how well the agent worked out of the box. So I guess that the latest one or two generations of models have reached a stage where the agent harness around the model seems to be less important than before. [0] https://news.ycombinator.com/item?id=46527722 https://news.ycombinator.com/item?id=46527722
- kristopolous 9mo agoThe source code link at the bottom of the article goes to YouTube for some reason
- bochoh 9mo agoI’ve had decent results with this for context management in large code bases so far https://github.com/GMaN1911/claude-cognitive https://github.com/GMaN1911/claude-cognitive
- d4rkp4ttern 9mo agoThis is consistent with how I've defined the 3 core elements of an agent: - Intelligence (the LLM) - Autonomy (loop) - Tools to have "external" effects Wrinkles that I haven't seen discussed much are: (1) Tool-forgetting: LLM forgets to call a tool (and instead outputs plain text). Some may say that these concerns will disappear as frontier models improve, there will always be a need for having your agent scaffolding work well with weaker LLMs (cost, privacy, etc), and as long as the model is stochastic there will always be a chance of tool-forgetting. (2) Task-completion-signaling: Determining when a task is finished. This has 2 sub-cases: (2a) we want the LLM to decide that, e.g. search with different queries until desired info found, (2b) we want to specify deterministic task completion conditions, e.g., end the task immediately after structured info extraction, or after acting on such info, or after the LLM sees the result of that action etc. After repeatedly running into these types of issues in production agent systems, we’ve added mechanisms for these in the Langroid[1] agent framework, which has blackboard-like loop architecture that makes it easy to incorporate these. For issue (1) we can configure an agent with a `handle_llm_no_tool` [2] set to a “nudge” that is sent back to the LLM when a non-tool response is detected (it could also be set as a lambda function to take other possible actions). As others have said, grammar-based constrained decoding is an alternative but only works for LLM-APIs that support. For issue (2a) Langroid has a DSL[3] for specifying task termination conditions. It lets you specify patterns that trigger task termination, e.g. - "T" to terminate immediately after a tool-call, - "T[X]" to terminate after calling the specific tool X, - "T,A" to terminate after a tool call, and agent handling (i.e. tool exec) - "T,A,L" to terminate after tool call, agent handling, and LLM response to that For (2b), in Langroid we rely on tool-calling again, i.e. the LLM must emit a specific DoneTool to signal completion. In general we find it useful to have orchestration tools for unambiguous control flow and message flow decisions by the LLM [4]. [1] Langroid https://github.com/langroid/langroid https://github.com/langroid/langroid [2] Handling non-tool LLM responses https://langroid.github.io/langroid/notes/handle-llm-no-tool https://langroid.github.io/langroid/notes/handle-llm-no-tool... [3] Task Termination in Langroid https://langroid.github.io/langroid/notes/task-termination/ https://langroid.github.io/langroid/notes/task-termination/ [4] Orchestration Tools: https://langroid.github.io/langroid/reference/agent/tools/orchestration/ https://langroid.github.io/langroid/reference/agent/tools/or...
- dmvaldman 9mo agoThis misses that agentic LLMs are trained via RL to use specific tools. Adding custom tools is subpar to those the model has been trained with. That's why Claude Code has an advantage, over say, Cursor, by being vertically integrated.
- firloop 9mo agoBut if one were to write tools that were "abi-compatible" with Claude Code's, could you see similar performance with a custom agent? And if so - is Cursor not doing just that?
- yencabulator 9mo agoPart of that is likely that Claude Code tools keep changing a little. Imitating them is chasing a moving target.
- mikmoila 9mo agoAre they really? I've been under impression that agentic LLMs are just instances of the LLMs, no "specialized training" involved
- pbw 9mo agoI have mixed feelings about the "Do X in N lines of code" genre. I applaud people taking the time to boil something down to its very essence, and implement just that, but I feel like the tone is always, "and the full thing is lame because it's so big," which seems off to me.
- utopiah 9mo agoI do prototyping for a living and ... I definitely do "X in 1/100th lines of code" regularly. It's exciting, liberating... but it's a lie. What I do is to get the CORE of the idea so that I fully understand it. It's really nice because I get a LOT of millage very quickly... but it's also brittle, very brittle. My experience is that most projects are 100x bigger than the idea they embody because the "real World" is damn messy. There are always radically more edge cases than the main idea enables. At some point you have to draw a line but the furthest away you draw the line, the more code you need to do it. So... you are right to have mixed feeling, the tiny version is only valuable to get the point but it's not something one can actually use in production.
- _def 9mo agoAre there useful open source "agents" already ready to use with local LLMs?
- mephos 9mo agoHow much Claude could a Claude code code if a Claude code could code Claude
- __0x01 9mo agoThese LLM tools appear to have an unprecedented amount of access to the file systems of their users. Is this correct, and if so do we need to be concerned about user privacy and security?
- fragmede 9mo agoWe should be absolutely terrified about the amount of access these things have to users systems. Of course there is advice to use a sandbox but there are stupid people out there (I'm one of them) who disregard this advice because it's too cumbersome, so Claude is being run in yolo mode, on the same machine that has access access to bank accounts, insurance, password manager and crypto private keys.
- erelong 9mo agoKind of a meta thought but I guess we could just ask a LLM to guide us through creating some of these things ourselves, right? (Tools, agents, etc.)
- sams99 9mo agoFor those interested, edit is a surprisingly difficult problem, it seems easy on the surface but there is both fine tuning and real world hallucinations you are fighting with. I implemented one this week in: https://github.com/samsaffron/term-llm https://github.com/samsaffron/term-llm It is about my 10th attempt at the problem so I am aware of a lot of the edge cases, a very interesting bit of research here is: https://gist.github.com/SamSaffron/5ff5f900645a11ef4ed6c87f2b0a6519 https://gist.github.com/SamSaffron/5ff5f900645a11ef4ed6c87f2... Fascinating read.
- emsign 9mo ago> The LLM never actually touches your filesystem. But that's not correct. You give them write access to files it then compiles and executes. It could include code that then runs with the rights of the executing user to manipulate the system. It already has one foot past the door. And you'd have to set up all kinds of safeguards to make sure it doesn't walk outside completely. It's a fundamental problem if you give agentic AI rights on your system. Which in contrast kind of is the whole purpose of agentic AI.
- armcat 9mo agoThe new mental model actually is (1) skills based model, i.e. https://agentskills.io/home https://agentskills.io/home, and (2) where the LLM agents "see all problems as coding problems". Skills are a bunch of detailed Markdowns and corresponding code libraries and snippets. The mental model thereby loops as follows: read only the top level descriptions in each SKILL.md, use those in-context to decide which skill to pick, after picking the relevant skill read the skill in-depth to choose which code/lib to use, based on the <problem, code/lib> generate new code, execute the code, evaluate, repeat. The problem-as-a-code mental model is also a great way of evaluating, and creating rewards and guarantees.
- computerex 9mo agoI 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.
- deleted 9mo ago[deleted]
- RagnarD 9mo agoThis 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?
- utopiah 9mo agoWhy 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?
- vinhnx 9mo agoThis reminds me of Amp's article last year[1]. I building my own coding agent [2]. Two goals: understand real-world agent mechanics and validate patterns I'd observed across OpenAI Codex and contemporary agents. The core loop is straightforward: LLM + system prompt + tool calls. The differentiator is the harness, CLI, IDE extension, sandbox policies, filesystem ops (grep/sed/find). But what separates effective agents from the rest is context engineering. Anthropic and Manus has published various research articles around this topic. After building vtcode, my takeaway: agent quality reduces to two factors, context management strategy and model capability. Architecture varies by harness, but these fundamentals remain constant. [1] https://ampcode.com/how-to-build-an-agent https://ampcode.com/how-to-build-an-agent [2] https://github.com/vinhnx/vtcode https://github.com/vinhnx/vtcode [3] https://www.anthropic.com/engineering/building-effective-agents https://www.anthropic.com/engineering/building-effective-age...
- mirzap 9mo agoThe "200 lines" loop is a good demo of the shape of a coding agent, but it’s like "a DB is a B-tree" - technically true, operationally incomplete. The hard part isn’t the loop - it’s the boring scaffolding that prevents early stopping, keeps state, handles errors, and makes edits/context reliable across messy real projects.
- lucideer 9mo agoThis is a really great post, concise & clear & educational. I do find the title slightly ironic though when the code example goes on to immediately do "import anthropic" right up top. (it's just a http library wrapping anthropic's rest API; reimplementing it - including auth - would add enough boilerplate to the examples to make this post less useful, but I just found it funny alongside the title choice)
- MORPHOICES 9mo ago[dead]
- santiagobasulto 9mo agoI'm surprised this post has so many upvotes. This is a gross oversimplification of what Claude Code (and other agents can do). On top of that, it's very poorly engineered.
- all2 9mo ago> Poorly engineered How so? As a pedagogic tool it seems adequate. How would you change this to be better (either from a teaching standpoint or from a SWE standpoint)?
- jacob019 9mo agoSeems everyone is working on the same things these days. I built a persistent Python REPL subprocess as an MCP tool for CC, it worked so insanely well that I decided to go all the way. I already had an agentic framework built around tool calling (agentlib), so I adapted it for this new paradigm and code agent was born. The agent "boots up" inside the REPL. Here's the beginning of the system prompt: >>> help(assistant) You are an interactive coding assistant operating within a Python REPL. Your responses ARE Python code—no markdown blocks, no prose preamble. The code you write is executed directly. >>> how_this_works() 1. You write Python code as your response 2. The code executes in a persistent REPL environment 3. Output is shown back to you IN YOUR NEXT TURN 4. Call `respond(text)` ... You get the idea. No need for custom file editing tools--Python has all that built in and Claude knows it perfectly. No JSON marshaling or schema overhead. Tools are just Python functions injected into the REPL, zero context bloat. I also built a browser control plugin that puts Claude directly into the heart of a live browser session. It can inject element pickers so I can click around and show it what I'm talking about. It can render prototype code before committing to disk, killing the annoying build-fix loop. I can even SSH in from my phone and use TTS instead of typing, surprisingly great for frontend design work. Knocked out a website for my father-in-law's law firm (gresksingleton.com) in a few hours that would've taken 10X that a couple years ago, and it was super fun. The big win: complexity. CC has been a disaster on my bookkeeping system, there's a threshold past which Claude loses the forest for the trees and makes the same mistakes over and over. Code agent pushes that bar out significantly. Claude can build new tools on the fly when it needs them. Gemini works great too (larger context). Have fun out there! /end-rant
- freehorse 9mo agoThis sounds really cool! I love the idea behind it, the agent having persistent access to a repl session, as I like repl-based workflows in general. Do you have any code public from this by any chance?
- jacob019 9mo agohttps://github.com/jacobsparts/agentlib https://github.com/jacobsparts/agentlib See CodeAgent or subrepl.py if you're just interested in the REPL orchestration. I also have a Python REPL MCP server that works with CC. It isn't published, but I could share it by request. My favorite part of code agent is the /repl command. I can drop into the REPL mid session and load modules, poke around with APIs and data, or just point Claude in the right direction. Sometimes a snippet of code is worth 1000 words.
- ozim 9mo agoMagic is not agent, magic is neural network that was trained. Yeah I agree there is bunch of BS tools on top that basically try to coerce people into paying and using their setup so they become dependent on that provider that provides some value but still they are so pushy that it is quite annoying.
- egeozcan 9mo agoclaude opus 4.5 is much more impressive when used in claude code. I also tried it through antigravity but from a users perspective, claude code is magic.
- bilater 9mo agoI'm curious how tools like Claude Code or Cursor edit code. Do they regenerate the full file and diff it, or do they just output a diff and apply that directly? The latter feels more efficient, but harder to implement.
- m3kw9 9mo agowhy the pointless exercise? Claude code itself can do all that.
- thiagowfx 9mo agoThe blog post starts with: > I’m using OpenAI here, but this works with any LLM provider Have you noticed there’s no OpenAI in the post?
- hooverd 9mo agoWoah now, did you get Anthropic's permission to use Claude outside of Claude Code?
- wizzard0 9mo agowdym? claude code is just a wrapper you can get yourself an api key at console.anthropic.com and build whatever you want (i use local models where possible but must admit opus45 is good)
- akhil08agrawal 9mo agoNice breakdown. Been thinking about this a lot lately - if the core is this simple, what actually becomes the hard part? Feels like we're headed toward a world where everyone can build these loops easily. Curious what you think separates good uses of these agents from mediocre ones.
- wrochow 9mo agoI always laugh when I see a post that claims some tech is "easy". Sure, if all you're doing is creating a hello world script. But try to do something for which a client would pay you more than 25¢ for. Go ahead, try it. We'll wait (!). What about context length, or code validation, architecture, planning, large files... Oh, yes it's easy. That's just so cute.
- voidhorse 9mo agoWait, did people in the tech world not know this? If this is some shocking revelation to engineers we are in trouble. Any and every "AI" experience is just kiddie level program mg wrapping LLMs.
- miki123211 9mo agoAll you actually need is 50 lines and one tool. If your agent can execute Bash commands, it can do anything, including reading files (with cat), writing them (with sed / patch / awk /perl), grepping, finding, and everything else you may possibly need. The specialized tools are just an optimization to make things easier for the agent. They do increase performance (in the "how much can this do", not the "how fast is this" sense), but they're not strictly required. IMHO, this is one of the more significant LLM-related discoveries of 2025. You don't need a context-polluting Github MCP that takes 10+% of your precious context window, all you need is the gh cli, which the agent already knows how to use.
- sathish316 9mo agoExcellent article on the internals of coding CLIs. I learned a similarly powerful way to build DIY coding CLIs from this Martin Fowler post, which uses PydanticAI and MCP-based tools: https://martinfowler.com/articles/build-own-coding-agent.html https://martinfowler.com/articles/build-own-coding-agent.htm... Once you understand the underlying LLM tool-calling protocols described here—and how MCP tool calls work (they’re conceptually very similar)—most coding CLIs stop feeling like magic. Anthropic’s own deep dive on MCP was especially useful for me in seeing how to integrate this into a DIY “Claude Code”-style CLI, and even adapt the same approach for non-coding agents as well: https://www.deeplearning.ai/short-courses/mcp-build-rich-context-ai-apps-with-anthropic/ https://www.deeplearning.ai/short-courses/mcp-build-rich-con...
- domlebo70 9mo agoI don't code in Python much. Are those type annotations really how people are using them, or is it just for the example? def list_files_tool(path: str) -> Dict[str, Any]: And it returns { "path": str(full_path), "files": all_files } Is that useful?
- Waterluvian 9mo agoHow much code could Claude Code code if Claude Code could code Claude?
- cmiles8 9mo agoA lot of software is like this. You can build a bare bones but functional version for 1x investment or something that addresses every bell and whistle (often with market research saying it’s really needed) for 1000x. The 1000x version is better, but not remotely 1000x better. A lot of SaaS has turned into this too. Take a bloated monstrosity like Salesforce and I bet 95% of customers would be very happy with a “bare bones” version that costs 1 10th the price.
- fb03 9mo ago"I'm using OpenAI here" proceeds to show a piece of code importing anthropic was pretty confusing to me
- oars 9mo agoCan't believe Claude Code was launched less than a year ago. It's certainly a new tool in my kit and allowed me to approach and work on new coding problems in a new way.
- stevenslade 9mo agoI’d been wondering how conversation history actually works in these agent loops — the LLM itself has no memory, so whatever “history” exists is just text you keep feeding back in. At a high level it seems to usually be one (or a mix) of: - full transcript appended every turn - sliding window of the last N turns / tokens - older turns summarized into a rolling memory - structured state (goals, decisions, progress) rendered into the prompt - external storage + retrieval (RAG-style) to pull in only relevant past info Under the hood I’m sure it gets more complex, but the core idea is pretty simple once you strip away the mystique: memory = prompt assembly.