Claude Code in 9 lines of Python
The Reddit page returned mostly HTML/JavaScript. Let me search for the actual post content more specifically. I now have substantial content from the Reddit…
By Dillip Chowdary • Aug 09, 2026 • Source: HN Claude/Codex/Fable
What happened
The Reddit page returned mostly HTML/JavaScript. Let me search for the actual post content more specifically. I now have substantial content from the Reddit post. I can see the key details: the project is called "smol" hosted at github.com/smol-env/smol, posted by user tosh, with 83 comments and 63,747 views. The post involves a minimal coding agent implementation. Let me also quickly search for the linked GitHub project for more technical detail. I have enough information from the Reddit post metadata and comments to write a well-grounded piece. Key facts from the source:
- Posted by user tosh on Reddit's LocalLLaMA community (795,097 subscribers) - The project is called "smol" at github.com/smol-env/smol - Described as "smol is a smol agent" - 83 comments, 63,747 views - The author's goal: a minimal coding agent that works like Claude Code or Codex - The implementation is 220 tokens by the OpenAI tokenizer - The "9 lines" claim was contested — the top comment (98 upvotes) called it code-golfed, not genuinely 9 lines - The author also posted a Go implementation and a Clojure (Babashka) implementation - Commenters debated what Claude Code actually constitutes (memory, plugins, MCP, telemetry, configuration) - Author acknowledged compaction takes "a few more lines" - Author claims production-comparable Claude Code could be done in ~100x less code than Anthropic's implementation - The post went from 15+ upvotes to 0, suggesting vote manipulation
Here is the article:
The technical detail
---

A developer using the handle tosh published a Reddit post titled "Claude Code in 9 lines python" to the LocalLLaMA community, linking to a GitHub repository called smol under the organization smol-env. The post drew 83 comments and 63,747 views, with discussion quickly splitting between people who found value in the minimal implementation and critics who challenged both the line count and the claim that the result was meaningfully analogous to Claude Code or OpenAI's Codex. The post's vote count moved from above 15 down to zero during the discussion, suggesting coordinated downvoting, though the author noted being surprised at the swing.
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 smol project implements what the author calls an agent loop: a stripped-down structure that takes a user prompt, calls a language model with tool-use capability, executes the returned tool calls, and feeds results back into the next model turn. This cycle repeats until the model produces a final text response rather than another tool invocation. The entire Python implementation reportedly clocks in at 220 tokens by the OpenAI tokenizer, making the whole agent loop smaller than a moderate system prompt. The author also published implementations in Go and in Clojure using the Babashka runtime, suggesting the core pattern is language-agnostic and maps cleanly to whatever async execution model is available.
The most-upvoted criticism, with 98 upvotes, came from a commenter named hougaard, who argued the "9 lines" figure is achieved by collapsing what would normally be many lines of readable code into as few line breaks as possible — code golf rather than genuine brevity. The author responded by posting a more expanded version and acknowledging the density, but defended the compressed form as easier for them to survey at a glance as the sole maintainer. The author separately noted that when experimenting with aliased variants to reduce token count further, some aliases actually increased total token usage, which is a counterintuitive result worth noting for anyone trying to optimize prompts or agent scaffolding for context efficiency.
Market and competitive context
For engineers building on top of model APIs, the smol project serves a concrete purpose: it exposes exactly how little scaffolding is required for an agent loop to function. Production tools like Claude Code carry substantial infrastructure — memory mechanisms, plugin systems, MCP client and server components, telemetry pipelines, configuration management, and authentication flows. None of that is the agent loop itself. Smol strips all of it away, leaving only the conversation state, tool dispatch, and the cycle logic. When an engineer or researcher wants to understand where a given model fails, or wants to wire up custom tooling without pulling in a heavy dependency, a 220-token core is a much cleaner starting point than several thousand lines of an established CLI tool.
Claude Code is Anthropic's terminal-based coding assistant, and Codex is the name OpenAI used for both its earlier code-generation model and its own agent CLI. Both are built around the same fundamental loop smol reimplements: give the model access to tools, let it call them, feed back the results, repeat. The difference is that Anthropic's production implementation includes memory compaction, which the smol author notes takes additional lines to implement, plus conversation persistence, project-level context management, and the guardrails that make the tool usable by people who are not debugging the agent loop itself. A commenter named LocoMod summed up the skepticism: an agent loop is not Claude Code, in the same way that a TCP socket is not a web browser.
What to watch next
The practical takeaway is that the smol repository functions as an educational reference and a fork-and-extend starting point rather than a production substitute. The author's own framing — describing it as "starter dough" for an agent — is accurate. A team that wants to build a domain-specific coding agent targeting a particular codebase, with custom tools and a tailored system prompt, will cover more ground starting from smol than from trying to configure and constrain an existing CLI tool. The Go and Clojure implementations also suggest that teams working outside Python have tested entry points. Watch for whether the author follows through on plans to add de-golfed, documented versions of the implementations, which would significantly lower the onboarding cost.
The open question the comment thread kept circling but never quite answered is definitional: at what point does an agent loop become the thing it resembles? The author asked commenters to specify what features they would require to call something "a Claude Code," and received disagreement in response. Memory, MCP, telemetry, and configuration management were all named, but no consensus emerged on what the minimum viable set would be. That ambiguity is not just rhetorical; it matters for teams evaluating how much custom agent infrastructure they actually need to build versus how much they are building out of habit or because an existing tool bundles it. Smol's most valuable contribution may be making that question harder to dodge.
Advertisement