Code duplication piles up after weeks of vibe coding

A practical fix and a copyable AI coding prompt. Replace bracketed placeholders with your project details.

1. Check the problem

An agent can recreate a helper that already exists if it has not read that part of the repo. Point it to shared utilities in your project instructions and inspect the diff for duplicate logic before merging.

2. Use the prompt

Before writing any new code for [feature], search the codebase for existing helpers, utilities, or components that already do part of this and list them with file paths. Then implement [feature] by reusing them. When you're done, tell me if you duplicated any logic and show the closest existing helper.

3. Verify the fix

Review the proposed diff, run the relevant checks and exercise the original failing flow before merging.

Continue in the related workflow chapter.