Skip to content
Back to skills

Ruff Knowledge Patch

ASecurity

Ruff

  • 25 stars
  • 0 votes
  • 0 copies
  • 4 views
  • Added September 5, 2026
developmentpythonrustgoshellexpressgitsecurity

Works with

  • cli

Security analysis

A100/100

Pro scans all 8 files and shows the line behind each finding

Scanned December 1, 2026

npx -y skills add Nevaberry/nevaberry-plugins --skill ruff-knowledge-patch --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Ruff Knowledge Patch?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Ruff Knowledge Patch
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/nevaberry-ruff-knowledge-patch-nevaberry-plugins/badge)](https://www.skillsdirectory.com/skills/nevaberry-ruff-knowledge-patch-nevaberry-plugins)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: ruff-knowledge-patch
description: Ruff
version: "0.17.6"
license: MIT
metadata:
  author: Nevaberry
---


# Ruff Knowledge Patch

Load this skill when configuring Ruff, migrating rule selections or suppressions,
interpreting diagnostics and fix safety, formatting Python or Markdown, or
integrating Ruff with editors, CI, dependency analysis, and package distribution.
The references retain version-specific conditions and distinguish preview from
stable behavior.

## Reference index

| Reference | Topics |
| --- | --- |
| [Configuration, CLI, and Server](references/configuration-cli-and-server.md) | Python targets, configuration migration, suppressions, commands, reports, editor integration |
| [Rule Lifecycle and Selection](references/rule-lifecycle-and-selection.md) | Default selections, deprecated and removed rules, recodes, names, categories, stable and preview rules |
| [Fixes and Safety](references/fixes-and-safety.md) | Future annotations, PEP 695, pathlib, logging, pytest, unsafe and manual fixes |
| [Formatting and Syntax](references/formatting-and-syntax.md) | Formatter style, Markdown, pragmas, syntax diagnostics, Python language support |
| [Rule Behavior](references/rule-behavior.md) | Imports, typing, pytest, docstrings, classes, security, async code, Airflow, expressions |
| [Analysis, Discovery, and Distribution](references/analysis-discovery-and-distribution.md) | Dependency graphs, discovery, extensions, shebangs, installers, packages, source builds |

## Breaking changes and deprecations

### Rule selection and code migrations

Set `lint.select` explicitly to preserve a project's previous rule set when
upgrading across the expanded default selection. Ruff now enables `F406` by
default and omits `DTZ001`, `DTZ005`, `DTZ006`, `DTZ007`, `DTZ011`, `DTZ012`, and
`DTZ901`; add these datetime rules to `lint.extend-select` to keep running them
alongside the new defaults.

Deprecated rules require exact-code selection; group and prefix selections skip
them. Remove retired `S320`, `PD901`, and `UP038` from selectors and suppressions.

| Previous selector or check | Migration |
| --- | --- |
| `RUF035` | Use `S704` for `unsafe-markup-use`. |
| `RUF025` in preview | Use `RUF037`. |
| `UP007` for `typing.Optional` | Use `UP045`; `UP007` covers `typing.Union`. |
| `N804` for the first argument of `__new__` | Enable `PLW0211` to retain the check. |
| `TRY302` for `useless-try-except` | Use `TRY203`. |
| `PLC2201` for a constant on the left of a comparison | Use `SIM300`. |
| `UP011` for the cache-decorator rewrite | Use `UP033`; keep `UP011` for empty decorator parentheses. |

A CLI `select` can reset project ignores: `ruff check --select F .` enables
`F401` even if project configuration sets `ignore = ["F401"]`.
Airflow recodes and subsequent splits are detailed in the lifecycle reference.

### Configuration, editor, and package migrations

Remove `update-check`, even if it is `false`. The `builtins-`-prefixed settings
are deprecated; use unprefixed settings such as `allowed-modules`.
The unused-import allowlist moved from `lint.allow-unused-imports` to
`allowed-unused-imports` under `[tool.ruff.lint.pyflakes]`.
On macOS, move user configuration from
`~/Library/Application Support/ruff/ruff.toml` to the XDG location, typically
`~/.config/ruff/ruff.toml`.

Ruff no longer supports `ruff-lsp`. The VS Code extension always uses the native
server and ignores `ruff.nativeServer`. For conda-forge, switch callers using
`python -m ruff` or `import ruff` to the `ruff` executable on `PATH`.
Building Ruff 0.17.6 from source requires Rust 1.98 or later; the project's Rust
toolchain is 1.100.

### Report consumers and exit status

Use `output-format`, `RUFF_OUTPUT_FORMAT`, and `--output-format` for report
selection in place of `format`, `RUFF_FORMAT`, and the old `--format` flag.
`ruff rule` and `ruff linter` also use `--output-format`.

- JSON consumers must accept `null` for `filename`, `location`, `end_location`,
  `fix.edits[].location`, and `fix.edits[].end_location`. Read each fix's edits
  from `fix.edits`; the message remains at `fix.message`.
- JUnit consumers should read `skipped` instead of `disabled` on `<testsuite>`;
  `<testsuites>` also provides `skipped`.
- GitLab reports expose the rule code in `check_name`; later report changes add
  column numbers and the rule code to `description`.
- `ruff format --exit-non-zero-on-format .` writes changes and exits 1 if it
  reformats any file.
- `ruff check --fix-only .` exits zero on success even after applying fixes;
  use `ruff check --fix-only --exit-non-zero-on-fix .` for nonzero status on changes.

### Fix display and automatic application

`ruff check` and `ruff format --check` show proposed diffs in their default
diagnostic output. The default `full` output also shows unsafe and display-only
edits regardless of `unsafe-fixes`; automatically applying unsafe fixes still
requires opting in.
The language server offers display-only fixes and marks safe fixes as preferred.

`UP040` type-alias fixes always require opting into unsafe fixes for automatic
application. Preview `G004` logging f-string fixes also require that opt-in from
0.17.5. `ISC003` and `F541` fixes are unsafe when they would create a docstring.
The fixes reference preserves the individual rules' conditions for comment
deletion, return-type changes, and withheld fixes.

## Python targets and typing

Without an explicit or inferred target, Ruff uses Python 3.11 for lint rules and
Python 3.15 for syntax diagnostics. Set `target-version` explicitly to check
compatibility with an older Python release.
Ruff resolves the full `extend` chain before falling back to the default target.

When `ruff.toml` omits `target-version`, Ruff reads `[project].requires-python`
from a sibling `pyproject.toml`, even one containing only project metadata.
Without project configuration, it looks for the nearest parent `pyproject.toml`;
that file's `requires-python` takes precedence over user-level settings.

Use `per-file-target-version` for files needing a different Python target:

```toml
[tool.ruff]
target-version = "py39"

[tool.ruff.per-file-target-version]
"scripts/*.py" = "py312"
```

Enable `lint.future-annotations` to let stable autofixes insert
`from __future__ import annotations`. This lets `TC001`–`TC003` move more imports
into `TYPE_CHECKING`, `RUF013` use `|` in annotations before Python 3.10, and
`UP037` unquote more annotations.

```toml
[tool.ruff.lint]
future-annotations = true
```

Set `lint.typing-extensions` to `false` to prevent suggestions to import from
`typing_extensions`. Replace legacy `if 0:` and `if False:` type-checking guards
with `if TYPE_CHECKING:`.
For Python 3.15 or later, `TC001`, `TC002`, and `TC003` prefer `lazy import` for
type-only dependencies. `TID254` and `TID255` run without preview; `TID254` skips
stubs. Ruff also recognizes lazy imports declared through `__lazy_modules__`.

## Suppressions and rule names

Stable linting accepts `ruff: ignore[...]` on the diagnostic line or the preceding
line. Above a multiline function definition, it covers the entire header.
Use `ruff: file-ignore[...]` for the whole file and paired `ruff: disable` /
`ruff: enable` directives for blocks. Any Ruff suppression directive can include
a reason after its closing bracket.

```python
# ruff: file-ignore[F401] Imports are kept for interactive use
import pathlib
```

Generate stable comments with `ruff check --add-ignore example.py`.
`RUF102` checks unknown codes in inline and file-level suppressions; `RUF100`
limits its checks to known codes. `PGH004` flags blanket file-level suppressions
such as `# ruff: noqa`. Put `DOC` suppressions on the first docstring line, and
multiline `UP015` suppressions on the redundant mode argument's line.

Preview supports rule names in selectors and suppression comments, and rules
identified only by name. `ruff rule unused-import` looks up a rule by name.

```sh
ruff check --preview --select unused-import .
```

Preview `RUF105`, `RUF106`, and `RUF201` flag legacy `noqa` comments, codes in
`ruff: ignore` comments, and codes in configuration selectors, respectively.
Preview redirects renamed selectors and adds `renamed-rule` (`RUF202`);
preview `RUF101` checks redirected selectors in suppression comments beyond `noqa`.

## Formatting and editor integration

`ruff format README.md` formats Python code blocks in Markdown in stable mode.
Supported labels include `python`, `py`, `python3`, `py3`, `pyi`, and `pycon`;
`pyi` blocks use stub formatting and `pycon` blocks use REPL formatting.
Use `<!-- fmt: off -->` / `<!-- fmt: on -->` around Markdown regions, or
`# fmt: off` / `# fmt: on` inside a Python fence.
Add `"*.md"` to `extend-exclude` to exclude Markdown entirely.
Quarto files require an explicit extension mapping:

```toml
[tool.ruff]
extension = { qmd = "markdown" }
```

`ruff format --check` supports the linter's output formats, including CI formats:

```sh
ruff format --check --output-format github .
```

`format.nested-string-quote-style` controls nested string quotes; inspect installed
choices with `ruff config format.nested-string-quote-style`.
The formatter and `I001`, `E501`, and `W505` exclude trailing pragma comments
from line-length calculations, which can change import wrapping.

The editor's `ruff.configuration` accepts an inline object. Server `logLevel`
defaults to `info`; `ruff.printDebugInformation` returns a string containing
document-specific details and no longer writes that output to the server log.
The language server can use uv for formatting and skips `uv format` in untrusted
workspaces. It reports TOML diagnostics but excludes TOML from formatting
registration. LSP clients can request diagnostics for individual notebook cells.

## Dependency analysis and installation

`ruff analyze graph` supports stubs and notebooks, can use a supplied virtual
environment, resolves directories configured in `src`, and offers an option to
omit imports inside `TYPE_CHECKING` blocks for runtime dependency analysis.
The analysis reference also covers discovery exclusions and extension mappings.

The shell and PowerShell installers choose `$XDG_BIN_HOME`, then `$XDG_DATA_HOME/../bin`, then
`~/.local/bin`, using the first applicable directory. Update scripts and `PATH`
entries that assume the previous Cargo location. Release archives add a directory
level; pass `--strip-components=1` to `tar` when extracting the binary directly
into its destination.

Files in this skill

  • SKILL.md8.9 KB
  • coverage.json1.4 KB
  • references/analysis-discovery-and-distribution.md2.3 KB
  • references/configuration-cli-and-server.md3.7 KB
  • references/fixes-and-safety.md3.7 KB
  • references/formatting-and-syntax.md4.5 KB
  • references/rule-behavior.md6.6 KB
  • references/rule-lifecycle-and-selection.md9.2 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.