Catalogue / unify-repo-formatting
unify-repo-formatting
Older skill: source not recordedSignedAudits a repository's code-formatting setup, then configures one formatter per language and wires it into everyday tooling: Biome or Prettier for JavaScript and TypeScript, Ruff format for Python, rustfmt for Rust, each aligned with EditorConfig, package scripts, pre-commit hooks, CI steps and VS Co…--- name: unify-repo-formatting description: > Audits a repository's code-formatting setup, then configures one formatter per language and wires it into everyday tooling: Biome or Prettier for JavaScript and TypeScript, Ruff format for Python, rustfmt for Rust, each aligned with EditorConfig, package scripts, pre-commit hooks, CI steps and VS Code settings. Distinguishes a tool being installed from formatting actually being invoked, migrates Black to Ruff format, and moves Prettier to Biome only on request. Use when a project lacks a formatter, has conflicting or partial formatting configuration, needs a formatting audit and report, or needs formatting enforced in scripts, hooks, CI or editors. Not for lint-rule configuration, one-off reformatting of single files, or replacing a working setup nobody asked to change. license: MIT ---
One Formatting Standard, Proven Enforced
You take a repository from inconsistent per-author styling to one formatter per language, one set of style numbers, and evidence that the formatter actually runs. You draft, propose and verify; the user decides, approves and commits. This workflow adapts an MIT-licensed community skill — keep that notice if you redistribute it.
Hard limits
- Formatting only. Do not configure lint rules, and for each tool choose the format-only hook id, never an id that also lints.
- Never change an existing file without showing the intended edit and receiving a yes in this conversation.
- Three acts additionally require an explicit yes, a clean working tree, and one dedicated commit each: rewriting source files across the repository, retiring a formatter (its dependency, config and ignore files together), and editing a shared CI workflow. Never commit or push — the user does both.
- Install tools only through the project's own package manager. Never fetch a script from the network and execute it as a shortcut.
- Never call a tool outdated without checking its official release page in this session and naming where you checked.
- Never record an enforcement surface as present when it is not; the closing standards file must describe the repository as it actually is, including surfaces the user declined.
Collect the decisions first
Settle four things with the user before touching files:
- Mode. Audit-only means produce the report below and stop. Anything else proceeds with every gate above intact.
- Tool per language. JavaScript/TypeScript: Biome by default for new setups; an existing Prettier setup is fully supported and stays unless the user wants the switch or accepts a concrete argument for it. Python: Ruff format, with Black as its maintained-mode predecessor. Rust: rustfmt, bundled with the toolchain. If two formatters cover the same files, plan a consolidation rather than stacking them; one root config per monorepo unless packages truly diverge.
- The numbers. One line width and indent size per language, repeated identically in the formatter config, EditorConfig, scripts and CI. The examples below use 96/2 for JS-TS, 90/4 for Python and 100/4 for Rust — substitute the user's picks everywhere numbers appear.
- Enforcement surfaces. For each of check script, pre-commit hook, CI step and editor integration, get an explicit opt-in or decline and remember the answer. A check script plus a CI step is the minimum worth recommending.
Audit: separate installed from invoked
Read the files that carry evidence: package.json and the lockfile, pyproject.toml, Cargo.toml, .editorconfig, .pre-commit-config.yaml, .vscode/settings.json, .vscode/extensions.json, and the CI workflow directory.
Presence — what points at a tool:
| You find | Points to | |---|---| | biome.json with a formatter block, or @biomejs/biome in the lockfile or scripts | Biome | | .prettierrc* / prettier.config.*, or prettier among dev dependencies | Prettier | | ruff in a dependency group or lockfile, any [tool.ruff] section, or ruff.toml / .ruff.toml | Ruff — installed, nothing more | | [tool.black], or black in dependencies | Black | | rustfmt.toml or .rustfmt.toml | rustfmt |
Invocation — what proves formatting actually runs:
| Surface | What counts | |---|---| | Scripts or task runner | an entry whose command formats or format-checks | | Pre-commit | a format-only hook id | | CI | a step running the drift-check command | | Editor | defaultFormatter naming the tool, with format-on-save enabled |
A tool is the project's active formatter only when presence and invocation agree. The distinction decides the Python verdict: Ruff is a linter that also formats, so a dependency entry, a lockfile hit, or a [tool.ruff] section — even one setting line-length and exclude — proves only that Ruff is installed, most plausibly for linting. Call Ruff formatting active only when you can point to a ruff format command in a script, a ruff-format hook, a CI step, or the editor assignment. A [tool.ruff.format] sub-table shows someone chose formatting options; if no command anywhere invokes ruff format, report "formatting configured but never run" and treat Python as unenforced until wiring exists. Apply the same presence-plus-invocation test to Biome, whose all-in-one entry point also lints.
Then audit each active formatter for: config parses; width, indent, quotes and line endings decided; generated and vendored paths excluded; drift-check script present; hook present; CI checks formatting; .editorconfig agrees on indent and endings; VS Code assigns the same tool the scripts, hooks and CI invoke; extensions.json recommends that tool's extension. A Prettier extension recommendation under Biome scripts is a conflict — report it, never split the difference.
Run each applicable drift-check command, count files that would change, and report compactly:
Formatting audit — ledger-sync TypeScript Biome format active: biome.json, "fmt:check" script, hook, CI step Python Ruff installed (dev group), no format invocation — lint-only, no formatter enforced Rust rustfmt active via cargo fmt in CI Options width 96 / 2 spaces (TS), 90 / 4 (Py), 100 / 4 (Rs) Exclusions vendored/webauthn-js not excluded — 2 of 14 drift files live there EditorConfig matches TypeScript only VS Code format-on-save off, no default formatter assigned Drift 14 TS files, 3 Py files would change
When the audit hits trouble
- No package manager. No
package.jsonor lockfile, no Python environment, no Rust toolchain: stop before installing anything. Offer the choices — the user installs a manager and you continue, or you work config-only, writing configs and scripts without executing the formatter. - Config fails to parse or a field is rejected. Quote the diagnostic with file and line, print the current contents, propose the fix, and apply it only after approval. Rerun until the tool loads cleanly.
- Two formatters, one language. Warn and propose the consolidation sequence below.
- Drift found. List counts by area and offer the gated rewrite as a follow-up.
Write the configs
Add each tool as a dev dependency through the project's manager (npm/pnpm/bun for the JS tools, the uv dev group for Ruff; rustfmt ships with the toolchain). Write only what was decided.
Biome. Read the exact installed version from the lockfile first — the $schema URL must name it, and exclusion syntax moved between majors:
{
"$schema": "https://biomejs.dev/schemas/VERSION/schema.json",
"formatter": { "enabled": true, "indentStyle": "space", "indentWidth": 2, "lineWidth": 96, "lineEnding": "lf" },
"javascript": { "formatter": { "quoteStyle": "double", "semicolons": "always", "trailingCommas": "all" } },
"files": { "includes": ["**", "!**/generated", "!**/dist"] }
}If the binary flags includes as unknown, the installed major expects files.ignore with plain paths — switch and rerun the check command to confirm clean loading and skipped directories.
Prettier. .prettierrc.json plus a separate .prettierignore covering dependency folders, build output, lockfiles, and minified or vendored files:
{ "printWidth": 96, "tabWidth": 2, "useTabs": false, "semi": true, "singleQuote": false, "trailingCommas": "all", "endOfLine": "lf" }Ruff format. In pyproject.toml:
[tool.ruff] line-length = 90 exclude = [".venv", "dist", "build", "generated"]
That section is complete: ruff format takes width and exclusions from it and applies Black-compatible defaults for quotes, indentation and line endings. Add [tool.ruff.format] only to override a default, and note why. docstring-code-format defaults to off; enabling it rewrites example code inside docstrings, which Black never did — discuss before turning it on.
rustfmt. rustfmt.toml beside Cargo.toml, stable options only:
max_width = 100 tab_spaces = 4 hard_tabs = false newline_style = "Unix"
Set edition only when it differs from Cargo.toml. Comment wrapping, doc-comment formatting, string formatting and import grouping are nightly-only. On stable, rustfmt typically warns and proceeds without them — behavior varies by version, so run the formatter with the toolchain the project actually selects (check rust-toolchain.toml, else the default) and read the output rather than guessing. If an option is rejected, drop it, or get an explicit team commitment to nightly — and then point CI at that same toolchain, since output differs between channels.
Wire only the approved surfaces
Scripts. Add a rewrite entry and a drift-check entry. Check commands never modify files and exit non-zero when anything drifts — that exit status is what hooks and CI reuse:
| Tool | Drift check (read-only, non-zero exit on drift) | Rewrite | Extras | |---|---|---|---| | Biome | biome format . | biome format --write . | --reporter=github emits CI annotations | | Prettier | prettier --check . | prettier --write . | — | | Ruff | ruff format --check . | ruff format . | ruff format --diff . previews the patch | | rustfmt | cargo fmt --all -- --check | cargo fmt --all | — |
EditorConfig. Mirror indent and width per language and the formatter's line-ending choice. Comments must sit on their own line — trailing text becomes part of the value:
root = true
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
[*.{js,cjs,mjs,ts,tsx,json,yaml,yml}]
indent_style = space
indent_size = 2
# equals Biome lineWidth, or Prettier printWidth
max_line_length = 96
[*.py]
indent_style = space
indent_size = 4
# equals ruff line-length
max_line_length = 90
[*.rs]
indent_style = space
indent_size = 4
# equals rustfmt max_width
max_line_length = 100Trim trailing whitespace for code files but not Markdown, whose hard breaks depend on it; Makefiles require tabs. Add those exception stanzas only where such files exist.
Pre-commit. One format-only entry per tool:
| Tool | Repository | Hook id | Avoid | |---|---|---|---| | Biome | biomejs/pre-commit | biome-format | biome-check (lints too) | | Prettier | pre-commit/mirrors-prettier | prettier | — | | Ruff | astral-sh/ruff-pre-commit | ruff-format | ruff (lints) | | rustfmt | doublify/pre-commit-rust | fmt | — |
Look up each repository's newest release tag online in this session — never from memory — and use it as rev. Pin Biome's additional_dependencies to the release the project depends on so hook runs match local runs. If a mirror is archived or lacks the id at that tag, fall back to a local hook (repo: local, language: system) whose entry runs the project's own drift-check script.
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "" # the tag you verified this session
hooks:
- id: ruff-formatPreview shortened. The full SKILL.md is in the pack.
| File | Size | SHA-256 |
|---|---|---|
| SKILL.md | 15.5 kB | 71ae641f2a82 |
| THIRD_PARTY_NOTICES.md | 1.4 kB | 34c398a0bbba |
| examples.json | 2.2 kB | ed1686dcba08 |
Published verbatim from the pinned commit. Nothing is rewritten.
| Version | Pinned commit | Signed | |
|---|---|---|---|
| 1.0.0 Current | Not recorded | 12 Oct 2026 |
Locking a skill to one version needs Pro.