Live data from Hacker News

How to code Claude Code in 200 lines of code

mihaileric.com

221–230 of 249 posts

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

#222
Nice 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.

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

#223
post #214

Earlier quoted context omitted.

Models 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…

> 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. Any idea on why the other end of the spectrum is this way -- thinking that it always has something to do? I can think of a pet theory on it stopping early -- that positive tool responses and such bias it tow…

> Any idea on why the other end of the spectrum is this way -- thinking that it always has something to do?

Who said anything about "thinking"? Smaller models were notorious for getting stuck repeating a single word over and over, or just "eeeeeee" forever. Larger models only change probabilities, not the fundamental nature of the machine.

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

#224

This 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.

Are they really? I've been under impression that agentic LLMs are just instances of the LLMs, no "specialized training" involved

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

#225

This 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.

But 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?

Part of that is likely that Claude Code tools keep changing a little. Imitating them is chasing a moving target.

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

#227

Woah now, did you get Anthropic's permission to use Claude outside of Claude Code?

wdym? 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)

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

#228

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’m a DIY (or, less generously and not altogether inaccurately, NIH) type who thinks he could do a good job of smarter context management. But, I have no particular reason to know better than anyone else. Tell me more. What have you seen? What kinds of approaches? Who’s working on it?

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

#229

Earlier quoted context omitted.

> there's a threshold past which Claude loses the forest for the trees and makes the same mistakes over and over. Try using something like Beads with Claude Code. Also don't forget to have a .claude/instructions.md file, you can literally ask Claude to make it for you, this is the file Claude reads every time you make a new prompt. If Claude starts acting "off" you tell it to reread it again. With Beads though, I bas…

Ohh, looks interesting, thanks for the tip! Git as db is clever, and the sqlite cache is nice. I'd been sketching sqlite based memory features myself. So much of the current ecosystem is suboptimal just because it's new. The models are trained around immutable conversation ledgers with user/tool/assistant blocks, but there are compelling reasons to manipulate both sides at runtime and add synthetic exchanges. Priming…

I am working on a strict sqlite alternative to Beads as an experiment so far it works.

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

#230
I 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.

Post reply on HN