ruff
Use this skill when linting, formatting, or fixing Python code with ruff. Activates on mentions of ruff, ruff check, ruff format, ruff fix, ruff server, ruff analyze, Python linting, Python formatting, flake8, isort, black replacement, noqa, pycodestyle, pyflakes, lint rules, ruff config, ruff.toml, autofix, per-file-ignores, language server for Python, or Python code quality.
What this skill does
# ruff: Python Linter & Formatter
ruff (v0.15.12, Apr 2026) is three tools in one Rust binary: linter (`ruff check`), formatter (`ruff format`), and dependency analyzer (`ruff analyze graph`). It replaces Flake8, Black, isort, pyupgrade, and dozens more.
**The built-in language server** (`ruff server`) replaces the deprecated `ruff-lsp` package (archived Dec 2025).
## Invocation
```bash
uv run ruff ... # Project dependency (pinned version)
uvx ruff ... # One-off (latest)
ruff ... # Global install
```
## Rule Selection: The Critical Decision
**Default rules are minimal:** only `["E4", "E7", "E9", "F"]`, catches syntax errors and undefined names but misses most quality rules. You almost certainly need to extend this.
### select vs extend-select
| Command | Behavior |
| -------------------------- | ---------------------------------------------------- |
| `select = ["E", "F", "B"]` | **Replaces** entire default set. Only these run. |
| `extend-select = ["B"]` | **Adds** to whatever `select` provides (or defaults) |
**Config inheritance trap:** When a child config specifies `select`, the parent's `ignore` list is **discarded**. This surprises people with monorepo setups.
**Specificity wins:** More specific prefixes override less specific ones. `select = ["E"]` + `ignore = ["E501"]` enables all E rules except E501.
### Recommended Selection Strategy
**New project, start broad:**
```toml
[tool.ruff.lint]
select = [
"E", "W", # pycodestyle
"F", # Pyflakes
"I", # isort
"N", # pep8-naming
"UP", # pyupgrade
"B", # flake8-bugbear
"SIM", # flake8-simplify
"TC", # flake8-type-checking
"RUF", # Ruff-specific
]
ignore = ["E501"] # Let formatter handle line length
```
**Library / open source, maximum strictness:**
```toml
[tool.ruff.lint]
select = ["ALL"]
ignore = [
# Formatter conflicts (MUST disable)
"W191", "E111", "E114", "E117",
"D206", "D300",
"Q000", "Q001", "Q002", "Q003", "Q004",
"COM812", "COM819",
# Pydocstyle conflicts
"D203", "D213",
# Overly strict
"D100", "D104",
"ANN101", "ANN102",
"FBT", "ERA001",
"E501",
]
[tool.ruff.lint.per-file-ignores]
"tests/**" = ["S101", "D", "ANN", "ARG"]
"scripts/**" = ["T20", "INP001"]
"**/__init__.py" = ["F401", "D104"]
```
**Legacy migration, incremental:**
```toml
[tool.ruff.lint]
select = ["E4", "E7", "E9", "F"]
extend-select = [
"I", # Step 1: import sorting (safe, auto-fixable)
"UP", # Step 2: pyupgrade (mostly auto-fixable)
# "B", # Step 3: uncomment when ready
]
```
### The ALL Selector
`select = ["ALL"]` enables every stable rule. Ruff auto-disables conflicting pairs (D203/D211, D212/D213), but being explicit is better practice. Preview rules require `preview = true` and are **not** included even with ALL.
## Formatter Behavior
### Configuration
```toml
[tool.ruff.format]
quote-style = "double" # "double" | "single" | "preserve"
indent-style = "space" # "space" | "tab"
skip-magic-trailing-comma = false
docstring-code-format = true # Format code in docstrings
preview = false # Enable 2026 style guide
```
### Rules That CONFLICT With the Formatter
When using `ruff format`, these lint rules should be avoided:
```toml
ignore = [
"W191", "E111", "E114", "E117", # Indentation
"D206", "D300", # Docstring formatting
"Q000", "Q001", "Q002", "Q003", "Q004", # Quotes
"COM812", "COM819", # Commas
]
```
Also avoid `ISC002` in Ruff's documented formatter-conflict case: `ISC002` selected, `ISC001` not selected, and `flake8-implicit-str-concat.allow-multiline = false`.
### Known Deviations from Black
Ruff targets >99.9% parity with Black but has 23 intentional divergences. The most impactful:
| Deviation | Ruff | Black |
| ------------------------------------- | ---------------------------------------------- | --------------------------------- |
| F-string interiors | Formats `{expr}` contents (stable since 0.9.0) | Does not touch f-string interiors |
| Pragma comments (`# noqa`, `# type:`) | Excluded from line width | Counted in line width |
| Implicit string concat | Merges when fits on one line | Splits more aggressively |
| Blank lines at block start | Removes them | Preserves them (Black 24+) |
| Trailing comments | Expands statement to keep comment close | Collapses, moves comment to end |
| Single-element tuples | Always parenthesizes | Removes parens when safe |
### E501 and the Formatter
The formatter makes best-effort line wrapping, it **cannot** always succeed. Comments, long strings, and URLs may exceed `line-length`. Either ignore E501 or set `lint.pycodestyle.max-line-length` higher than `line-length`.
## Fix Safety Model
```bash
ruff check --fix . # Safe fixes only
ruff check --fix --unsafe-fixes . # Include unsafe (review first!)
ruff check --fix --diff . # Preview changes before applying
```
| Safety | Meaning | Example |
| ------ | ------------------------------ | ------------------------------------------------------ |
| Safe | Cannot change runtime behavior | Reordering imports |
| Unsafe | May change behavior | `list(x)[0]` -> `next(iter(x))` changes exception type |
Override per-rule:
```toml
[tool.ruff.lint]
extend-safe-fixes = ["RUF015"] # Promote to safe
extend-unsafe-fixes = ["F401"] # Demote to unsafe (require --unsafe-fixes)
```
## Suppression System
```python
# Line-level
import os # noqa: F401
# Block-level (new in 0.15.0)
# ruff: disable[E501]
LONG_VALUE = "..."
# ruff: enable[E501]
# File-level
# ruff: noqa: F401, E501
```
```bash
ruff check --select RUF100 --fix . # Clean up unused noqa comments
ruff check --add-noqa . # Auto-add noqa to all violations
```
## Preview Mode
Preview is a staging area for new rules and formatter changes.
```toml
[tool.ruff.lint]
preview = true # Expands defaults from 59 to 412 rules
explicit-preview-rules = true # Require individual opt-in even with preview on
```
Preview rules are NOT activated by prefix selection or `ALL`, they require preview mode enabled. Use `explicit-preview-rules = true` to control which preview rules activate individually.
## Dependency Graph Analysis
```bash
ruff analyze graph src/ # File dependency graph (JSON)
ruff analyze graph --direction=dependents src/ # Reverse graph
ruff analyze graph --detect-string-imports src/ # Include dynamic imports
```
Use cases: selective test running, dead code detection, circular import detection.
## Configuration
**File precedence:** `.ruff.toml` > `ruff.toml` > `pyproject.toml` (nearest wins, no merging across levels).
Falls back to `~/.config/ruff/ruff.toml` when no project config exists.
```toml
[tool.ruff]
target-version = "py312" # Inferred from requires-python if unset
line-length = 88
src = ["src", "tests"] # First-party import classification
required-version = "==0.15.12" # Pin version with a PEP 440 specifier
extend = "../pyproject.toml" # Inherit parent config
[tool.ruff.lint.isort]
known-first-party = ["myproject"]
combine-as-imports = true
[tool.ruff.lint.pydocstyle]
convention = "google" # "google" | "numpy" | "pep257"
[tool.ruff.lint.flake8-type-checking]
runtime-evaluated-base-classes = ["pydantic.BaseModel"]
runtime-evRelated in Code Review
gstack
IncludedFast headless browser for QA testing and site dogfooding. Navigate pages, interact with elements, verify state, diff before/after, take annotated screenshots, test responsive layouts, forms, uploads, dialogs, and capture bug evidence. Use when asked to open or test a site, verify a deployment, dogfood a user flow, or file a bug with screenshots. (gstack)
startup-due-diligence
IncludedLegal due diligence review for seed-stage and Series A startups (US, Delaware C-Corp focus). Supports both investor and founder perspectives. Capabilities include: (1) Interactive document review and issue spotting; (2) Document request list generation; (3) Cap table and SAFE/convertible note analysis; (4) Red flag identification with severity ratings; (5) Diligence report generation. TRIGGERS: due diligence, DD, startup investment, cap table review, Series A, seed round, investor diligence, legal review startup, SAFE analysis, convertible note, 409A, founder vesting.
interview-master
IncludedThis skill should be used when the user asks to "generate interview questions", "prepare for interview", "optimize resume", "conduct mock interview", "analyze git commits for resume", "generate resume from code", "review my resume", or mentions interview preparation, career assistance, or extracting project experience from git history. Provides comprehensive interview and career development guidance for both job seekers and interviewers.
fix-issue
IncludedFixes GitHub issues using parallel analysis agents for root cause investigation, code exploration, and regression detection. Reads issue context from gh CLI, searches codebase and memory for related patterns, generates a fix with tests, and links the resolution back to the issue via PR. Includes prevention analysis to avoid recurrence. Use when debugging errors, resolving regressions, fixing bugs, or triaging issues.
sf-apex
IncludedGenerates and reviews Salesforce Apex code with 150-point scoring. TRIGGER when: user writes, reviews, or fixes Apex classes, triggers, test classes, batch/queueable/schedulable jobs, or touches .cls/.trigger files. DO NOT TRIGGER when: LWC JavaScript (use sf-lwc), Flow XML (use sf-flow), SOQL-only queries (use sf-soql), or non-Salesforce code.
swift-development
IncludedComprehensive Swift development for building, testing, and deploying iOS/macOS applications. Use when Claude needs to: (1) Build Swift packages or Xcode projects from command line, (2) Run tests with XCTest or Swift Testing framework, (3) Manage iOS simulators with simctl, (4) Handle code signing, provisioning profiles, and app distribution, (5) Format or lint Swift code with SwiftFormat/SwiftLint, (6) Work with Swift Package Manager (SPM), (7) Implement Swift 6 concurrency patterns (async/await, actors, Sendable), (8) Create SwiftUI views with MVVM architecture, (9) Set up Core Data or SwiftData persistence, or any other Swift/iOS/macOS development tasks.