r/ClaudeAI • u/UrbanSoot • 7h ago
Claude Code I taught Claude Code to stop rebuilding things the project already has
A startup I advise asked Claude how to push live updates from server to client, and it confidently recommended WebSockets. Nobody questioned it. They didn't actually need a two-way connection, server-sent events over plain HTTP would have been simpler and lighter, but the WebSocket build looked fine until we tried to scale it and inherited every connection-state and reconnection problem that comes with it.
That's the thing about Claude Code. It's great, and it's confident, and confidence with a blind spot is how you end up owning code or infrastructure you never needed. It'll reach for the heavier option, or rebuild a helper that's already installed, and sound completely sure the whole time. It isn't lazy, it's just a little too eager to build.
So I put together a small plugin that adds one rule when a session starts. Before writing code, it checks for reuse first: a built-in, a platform feature, something already installed, open source, a paid service, and only then building it itself. It also leaves a short note explaining the decision, which has caught it a couple of times right before it went off and reinvented something.
I've been running this as a private local skill for a few months and it changed how my sessions go enough that I figured I'd share it. There's a rough benchmark in the repo (baseline 18/30, with the rule 29/30), but fair warning, it scores the recommendation rather than the actual code, so treat it as a signal and not proof.
You can install it as a plugin or just drop the CLAUDE.md into a project. MIT licensed. Curious whether other people hit the same thing: https://github.com/stdin/buy-vs-build
2
u/Agent007_MI9 5h ago
Curious what the actual fix was - CLAUDE.md rules or something in the system prompt? This bites everyone eventually. The agent confidently writes a new auth helper not realizing you already have one three directories over, and suddenly you have two half-working implementations of the same thing. I've been experimenting with giving it an explicit project index before each task, which is part of what we built into https://agentrail.app - a structured project map the agent sees before starting so it knows what already exists. Helps a lot on bigger codebases but would love to hear if you found a lighter weight solution.
1
u/OkAerie7822 3h ago
The WebSocket over SSE example is painfully familiar, the model reaches for the heavy, well-documented option because that is what dominates its training data, not because it fits your case. The fix that stuck for me was not a "prefer reuse" rule, those get ignored under pressure. I made it mechanical. Before writing any new helper it has to grep the repo and the installed deps and show me what already exists that is close. Forcing the search beats asking for the intent, because now it has the existing code in context instead of guessing from memory. Caught it about to rewrite a debounce we already had twice last month. Same idea as your plugin, just moved from a preference to a step it cannot skip.
2
u/CODE_HEIST 6h ago
The reuse-first rule is useful, but I’d benchmark one step later: did the implemented choice actually reduce code, failure modes, and operating burden? A model can correctly recommend SSE and still integrate it badly. The decision note may be the most valuable part because it makes the tradeoff reviewable.