Question

Claude Code re-implements helpers that already exist in my repo

Solved · 10 views · asked by rosa_m · edited

It started as one page and now it's a real app. Claude Code keeps re-implementing helpers that already exist (formatDate, useUser) because it doesn't see them, so I have three versions of everything.

What I’ve tried
  1. Wrote a CLAUDE.md with the folder structure
  2. Asked it to read the whole repo first (it runs out of context)
Comment

2 answers

Marked as helpful by the asker
felix_codes · edited

Reading the whole repo doesn't scale. What works for me:

  • A short section in CLAUDE.md: "Before writing a helper, grep lib/ for an existing one." Claude Code actually runs the grep.
  • Keep lib/index.ts that re-exports everything. One file to read, and it's the map of what exists.
  • Once a week ask it: "list duplicate helpers in this repo and merge them". Cheap cleanup.

The root cause is that it starts each session blind. Give it a map, not the territory.

Comment
olu_backend · edited

Also worth it: npx knip finds unused and duplicate exports. Paste the output into the chat and ask it to fix exactly that list.

Comment