← sources

Code review kept passing duplicate APIs my Claude Code agents built. Now a hook names the owner as they write

source: reddit (reddit:ClaudeCode)published 2026-11-07 12:19ingested 2026-11-08 02:39

retained text

Review couldn't catch them, because the other copy is never in the diff. One audit of one project found 2 cost-query APIs (`LlmCostQueryAPI` and `LLMCostQueryAPI`), a command API defined twice and 2 copies of the API contract.

So now a hook runs after every Write or Edit (and Codex's apply_patch). It looks each new function, class, route or table write up in the project's generated API index, ignoring case and word order. On a match it names the owner and asks the agent to extend that instead. It never blocks.

The first version grepped the whole repo: 6.1 s, past the hook's 2 s timeout, so it said nothing. Reading the index takes about 45 ms.

It went live on 7 November, so there's no catch count yet.

Write-up: https://maclulich.com/blog/stop-agents-duplicating-code/ (my blog)

How do you stop your agents rebuilding what's already there?

document fetched 2026-11-08 00:33 · canonical https://reddit.com/r/ClaudeCode/comments/1xq52lp/code_review_kept_passing_duplicate_apis_my_claude