Refactoring Prompt for Post-LLM Coding Tasks

lucasmeijer · x · 2026-07-12

The author shares a prompt they append directly after every LLM coding task: asking the model to review all its changes, simplify the code as much as possible, remove dead code, reuse shareable logic, and clean up leftovers from previous attempts. They admit this might not be optimal, but it works "much better than doing nothing"; replies add that this is done within the **same context window**.

Related event: Developers Share Post-Generation Refactoring Prompt for LLM Coding(2 posts)→

Original post →

More from coding & agent

coding & agent channel →