Atomic file writes can now be aborted mid-write by a new beforePublish check that throws PublishRefusedError
The internal helper Claude Code uses to write files and other artifacts safely (writing to a temporary location and then swapping it in, so a crash never leaves a half-written file) now supports a beforePublish check that runs just before the write completes. If that check returns false, the write is aborted, a new PublishRefusedError is thrown, and nothing is published, including cleaning up any empty placeholder file that may have been created along the way.
This gives internal callers a way to cancel a write at the last moment based on some condition, without risking a partially-written or stray file being left behind.