I’m quite sure this doesn’t cover all cases, BUT here’s something to watch out for if you’re getting whole-script duplication.
It seems sometimes Claude-3.5-sonnet likes to put in // ... existing code
markers even before the start of the actual script. Let’s say you’re writing JS and your file starts:
<script>
// things ...
Sometimes it seems Claude will supply your suggested change as:
// ... existing code ...
<script>
// ... existing functions
something
This seems to lead to the engine interpreting it as “put all of the existing code here at the top, and then we’ll continue from <script>
”, which obviously causes duplication.
I’ve worked around this several times by hitting “Ask” and then saying something like: ‘can you re-state this proposed update? placing " … existing code …" at the top before the script tag is confusing the diff engine and causing duplication. there shouldn’t be any existing code before the script tag.’
Not a complete solution but it might help a few folks in such circumstances; it’s certianly something to watch out for.