
ruff
Guide for using ruff, the extremely fast Python linter and formatter. Use this when linting, formatting, or fixing Python code.
- Installs
- 3.4K
- Last 24h
- +31
- Trending rank
- #4304
- Security
- Not audited
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/astral-sh/claude-code-plugins --skill ruff- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads ruff automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
SKILL.md
The instructions your agent reads when the skill is triggered.
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:
FAQ
What does the ruff skill do?
Guide for using ruff, the extremely fast Python linter and formatter. Use this when linting, formatting, or fixing Python code.
How do I install ruff?
Run npx skills add https://github.com/astral-sh/claude-code-plugins --skill ruff in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/ruff/ (personal) or .claude/skills/ruff/ (project).
Which AI agents can use ruff?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is ruff safe to install?
No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.
Who maintains ruff?
It is published by astral-sh in astral-sh/claude-code-plugins. It has 3,396 recorded installs.
More from astral-sh/claude-code-plugins
uv
astral-sh/claude-code-plugins
Guide for using uv, the Python package and project manager. Use this when working with Python projects, scripts, packages, or tools.
ty
astral-sh/claude-code-plugins
Guide for using ty, the extremely fast Python type checker and language server. Use this when type checking Python code or setting up type checking in Python projects.
Popular other skills
hyperframes-cli
heygen-com/hyperframes
The HyperFrames CLI by job - scaffold, check, look at frames, edit the timeline, preview, render locally or in the cloud, publish, project history - plus reading its JSON and recovering from build or render failures.
triage
mattpocock/skills
Move issues and external PRs through a state machine of triage roles, categorise, verify, grill if needed, and write agent-ready briefs.
ask-matt
mattpocock/skills
Ask which skill or flow fits your situation. A router over the skills in this repo.
to-questionnaire
mattpocock/skills
Turn a decision you can't fully answer into a questionnaire for someone else to fill in.
loop-me
mattpocock/skills
Grill me about specs for the workflows I want to build, within this workspace.