{"version":"2.1.275","anchor":"atomic-file-writes-support-a-beforepublish-refusal-hook","canonical_anchor":"atomic-file-writes-support-a-beforepublish-refusal-hook","heading":"Atomic file writes support a 'beforePublish' refusal hook","tier":"internal","area":"File Writes","scope":null,"heads_up":null,"url":"https:\/\/changelogs.core-directive.com\/v\/2.1.275\/e\/atomic-file-writes-support-a-beforepublish-refusal-hook","release_url":"https:\/\/changelogs.core-directive.com\/v\/2.1.275","markdown":"### Atomic file writes support a 'beforePublish' refusal hook\n\nAtomic file writes can now be aborted mid-write by a new beforePublish check that throws PublishRefusedError\n\n**What**\n\nThe 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.\n\n**Why**\n\nThis 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.\n\n- Area: File Writes\n- Tier: Under the hood\n- Useful: 3\/5\n- Signal: 2\/5"}