/migration-patterns-plugin:black-to-ruff-format [--check-only] [--fix]from migration-patterns-plugin
Migrates Python formatting from black to ruff-format, replacing pre-commit hooks and pyproject.toml config. Use when psf/black is in .pre-commit-config.yaml or [tool.black] exists in pyproject.toml.
Ships in migration-patterns-plugin. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
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.
| 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 |
find . -maxdepth 1 -name '.pre-commit-config.yaml'find . -maxdepth 1 -name 'pyproject.toml'find . -maxdepth 1 -name 'ruff.toml'| Parameter | Description |
|---|---|
--check-only | Report what would change without modifying files |
--fix | Apply migration automatically |
Execute this black-to-ruff-format migration:
.pre-commit-config.yaml and locate psf/black entries.pyproject.toml and extract the [tool.black] section.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.Remove the psf/black repo block. If ruff-pre-commit is already present, add the ruff-format hook ID. Otherwise add the full ruff-pre-commit repo block with both ruff and ruff-format hooks:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.9.1 # use latest stable ruff version
hooks:
- id: ruff
args: [--fix]
- id: ruff-format
If ruff-pre-commit already exists but only has the ruff linter hook, add the ruff-format hook ID under the same repo block.
Convert black configuration to ruff format config:
| black key | ruff equivalent | Notes |
|---|---|---|
line-length | [tool.ruff] line-length | Shared with linter |
target-version | [tool.ruff] target-version | Shared with linter |
skip-string-normalization | [tool.ruff.format] quote-style = "preserve" | |
skip-magic-trailing-comma | [tool.ruff.format] skip-magic-trailing-comma = true | |
preview | [tool.ruff.format] preview = true |
Remove the [tool.black] section. Merge settings into [tool.ruff] and [tool.ruff.format] sections (create if absent, merge if existing).
Remove black from dev/lint dependencies:
# With uv
uvx --from uv uv remove --dev black 2>/dev/null || true
If not using uv, note it for manual removal.
Run the new hook to confirm it works:
pre-commit run ruff-format --all-files
If it exits 0, the migration is complete. If it produces diffs, this is expected on first run (ruff format may reformat some files differently from black). Commit the reformatted files as part of the migration.
Print a summary of changes:
black → ruff-format migration complete
=======================================
.pre-commit-config.yaml UPDATED (removed psf/black, added ruff-format hook)
pyproject.toml UPDATED ([tool.black] → [tool.ruff.format])
Note: ruff-format is Black-compatible (same defaults), but may reformat a small
number of files. Review the diff and include these reformatted files in the
migration commit.
Files to stage:
git add .pre-commit-config.yaml pyproject.toml
git add <any reformatted .py files>
| Context | Command |
|---|---|
| Audit only | /migration-patterns:black-to-ruff-format --check-only |
| Apply migration | /migration-patterns:black-to-ruff-format --fix |
| Verify after migration | pre-commit run ruff-format --all-files |
| Check format directly | uvx ruff format --check . |
| Item | Value |
|---|---|
| ruff format docs | https://docs.astral.sh/ruff/formatter/ |
| Black compatibility | ruff format is designed as a Black drop-in with ~99.9% compatible output |
| Config section | [tool.ruff.format] in pyproject.toml |
| Pre-commit hook | ruff-format in astral-sh/ruff-pre-commit |
/migration-patterns:flake8-to-ruff — Migrate flake8/isort linting to ruff/migration-patterns:mypy-to-ty — Migrate mypy to ty/configure:repo — End-to-end repo config driverWhat SKILL.md sets; muted values are Claude Code's defaults
sonnet7 skills in this plugin
/dual-writeDual-write pattern for safe data store transitions. Use when planning DB migrations, switching storage backends, or reviewing code writing to multiple systems simultaneously./eslint-to-biomeMigrate JS/TS linting from ESLint+Prettier to Biome. Use when .eslintrc* or eslint.config.* exists and no biome.json is present./flake8-to-ruffMigrate Python linting from flake8/isort to ruff. Use when pycqa/flake8 or PyCQA/isort is in .pre-commit-config.yaml or [tool.flake8]/[tool.isort] config exists./mypy-to-tyMigrate Python type checking from mypy to ty (Astral). Use when mirrors-mypy is in .pre-commit-config.yaml or [tool.mypy] config exists./shadow-modeShadow mode / dark-launch for validating new systems under production load. Use when testing replacement services, comparing behavior, or planning traffic mirroring for migrations./tool-migration-cutoverMigrating tools (Dependabot to Renovate, PAT to GitHub App, linter swaps). Use when removing the incumbent, to verify the new one runs, or on whole-file reformat churn from a leftover tool.npx claudepluginhub laurigates/claude-plugins --plugin migration-patterns-pluginOther plugins' skills for the same job