ワンクリックで
ruff
Fix all Python lint violations and enforce consistent formatting in one command.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Fix all Python lint violations and enforce consistent formatting in one command.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
| name | ruff |
| description | Fix all Python lint violations and enforce consistent formatting in one command. |
| license | MIT |
| compatibility | claude cursor opencode |
| metadata | {"version":"1.0.0","languages":"python","audience":"developers","workflow":"automation","since":"2026-02-25"} |
I run ruff to auto-fix all fixable lint violations and enforce consistent code formatting in one step:
[tool.ruff] section to pyproject.toml if ruff isn't yet configured/ruff
/ruff check
/ruff format
/ruff init
"fix linting"
"fix all lint issues"
Run ruff check --fix to auto-fix all fixable lint violations in the current directory:
ruff check --fix .
ruff fixes violations it can safely transform automatically — including:
F401)I001) — replaces isortUnion[X, Y] → X | Y for Python 3.10+)Interpreting output:
Fixed 1 error. or Found 3 errors (3 fixed, 0 remaining).Example output:
Found 5 errors (5 fixed, 0 remaining).
Run ruff format to apply consistent code style across all Python files:
ruff format .
ruff's formatter is Black-compatible — it produces the same output as Black for the vast majority of code. It handles:
Formatting is separate from linting: ruff check --fix fixes lint rules; ruff format fixes style. Run both for a complete cleanup:
ruff check --fix . && ruff format .
This is the recommended default invocation — lint first, then format. The order matters because formatting after linting ensures the final output is consistently styled even when lint fixes change code structure.
After running ruff check --fix ., any remaining output represents violations that require manual attention:
ruff check . # dry run: show all current violations without fixing
Example output:
src/main.py:42:5: E501 Line too long (96 > 88 characters)
src/utils.py:18:1: F841 Local variable `result` is assigned to but never used
tests/test_api.py:7:1: S101 Use of `assert` detected
Reading the output: file:line:col: RULE-CODE message
Common unfixable rules:
| Rule | Name | Fix |
|---|---|---|
E501 | Line too long | Manually break the line or raise line-length in config |
F841 | Unused variable | Remove or use the variable |
F811 | Redefinition of unused name | Remove duplicate definition |
S101 | Assert detected | Replace with proper exception in production code |
B006 | Mutable default argument | Use None default + if arg is None: arg = [] pattern |
PLR0913 | Too many arguments | Refactor to use a dataclass or config object |
When unfixable violations are found, the skill shows the count, lists each with its rule code and location, and explains how to resolve the most common ones.
If ruff is not yet configured in the project, add a [tool.ruff] section to pyproject.toml:
[tool.ruff]
line-length = 88
target-version = "py311" # match your Python version
[tool.ruff.lint]
select = ["E", "F", "I", "B", "S"] # pycodestyle + pyflakes + isort + bugbear + bandit
ignore = ["S101"] # ignore assert in tests
[tool.ruff.lint.per-file-ignores]
"tests/**/*.py" = ["S101", "PLR2004"] # allow assert and magic values in tests
Alternatively, use a standalone ruff.toml at the project root (same format, without [tool.ruff] prefix):
line-length = 88
target-version = "py311"
[lint]
select = ["E", "F", "I"]
Rule set guidance:
| Code | Ruleset | Replaces |
|---|---|---|
E, W | pycodestyle | flake8 E/W |
F | pyflakes | flake8 F |
I | isort | isort |
B | flake8-bugbear | flake8-bugbear |
S | flake8-bandit | bandit |
UP | pyupgrade | pyupgrade |
RUF | ruff-specific | — |
Start with ["E", "F", "I"] as a minimal set and add more as your project adopts stricter standards.
Run ruff check --fix . && ruff format . as your standard cleanup — this covers both lint and format in one pass. Alias it or add it to a Makefile target.
Dry run before fixing: ruff check . (no --fix) shows all violations without modifying files — useful to understand the scope before applying changes.
ruff replaces multiple tools — ruff covers flake8, isort, pyupgrade, and parts of pylint. If you're migrating, you can remove those tools from pyproject.toml dev dependencies once ruff is configured.
Add ruff to pre-commit: ruff runs in milliseconds on large codebases, making it ideal for pre-commit hooks. The official hooks are available at github.com/astral-sh/ruff-pre-commit.
CI auto-patch: In CI, run ruff check --fix . && ruff format . && git diff --exit-code to fail the build if unfixed violations or unformatted files are committed.
Check ruff is installed: ruff --version. Install with pip install ruff, uv add --dev ruff, or brew install ruff.
E501 (line too long) is often not worth fixing manually — consider raising line-length in [tool.ruff] to 100 or 120 if your codebase has many long lines and reformatting isn't feasible.
ALWAYS use this skill whenever you would otherwise ask the user a question in free-form chat -- for clarifications, confirmations (especially destructive actions), missing parameters, multiple-choice decisions, or structured form input. Elicitations are routed through the Unique AI Platform UI via `unique-cli elicit create` + `elicit wait` (or `elicit ask` outside an agent harness) so the user gets a proper structured prompt and you get a structured answer back. Do NOT ask the user in plain chat when you can use this skill instead.
Read Agentic Table (magic table / due-diligence) sheets through the unique-cli agentic-table command. Use when the user or task involves inspecting an Agentic Table: a sheet's state and metadata, a specific cell's value or lock state, a cell's edit/answer history, or the sheet's generated export artifacts (reports, question exports). These are read-only (Tier 0) commands — they never modify the sheet and never require confirmation. Access to each sheet is enforced by the platform; a denial is reported as `agentic-table: permission denied`.
Call MCP (Model Context Protocol) server tools on the Unique AI Platform using the unique-cli mcp command. Use when the user asks to invoke, call, or execute an MCP tool, or when they need to send a JSON payload to an MCP server through the CLI. The JSON payload is forwarded 1:1 to the platform's MCP call-tool API.
Invoke connected Unique spaces/subagents through the unique-cli subagent command. Use when the workspace exposes connected-space tools and you need to delegate a question or task to one of those configured assistants.
Search the Unique AI Platform knowledge base using the unique-cli search command, with automatic per-turn citation tracking so cited facts render as clickable reference chips and `<sup>N</sup>` footnotes on the Unique platform. Use whenever the user asks to find, search, or query documents or content on Unique, including filtering by folder or metadata. Also covers `unique-cli read <cont_id>` for reading the full indexed text of a document when its content ID is already known. NOTE: This search uses combined vector + full-text indexing. Excel (.xlsx/.xls), CSV (.csv), and image files are NOT full-text indexed, so they will not appear in search results. To locate these file types, use the unique-cli-file-management skill instead (browse folders with `unique-cli ls` to find them by name).
Search the documents uploaded for the CURRENT task/row (e.g. an Agentic Table row's attached files) via the `unique-cli uploaded-search "<query>"` command, with the same per-turn citation tracking as `unique-cli search` so cited facts render as `<sup>N</sup>` footnotes and clickable reference chips on the Unique platform. ALWAYS use this skill when the user refers to documents they uploaded/attached to this task, or when you need facts from the task's own attached files. These uploaded files are scoped to the chat, NOT to a knowledge-base folder, so they will NEVER appear in `unique-cli search` results no matter the folder or metadata filters. Use `unique-cli search` for the knowledge base and this command for the task's uploaded documents; the two are complementary and citation numbering is shared across them within a turn.