skillfed

formatter-development

Learn to implement and modify Biome's formatters using its trait-based IR system. This skill covers generating formatter boilerplate, writing FormatNodeRule implementations, managing comments in formatted output, and validating your work against Prettier using snapshot tests and idempotency checks.

formatter-development teaches you to implement formatting rules for Biome syntax nodes using its IR-based infrastructure.

AI-generated summary based on this skill's SKILL.md

25,418 1,157 Apache-2.0 updated by biomejs

Install

biomejs/biome/formatter-development · repository language: Rust

git clone https://github.com/biomejs/biome
cp -r biome/.claude/skills/formatter-development ~/.claude/skills/formatter-development
npx skillfed install biomejs/biome/formatter-development

Frequently asked questions

AI-generated answers based on this skill's SKILL.md and metadata

How do you implement formatting rules in Biome?

formatter-development teaches you to implement formatting rules by writing FormatNodeRule trait implementations for syntax nodes. You define how each node type should be formatted using Biome's IR-based formatter infrastructure, which handles indentation, line breaks, and spacing. The skill covers generating formatter boilerplate, managing soft and hard line breaks, and handling grouping to control when content wraps across lines.

What is Biome's IR-based formatter infrastructure?

Biome's IR-based formatter infrastructure is the core system that formatter-development uses to transform syntax trees into formatted output. It uses an intermediate representation (IR) with formatting primitives like soft_line_break, hard_line_break, and grouping constructs. This approach separates formatting logic from output rendering, making it easier to implement consistent rules across different syntax node types.

How do you handle comments in Biome formatter output?

formatter-development covers handling comments by understanding how Biome's formatter preserves and positions comments within formatted output. The skill addresses dangling comments—comments that appear after code on the same line or in ambiguous positions—and shows how to use formatter rules to ensure comments are placed correctly relative to syntax nodes without breaking idempotency or readability.

How can you compare Biome formatting with Prettier?

formatter-development includes using Biome's prettier compare tool to validate your formatter output against Prettier's behavior. This comparison helps identify formatting differences and ensures consistency. The skill teaches snapshot testing and idempotency checks to verify that your formatter produces stable, correct output that matches expected formatting patterns.

What are snapshot tests and idempotency checks in formatter-development?

formatter-development teaches snapshot tests as a way to validate formatter output by comparing it against stored expected results. Idempotency checks ensure that running the formatter twice on the same input produces identical output—a critical property for any formatter. The skill covers writing these tests using quick_test.rs and debugging failures when output changes unexpectedly.

How do you debug and fix formatter idempotency issues?

formatter-development shows how to debug idempotency failures by analyzing formatter output across multiple passes. When the formatter produces different results on subsequent runs, you trace the issue through your FormatNodeRule implementations, checking for inconsistent line break placement, grouping logic, or comment handling. The skill teaches using snapshot tests and comparison tools to identify and fix the root cause.

SKILL.md

rendered from the published skill — quoted content, verbatim

Purpose

Use this skill when implementing or modifying Biome's formatters. It covers the trait-based formatting system, IR generation, comment handling, and testing with Prettier comparison.

Prerequisites

  1. Install required tools: just install-tools (includes wasm-bindgen-cli and wasm-opt)
  2. Language-specific crates must exist: biome_{lang}_syntax, biome_{lang}_formatter
  3. For Prettier comparison: Install bun and run pnpm install in repo root

Common Workflows

Generate Formatter Boilerplate

For a new language (e.g., HTML):

just gen-formatter html

This generates FormatNodeRule implementations for all syntax nodes.

(truncated - see the full file via the links below)

Read as markdown · JSON record · Browse the source repository

File tree — 1 file
.claude/skills/formatter-development/SKILL.md

Related skills

Tags

code-formatting syntax-tree-traversal ir-generation test-automation prettier-compatibility idempotency-validation formatter-infrastructure snapshot-testing whitespace-handling ast-transformation