
Ruff
Run the project’s pinned Ruff linter and formatter on Python you are changing without reformatting entire untouched files.
Overview
Ruff is an agent skill for the Ship phase that runs Astral Ruff linting and formatting on Python with scoped auto-fixes aligned to existing project config.
Install
npx skills add https://github.com/astral-sh/claude-code-plugins --skill ruffWhat is this skill?
- Replaces Flake8, isort, Black, pyupgrade, autoflake, and many other tools in one CLI
- Invocation patterns: `uv run ruff`, `uvx ruff`, or global `ruff` depending on project deps
- Lint with `ruff check`, auto-fix with `--fix` / `--unsafe-fixes`, format with `ruff format`
- Respects `[tool.ruff]`, `ruff.toml`, and `.ruff.toml` when present
- Explicit guardrails: skip whole-file format when `--diff` shows the repo is not on Ruff format; scope fixes to edited co
Adoption & trust: 549 installs on skills.sh; 266 GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
You need consistent Python lint and format in CI and locally but mixing Black, isort, and Flake8—or reformatting whole files—hides the change you actually made.
Who is it for?
Python repos that already use or are adopting Ruff in `pyproject.toml` or `ruff.toml`, especially with `uv` for locked tool versions.
Skip if: Non-Python codebases, teams that forbid Ruff, or cases where you only need a one-off format pass across the entire repo without user approval.
When should I use this skill?
Linting, formatting, or fixing Python code; when `[tool.ruff]`, `ruff.toml`, or `.ruff.toml` is present.
What do I get? / Deliverables
After the skill runs, your agent uses the right `ruff check` / `ruff format` invocations and applies fixes only on code you are editing, keeping diffs reviewable.
- Scoped `ruff check` / `ruff format` command plan
- Auto-fixes applied only to targeted Python files when appropriate
Recommended Skills
Journey fit
Linting and formatting are quality gates that belong on the Ship shelf next to review and pre-merge checks, even when invoked while editing during Build. Review is where auto-fixable violations and format diffs are scoped to the files you touched before merge or CI.
How it compares
Use as a procedural Ruff playbook instead of asking the agent to guess Flake8 versus Black flags ad hoc in chat.
Common Questions / FAQ
Who is ruff for?
Solo and indie builders maintaining Python services, scripts, and packages who want one fast linter-formatter and agent-safe scoping rules.
When should I use ruff?
During Ship review when fixing violations before merge, and while editing Python during Build when `[tool.ruff]` or ruff config files are present.
Is ruff safe to install?
Review the Security Audits panel on this Prism page and only grant shell access in repos you trust; the skill instructs running local CLI commands, not calling unknown remote services.
SKILL.md
READMESKILL.md - Ruff
# 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 in `pyproject.toml` - A `ruff.toml` or `.ruff.toml` configuration file However, avoid making unnecessary changes: - **Don't format unformatted code** - 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. - **Scope fixes to code being edited** - Use `ruff check --diff` to 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 version - `uvx ruff ...` - Use when ruff is not a project dependency, or for quick one-off checks - `ruff ...` - Use if ruff is installed globally ## Commands ### Linting ```bash 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 ```bash 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`: ```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 ```bash black . → ruff format . black --check . → ruff format --check . black --diff . → ruff format --diff . ``` ### Flake8 → ruff check ```bash flake8 . → ruff check . flake8 --select E,F . → ruff check --select E,F . flake8 --ignore E501 . → ruff check --ignore E501 . ``` ### isort → ruff check ```bash 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. ```bash 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. ```bash 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: - https://docs.astral.sh/ruff/