Use this skill whenever implementing or debugging Biome formatter behavior, IR composition, node rules, layout selection, source-comment handling, verbatim formatting, idempotency, internal specs, or Prettier comparison. Do not use it for generic snapshot commands or parser changes.
69
84%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
View guide
Passed
No findings from the security scan
Use crates/biome_formatter/CONTRIBUTING.md and the language formatter's guide as the canonical architecture references. Inspect neighboring node implementations before selecting IR primitives.
quick_test.Formatter output is a structured rewrite of the source tree, not a fresh pretty-printer. Treat every missed node, missed token, unchecked suppression, and untracked replacement as a formatter bug, not as style feedback.
format_removed, replacing it with format_replaced, or by a language-specific helper that does one of those operations.node.format() or node.format().with_options(...) so the node's own rule formats the node, checks suppressions, and routes comments through the formatter infrastructure.f.context().comments().is_suppressed(node.syntax()); if the node is suppressed, it MUST write the language's format_suppressed_node(...) helper instead of formatting the node body. Without this check, debug builds fail suppression coverage and user suppressions can be ignored.token("...") only for syntax inserted by the formatter when no source token exists.format_removed(&token). Do not drop the field, bind it to _, or omit it from write! without consuming it through format_removed; skipped trivia still belongs to that token.format_replaced(&token, &replacement). Do not print the replacement directly and do not use token("...") for replacement text, because the original token still has trivia and must be marked consumed.Format<Context>. Do not use free functions or stored closure values to carry formatter state or layout invariants. Use format_with only for one-off local glue that is immediately written.Generated node rules implement FormatNodeRule. In fmt_fields:
*Fields type explicitly;_ rather than .. only when the field is consumed elsewhere in the same formatting path or deliberately handled by format_removed / format_replaced; otherwise _ on a node or token field is a dropped-tree bug;format_verbatim_* methods preserve a node's source text. Replace verbatim formatting with structured formatting only when tests cover valid, malformed, and commented forms of the node.
Format, replace, or remove every token. Formatter tests panic when a token is not handled, preventing accidental source loss.
Use format_replaced when substituting a token and format_removed when removing one.
Format a node through node.format() when possible. Its regular rule checks formatter-suppression comments as part of normal formatting.
When a helper formats a node or its tokens outside FormatNodeRule, run the formatter tests. If the suppression-check assertion reports a node, call f.context().comments().mark_suppression_checked(node.syntax()) for that reported node. The assertion shows that the helper bypasses the node's normal suppression check.
Use semantic IR rather than writing whitespace as arbitrary text:
space() for required spaces;For a distinct formatting concern, use a named type implementing Format. A cluster of free functions that pass &mut Formatter obscures what has already been written and which layout invariants apply.
Represent multi-way layout with an enum selected once. Recomputing layout at several write sites can produce inconsistent output and idempotency failures.
Leading and trailing comments are generally handled by formatter infrastructure. Explicitly format dangling comments when the node owns a position to which no child can attach them.
Test comments at each structural boundary affected by the change: before the first child, between children, after the last child, and around empty nodes. Dropping or moving a source comment is data loss.
Load testing-codegen for snapshot commands and review.
Internal specs should contain the focused source shapes needed to establish canonical output. Where useful, include both already formatted and deliberately unformatted inputs that should converge to the same result.
The formatter test infrastructure reformats error-free, non-range output during the test invocation and fails when the second result differs. IR is diagnostic evidence when output differs; it is not a separate equality contract.
Add internal specs for behavior changes even when a Prettier snapshot changes or disappears. Agreement with one external corpus input does not cover the changed edge case.
Use the repository tool when compatibility is part of the requirement:
bun packages/prettier-compare/bin/prettier-compare.js --rebuild -l js 'const value={a:1}'
bun packages/prettier-compare/bin/prettier-compare.js --rebuild -f path/to/file.js--rebuild rebuilds Biome's WASM bundle and writes build outputs. It is appropriate during implementation, not during a read-only review.
Treat differences as input to design, not automatic bugs. Biome may intentionally differ when its documented behavior or architecture requires it.
After changing source in a language formatter crate:
just f and just l before committing.f.context().comments().is_suppressed(node.syntax()) before formatting the node body manually.format_removed, or replaced with format_replaced; no source token is silently skipped, bound to _, or recreated as static text.Format<Context> rather than free functions or closure values.crates/biome_formatter/CONTRIBUTING.mdcrates/biome_js_formatter/CONTRIBUTING.mdcrates/biome_formatter_test/src/spec.rspackages/prettier-compare/README.md40dd3fb
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.