ruff
astral-sh/claude-code-plugins
Extremely fast Python linter and formatter replacing Flake8, Black, isort, and dozens of other tools.
What is ruff?
Ruff is a unified Python linter and code formatter that combines the functionality of Flake8, Black, isort, pyupgrade, and autoflake. Use it whenever you need to lint, format, or fix Python code, especially in projects configured with ruff.
- Lint Python code and auto-fix violations with `ruff check`
- Format Python code consistently with `ruff format`
- Replace multiple tools: Flake8, Black, isort, pyupgrade, autoflake
- Apply unsafe fixes with review capability for behavior-changing corrections
- Watch files for changes and re-lint automatically
- Select or ignore specific rule sets for customized linting
How to install ruff
npx skills add https://github.com/astral-sh/claude-code-plugins --skill ruff- Python project with ruff installed or available via uv
- Optional: `pyproject.toml` or `ruff.toml` configuration file
How to use ruff
- 1.Run `ruff check .` to lint all files in the current directory
- 2.Run `ruff check --fix .` to auto-fix fixable violations
- 3.Run `ruff format .` to format all files after linting
- 4.Use `ruff check --diff` to preview changes without applying them
- 5.For unsafe fixes, review with `ruff check --fix --unsafe-fixes --diff` first, then apply
Use cases
- Linting and formatting Python files in projects with `[tool.ruff]` configuration
- Auto-fixing common code violations like unused imports and style issues
- Migrating from Black/Flake8/isort to a unified ruff setup
- Applying lint fixes before formatting to handle structural changes
- Previewing formatting changes with `--diff` before applying them
- Python developers
- DevOps and platform engineers
- Teams standardizing on ruff for code quality
- Projects migrating from multiple linting/formatting tools
ruff FAQ
No. If `ruff format --diff` shows changes throughout an entire file, the project likely isn't using ruff for formatting. Skip formatting to avoid obscuring actual changes.
Use `uv run ruff ...` if ruff is in the project's dependencies, or `uvx ruff ...` for quick one-off checks outside the project.
Safe fixes only change style; unsafe fixes may change code behavior (e.g., removing unused imports that have side effects). Always review unsafe fixes with `--diff` before applying.
Yes. Replace `black .` with `ruff format .`, `flake8 .` with `ruff check .`, and `isort .` with `ruff check --select I --fix .`.
Run `ruff check --fix` before `ruff format` because lint fixes can change code structure (like reordering imports), which formatting then cleans up.
Full instructions (SKILL.md)
Source of truth, from astral-sh/claude-code-plugins.
name: ruff description: Guide for using ruff, the extremely fast Python linter and formatter. Use this when linting, formatting, or fixing Python code.
ruff
Ruff is an extremely fast Python linter and code formatter. It replaces Flake8, isort, Black, pyupgrade, autoflake, and dozens of other tools.
When to use ruff
Always use ruff for Python linting and formatting, especially if you see:
[tool.ruff]section inpyproject.toml- A
ruff.tomlor.ruff.tomlconfiguration file
However, avoid making unnecessary changes:
- Don't format unformatted code - If
ruff format --diffshows changes throughout an entire file, the project likely isn't using ruff for formatting. Skip formatting to avoid obscuring actual changes. - Scope fixes to code being edited - Use
ruff check --diffto see fixes relevant to the code you're changing. Only apply fixes to files you're modifying unless the user explicitly asks for broader fixes.
How to invoke ruff
uv run ruff ...- Use when ruff is in the project's dependencies to ensure you use the pinned versionuvx ruff ...- Use when ruff is not a project dependency, or for quick one-off checksruff ...- Use if ruff is installed globally
Commands
Linting
ruff check . # Check all files in current directory
ruff check path/to/file.py # Check specific file
ruff check --fix . # Auto-fix fixable violations
ruff check --fix --unsafe-fixes . # Include unsafe fixes (review changes!)
ruff check --watch . # Watch for changes and re-lint
ruff check --select E,F . # Only check specific rules
ruff check --ignore E501 . # Ignore specific rules
ruff rule E501 # Explain a specific rule
ruff linter # List available linters
Formatting
ruff format . # Format all files
ruff format path/to/file.py # Format specific file
ruff format --check . # Check if files are formatted (no changes)
ruff format --diff . # Show formatting diff without applying
Configuration
Ruff is configured in pyproject.toml or ruff.toml:
# pyproject.toml
[tool.ruff.lint]
select = ["E", "F", "I", "UP"] # Enable specific rule sets
ignore = ["E501"] # Ignore specific rules
[tool.ruff.lint.isort]
known-first-party = ["myproject"]
Migrating from other tools
Black → ruff format
black . → ruff format .
black --check . → ruff format --check .
black --diff . → ruff format --diff .
Flake8 → ruff check
flake8 . → ruff check .
flake8 --select E,F . → ruff check --select E,F .
flake8 --ignore E501 . → ruff check --ignore E501 .
isort → ruff check
isort . → ruff check --select I --fix .
isort --check . → ruff check --select I .
isort --diff . → ruff check --select I --diff .
Common patterns
Apply lint fixes before formatting
Run ruff check --fix before ruff format. Lint fixes can change code
structure (e.g., reordering imports), which formatting then cleans up.
ruff check --fix .
ruff format .
Applying and reviewing unsafe fixes
Ruff categorizes some auto-fixes as "unsafe" because they may change code behavior, not just style. For example, removing unused imports could break code that relies on side effects.
ruff check --fix --unsafe-fixes --diff . # Preview changes first
ruff check --fix --unsafe-fixes . # Apply changes
Always review changes before applying --unsafe-fixes:
- Use
ruff rule <CODE>to understand why the fix is considered unsafe - Verify the fix doesn't violate those assumptions in your code
Documentation
For detailed information, read the official documentation:
Related skills
More from astral-sh/claude-code-plugins and the wider catalog.

ty
Extremely fast Python type checker and language server replacing mypy and Pyright.

uv
Fast Python package and project manager replacing pip, pipx, pyenv, virtualenv, and poetry.

karpathy-llm-wiki
Build and maintain a personal LLM-powered knowledge base with immutable sources and compiled wiki articles.

astro
Build fast, content-driven websites with Astro's islands architecture and static site generation.

airflow
Query, manage, and troubleshoot Apache Airflow DAGs and runs via the `af` CLI.

airflow-hitl
Use when the user needs human-in-the-loop workflows in Airflow (approval/reject, form input, or human-driven branching). Covers ApprovalOperator, HITLOperator, HITLBranchOperator, HITLEntryOperator, HITLTrigger. Requires Airflow 3.1+. Does not cover AI/LLM calls (see airflow-ai).