Claude Code in 9 lines of Python
Let me fetch the source material before writing. The Reddit page came back as raw HTML. Let me search for the actual post content within the file. I now have…
By Dillip Chowdary • Aug 09, 2026 • Source: HN Claude/Codex/Fable
What happened
Let me fetch the source material before writing. The Reddit page came back as raw HTML. Let me search for the actual post content within the file. I now have enough detail from the raw Reddit JSON embedded in the page and from the web search. Let me also quickly fetch the GitHub repo. I now have rich source material. Here is the piece:
---
The technical detail
A Reddit post by user tosh in the LocalLLaMA community, published on August 8, 2026, shared a GitHub repository called smol — a coding agent implemented in nine lines of Python — and claimed it could be used in the same way as Claude Code or Codex. The post drew 73 comments and over 61,000 views, with the discussion splitting quickly between those who found it an elegant demonstration and those who pushed back on the headline itself.

The mechanics of smol are straightforward. The implementation maintains a conversation history variable, accepts a prompt from the command line, and runs a loop that sends messages to any OpenAI-compatible API endpoint, processes tool call responses, and feeds results back into the history. The only tool exposed to the model is sh, a shell handler that lets the language model issue arbitrary system commands. There is no system prompt, no MCP client, no memory mechanism, no structured file-reading tool. The author noted that, measured with the OpenAI tokenizer, the implementation comes in at 220 tokens. The repository also includes a Go implementation built on standard library alone, and the author subsequently shared Clojure and Babashka variants as well as a version using the OpenAI function-calling format rather than custom tool schema, which allows the loop to work out of the box with Ollama and DeepSeek v4 flash.
Advertisement
Tech Pulse Daily
Get tomorrow's pulse first
Join engineers who read Tech Pulse before stand-up. Free, weekday mornings.
Why it matters for builders
The question that matters for engineers is not whether nine lines is a real count — it is not, or at least not honestly — but whether the resulting architecture teaches something useful. It does. The agent loop that powers Claude Code, Codex, opencode, and pi is essentially this: receive a prompt, call the model, inspect the response for tool use, execute tools, append results to history, repeat until the model stops requesting tools. Every additional feature in the mature tools — MCP integration, sub-agent dispatch, permission dialogs, context compaction, telemetry, memory backends — is layered on top of this spine. Knowing the spine precisely is not a beginner concern; it matters to engineers who want to understand why token costs scale the way they do, or who need to wire agentic loops into environments those larger tools do not support.
On the question of performance, the author shared benchmark traces hosted at smolenv.com comparing smol against opencode, pi, hermes, and Codex on at least two concrete tasks — a nested template rendering problem and a DuckDB sessionization problem — using the gpt 5.6 sol model. The author reported that smol used fewer tokens, finished faster, and consumed less peak RAM than the other harnesses. One commenter noted that the absence of a system prompt can degrade model performance, and the author's response was that for newer, stronger models the system prompt appears to add overhead rather than focus. That claim is not fully substantiated across a broad benchmark suite, and the author acknowledged that older models likely benefit from good system-prompt scaffolding.
Market and competitive context
The competitive frame here is not smol versus Claude Code as shipped products; they are not in the same class. The relevant comparison is between this approach — roll your own, standard library only, no framework lock-in — and the cluster of minimal-harness projects like pi, hubcap, and Hugging Face's smolagents. Pi is the community's preferred middle ground: deliberately minimalist, explicitly designed to be extended, carrying a sensible permission model. Smolagents advertises a thousand lines of code but imports heavily from third-party libraries, making the actual surface area larger than its line count implies. Smol goes further than pi in stripping away conventions, which makes it more useful as a reference implementation and less useful as a daily driver. The author positioned it as starter dough — a base you modify rather than a finished tool.
The practical takeaway is about portability and context budget. Because smol depends only on Python standard library, it runs on operating systems that Claude Code, Codex, and similar tools do not target. One commenter mentioned planning to use a Python harness on DragonFlyBSD precisely for this reason. The broader lesson: the context window fills fastest with tool schemas, system prompts, and framework boilerplate. A shell-based universal tool collapses the schema surface to a minimum. Whether that tradeoff holds across diverse task types is what the smolenv.com benchmark page is intended to track over time, and it is the right question to watch.
What to watch next
The open risks are real. Exposing raw shell access as the only tool removes any fine-grained permission surface; the model can in principle run whatever the process owner is allowed to run. Larger harnesses implement command-approval flows, denylists, and sandbox constraints for exactly this reason. The author did mention logging requests and responses through a proxy for auditability, but that is observability after the fact, not a permission gate before. The code-golf framing also caused friction: the top comment, with 96 upvotes, called out that nine lines achieved by collapsing multiple statements per line is not nine logical operations, and the author conceded by posting a de-golfed version in the comments. Both the golfed and de-golfed versions point to the same prior art insight — that agent harnesses as a category have accreted complexity faster than models have needed it, and that the gap between what the loop requires and what production tools ship is worth examining directly.
Advertisement