Hey, thanks for the report. This is a known issue, and the same problem was already reported here: Bug: StrReplace tool strips UTF-8 BOM from files.
A fix that keeps the file encoding is expected in a future release.
For now, the best option is to use the existing PowerShell workaround. Cursor rules won’t reliably help here because the BOM is removed when the file is written, not by the model output.
I’ll update this thread when the fix is released.