| name | black-to-ruff-format |
| description | Migrate Python formatting from black to ruff-format. Use when psf/black is in .pre-commit-config.yaml or [tool.black] exists in pyproject.toml. |
| allowed-tools | Read, Write, Edit, Glob, Grep, Bash(find *), Bash(test *), Bash(pre-commit *), Bash(uvx *), AskUserQuestion, TodoWrite |
| model | sonnet |
| args | [--check-only] [--fix] |
| argument-hint | [--check-only] [--fix] |
| created | "2026-04-14T00:00:00.000Z" |
| modified | "2026-05-09T00:00:00.000Z" |
| reviewed | "2026-04-14T00:00:00.000Z" |
/migration-patterns:black-to-ruff-format
Migrate from black to ruff format — Ruff's drop-in Black-compatible formatter written in Rust (~35x faster). Replaces the psf/black pre-commit hook, migrates [tool.black] configuration, and removes black from dev dependencies.
When to Use This Skill
| Use this skill when... | Keep black when... |
|---|
.pre-commit-config.yaml contains psf/black | Team has strong preference for black's exact output |
[tool.black] exists in pyproject.toml | CI uses black --check specifically by name |
| Repo already uses ruff for linting | Project uses black's API in build scripts |
| Wanting to consolidate formatting under ruff | |
Context
- Pre-commit config: !
find . -maxdepth 1 -name '.pre-commit-config.yaml'
- pyproject.toml: !
find . -maxdepth 1 -name 'pyproject.toml'
- ruff already present: !
find . -maxdepth 1 -name 'ruff.toml'
Parameters
| Parameter | Description |
|---|
--check-only | Report what would change without modifying files |
--fix | Apply migration automatically |
Execution
Execute this black-to-ruff-format migration:
Step 1: Audit current black configuration
- Read
.pre-commit-config.yaml and locate psf/black entries.
- Read
pyproject.toml and extract the [tool.black] section.
- Report findings:
black → ruff-format migration audit
=====================================
pre-commit hook: psf/black found at rev <rev>
pyproject.toml: [tool.black] section found (line-length=<N>, target-version=<X>)
ruff already: EXISTS / NOT PRESENT
If --check-only, stop here.
Step 2: Update .pre-commit-config.yaml
Remove the repo block. If is already present, add the hook ID. Otherwise add the full ruff-pre-commit repo block with both and hooks: