I broke my project 4 times before I learned how to use Composer Agent mode correctly. Here are the exact techniques that let me refactor 20 files without introducing bugs.
How do you structure a multi-file refactoring prompt?
One function at a time. Not one refactor at a time. I used to write ‘refactor the auth system to use JWT’ and got 400 lines of broken code. Now I prompt: ‘create a JWT utility function in /lib/jwt.js’ then test it. Then ‘update the login route to use the JWT utility’ then test it. Each step is reversable if it breaks.
How do you prevent Composer from breaking unrelated files?
Lock files you do not want touched. I add a comment at the top of files: // LOCKED — do not modify without explicit instruction. Composer respects this instruction about 80% of the time. For critical files like database config, I tell Composer: ‘read only — do not modify.’ I keep a list of locked paths in my .cursorrules file.
Leave a Reply