Use this skill to enforce code quality with Ruff in a controlled, iterative workflow. It supports:
pyproject.toml.uv, direct ruff, python -m ruff, or equivalent).--select, --ignore, --extend-select, --extend-ignore).# noqa only when suppression is justified.Collect these inputs before running:
target_path (optional): folder or file to check. Empty means whole repository.ruff_runner (optional): explicit Ruff command prefix (for example uv run, ruff, python -m ruff, pipx run ruff).rules_select (optional): comma-separated rule codes to enforce.rules_ignore (optional): comma-separated rule codes to ignore.extend_select (optional): extra rules to add without replacing configured defaults.extend_ignore (optional): extra ignored rules without replacing configured defaults.allow_unsafe_fixes (default: true): whether to run Ruff unsafe fixes.ask_on_ambiguity (default: true): always ask the user when multiple valid choices exist.Build Ruff commands from inputs.
Determine a reusable ruff_cmd prefix before building commands.
Resolution order:
ruff_runner is provided, use it as-is.uv is available and Ruff is managed through uv, use uv run ruff.ruff is available on PATH, use ruff.python -m ruff.pipx run ruff), or stop and ask the user.Use the same resolved ruff_cmd for all check and format commands in the workflow.
Base command:
<ruff_cmd> check
Formatter command:
<ruff_cmd> format
With optional target:
<ruff_cmd> format <target_path>
Add optional target:
<ruff_cmd> check <target_path>
Add optional overrides as needed:
--select <codes>
--ignore <codes>
--extend-select <codes>
--extend-ignore <codes>
Examples:
# Full project with defaults from pyproject.toml
ruff check
# One folder with defaults
python -m ruff check src/models
# Override to skip docs and TODO-like rules for this run
uv run ruff check src --extend-ignore D,TD
# Check only selected rules in a folder
ruff check src/data --select F,E9,I
<ruff_cmd> check with the selected scope and options.--fix using the same scope/options.<ruff_cmd> format on the same scope.<ruff_cmd> check to refresh remaining findings.Run only if findings remain and allow_unsafe_fixes=true.
--fix --unsafe-fixes using the same scope/options.<ruff_cmd> format on the same scope.<ruff_cmd> check.For remaining findings:
<ruff_cmd> format on the same scope.<ruff_cmd> check.If there are multiple valid solutions at any step, always ask the user before proceeding. Do not choose silently between equivalent options.
# noqa)Use suppression only when all conditions are true:
Guidelines:
# noqa: <RULE> over broad # noqa.Repeat steps 2 to 6 until one of these outcomes:
<ruff_cmd> check returns clean.Each loop iteration must include <ruff_cmd> format before the next <ruff_cmd> check.
When no progress is detected:
Before declaring completion:
At the end of execution, report: