Skip to content
Back to skills

Ruff Patterns

ASecurity

Knowledge about the ruff linter and patterns for solving errors. **ZERO noqa policy** — always look for the proper solution.

  • 4 stars
  • 0 votes
  • 0 copies
  • 3 views
  • Added May 26, 2026
developmentbashfastapigitapidatabaseci/cd

Works with

  • api

Security analysis

A100/100

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

Scanned May 27, 2026

npx -y skills add ruslan-korneev/claude-plugins --skill ruff-patterns --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Ruff Patterns?

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

Security grade badge for Ruff Patterns
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/ruslan-korneev-ruff-patterns/badge)](https://www.skillsdirectory.com/skills/ruslan-korneev-ruff-patterns)

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
# Ruff Patterns

Knowledge about the ruff linter and patterns for solving errors. **ZERO noqa policy** — always look for the proper solution.

## Triggers

Use this skill when the user:
- Asks "how to configure ruff"
- Gets a ruff error and wants to understand how to fix it
- Wants to migrate from black/isort/flake8/pylint
- Asks about a specific rule (E501, F401, etc.)

## Main Principle: NEVER USE NOQA

**Every ruff error has a proper solution.** Using `# noqa` is:
- Hiding the problem, not solving it
- Technical debt
- A potential source of bugs

Instead of noqa:
1. Fix the code properly
2. Configure per-file-ignores for specific cases (tests, migrations)
3. Disable the rule globally if it doesn't fit the project

More details: `${CLAUDE_PLUGIN_ROOT}/skills/ruff-patterns/references/why-no-noqa.md`

## Quick Start

### Installation
```bash
uv add ruff --dev
```

### Basic Usage
```bash
# Check
ruff check .

# Format
ruff format .

# Auto-fix safe errors
ruff check --fix .

# Auto-fix all errors (including potentially unsafe)
ruff check --fix --unsafe-fixes .
```

## Recommended Configuration

### For FastAPI Projects
```toml
[tool.ruff]
target-version = "py312"
line-length = 120
src = ["src"]

[tool.ruff.lint]
select = ["ALL"]
ignore = [
    "D",       # docstrings
    "ANN101",  # self annotation
    "ANN102",  # cls annotation
    "FBT003",  # boolean positional arg
    "PLR0913", # too many arguments
    "S101",    # assert (allowed in tests via per-file-ignores)
    "COM812",  # trailing comma conflict
    "ISC001",  # implicit string concat conflict
]

[tool.ruff.lint.per-file-ignores]
"tests/**/*.py" = ["S101", "PLR2004"]
"alembic/versions/*.py" = ["ALL"]
"__init__.py" = ["F401"]

[tool.ruff.format]
quote-style = "double"
```

Full example: `${CLAUDE_PLUGIN_ROOT}/skills/ruff-patterns/examples/fastapi-pyproject.toml`

## Solutions for Popular Errors

Detailed solution database: `${CLAUDE_PLUGIN_ROOT}/skills/ruff-patterns/references/rule-solutions.md`

### Quick Reference

| Code | Problem | Solution |
|------|---------|----------|
| E501 | Line too long | Use parentheses for line breaks |
| F401 | Unused import | Remove or add to `__all__` |
| F841 | Unused variable | Use `_` or remove |
| B008 | Function call in default | `None` + check |
| PLR0913 | Too many arguments | Dataclass/Pydantic model |
| S101 | Assert in code | Explicit check + raise |
| UP007 | Outdated Union | Use `X \| Y` |

## Migration from Other Linters

### From black + isort + flake8

Ruff completely replaces these tools:
- `ruff format` = black
- `ruff check --select I` = isort
- `ruff check` = flake8 + plugins

```bash
# Remove old dependencies
uv remove black isort flake8 flake8-bugbear flake8-comprehensions

# Add ruff
uv add ruff --dev

# Remove old configs
rm .flake8 .isort.cfg
# Remove [tool.black], [tool.isort] sections from pyproject.toml
```

### From pylint

Ruff covers most pylint rules through PL* groups:
- PLC: Convention
- PLE: Error
- PLR: Refactor
- PLW: Warning

## CI/CD Integration

### GitHub Actions
```yaml
- name: Lint with ruff
  run: |
    ruff check --output-format=github .
    ruff format --check .
```

### Pre-commit
```yaml
repos:
  - repo: https://github.com/astral-sh/ruff-pre-commit
    rev: v0.8.0
    hooks:
      - id: ruff
        args: [--fix]
      - id: ruff-format
```

## Plugin Commands

- `/lint:check [path]` — check code
- `/lint:explain <error>` — error explanation + solution
- `/lint:config [preset]` — configure ruff for the project

Files in this skill

  • SKILL.md3.4 KB
  • examples/fastapi-pyproject.toml5.1 KB
  • references/recommended-config.md5 KB
  • references/rule-solutions.md10.3 KB
  • references/why-no-noqa.md3.5 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.