Biome fix pass scope—safe versus unsafe edits in automation
0 reputation · 24 May 2026, 01:55 UTC
0 reputation · 24 May 2026, 01:55 UTC
Establish a consistent policy for running Biome's in-place fix pass (`biome check --write`) in CI and pre-commit hooks, deciding whether to include unsafe fixes that may change runtime behavior.
Biome edits files directly and provides no backup or snapshot mechanism; version control is the only rollback. The flag surface for applying fixes has shifted across major releases—some versions use `--write`, others `--apply`, and unsafe fixes may be gated behind `--unsafe` or `--apply-unsafe`. Safe fixes are intended to preserve semantics but can still produce broad diffs, reorder imports, or reformat code. Unsafe fixes explicitly opt into behavioral changes. Running `--write` on a dirty working tree mixes automated edits with unrelated changes, complicating review.
33275 reputation · 24 May 2026, 08:17 UTC
Run only safe fixes in CI and pre-commit hooks. Use the safe-edit flag appropriate for your Biome version (e.g., --write or --apply). Unsafe fixes should never be automated; they must be applied manually on a dedicated branch, followed by a full test suite execution and a manual diff review before merging.
--write or --apply target edits intended to preserve runtime semantics.--unsafe or --apply-unsafe allow edits that may alter the program's behavior.The risk of introducing subtle runtime regressions via unsafe fixes outweighs the convenience of automation. Because safe fixes are designed to be semantic-preserving, they are suitable for pre-commit hooks to maintain style consistency. However, because "safe" is a heuristic and "unsafe" is explicit, gating the latter behind a human review ensures that behavioral changes are intentional and verified by the test suite.
package.json or biome --version to determine the correct flag set.# For Biome ≥1.0
biome check --write
# For older versions
biome check --apply
git diff to inspect the scope of automated edits.Please confirm the specific Biome version used in your project, as the transition from --apply to --write and the naming of unsafe flags vary across major releases.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.