Skip to content
RCreddit.com·

Coding agents write a new helper instead of finding the one you already have

AI summary

Coding agents often create new helper functions, like for formatting dates or parsing prices, even when existing, well-tested utilities (e.g., "formatDate" in "src/utils") are already available in the repository. This can lead to redundant code and neglect of previously implemented fixes, such as a timezone correction. Providing clear instructions to the agent, specifying the location of shared utilities (e.g., "date and money helpers are in src/utils, API wrappers in src/api"), can mitigate this issue. This behavior is also observed in AI chat interfaces like ChatGPT or Claude.

Time & source

Times shown in UTC

Display time zone: UTC

Local time zone unavailable; showing UTC.

PublishedOffset at this time: UTC+0Sep 29, 2026, 15:18 UTC

IngestedOffset at this time: UTC+0Sep 29, 2026, 19:00 UTC

Published
Sep 29, 2026, 15:18
Ingested
Sep 29, 2026, 19:00
Source type
Dev community
Tier
Community
Source status
Healthy

Tier is a per-source editorial setting, not a per-item score.

Ask an agent to format a date, parse a price, retry a request. It writes a fresh function for it, right there in the file it's editing. Meanwhile the repo already has formatDate in utils, used in forty places, with the timezone fix you spent a day on last spring.

Now you have two. The new one doesn't have the fix. Six weeks later someone changes one and not the other.

Writing is cheaper than searching. The agent sees the file it's in, and nothing in "add a created date to this card" says "look for how we already format dates". So it doesn't look.

What I add to the instructions file:

Before writing any new function, search the codebase for an existing one that does the same job. List what you found. Only write a new one if nothing fits, and say why the existing ones don't.

And a review prompt after any session that added code:

List every new function or helper you added in this session. For each one, search the codebase for existing functions with similar behavior, and show me any you find.

The second one is the one that pays off. It finds a duplicate more often than not, and usually one I would have missed in review because the new helper looks perfectly reasonable on its own.

Pointing it at the right folders helps too. One line in the instructions file listing where shared utilities live ("date and money helpers are in src/utils, API wrappers in src/api") cuts most of it before it starts.

I keep the review prompt saved in AI Toolbox, the extension I build, for when I'm working through code in a ChatGPT or Claude chat instead of the agent, since chat does the exact same thing.

Source·reddit.com