Use Ruff to lint and format Python code with extreme speed and comprehensive rule coverage
Use Ruff to lint and format Python code. Ruff is an extremely fast Python linter and code formatter written in Rust, providing 10-100x faster performance than existing tools like Flake8 and Black.
This skill helps you integrate Ruff into Python projects for:
Choose your preferred installation method:
**With uvx (no installation):**
```bash
uvx ruff check
uvx ruff format
```
**With uv (recommended):**
```bash
uv tool install ruff@latest # Install globally
uv add --dev ruff # Or add to project
```
**With pip:**
```bash
pip install ruff
```
**With pipx:**
```bash
pipx install ruff
```
**Standalone installer (macOS/Linux):**
```bash
curl -LsSf https://astral.sh/ruff/install.sh | sh
```
**Standalone installer (Windows):**
```powershell
powershell -c "irm https://astral.sh/ruff/install.ps1 | iex"
```
Run Ruff as a linter to check for code quality issues:
```bash
ruff check
ruff check path/to/code/
ruff check path/to/code/*.py
ruff check --fix
ruff check --output-format=full
```
Run Ruff as a formatter to auto-format code:
```bash
ruff format
ruff format path/to/code/
ruff format path/to/code/*.py
ruff format --check
```
Create a `ruff.toml` or add to `pyproject.toml`:
```toml
line-length = 88
target-version = "py39"
[lint]
select = ["E4", "E7", "E9", "F"] # Enable rule sets
ignore = [] # Ignore specific rules
fixable = ["ALL"]
unfixable = []
[format]
quote-style = "double"
indent-style = "space"
```
Or in `pyproject.toml`:
```toml
[tool.ruff]
line-length = 88
target-version = "py39"
[tool.ruff.lint]
select = ["E4", "E7", "E9", "F"]
ignore = []
```
Pass configuration via CLI arguments:
```bash
ruff check --select F401 --select F403
ruff check --ignore E501
ruff check --config "lint.per-file-ignores = {'some_file.py' = ['F841']}"
```
Add to `.pre-commit-config.yaml`:
```yaml
rev: v0.14.14
hooks:
- id: ruff-check
args: [ --fix ]
- id: ruff-format
```
Add to `.github/workflows/ruff.yml`:
```yaml
name: Ruff
on: [ push, pull_request ]
jobs:
ruff:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: astral-sh/ruff-action@v3
```
**Replace multiple tools:**
**Enable preview mode for latest features:**
```bash
ruff check --preview
```
Or in config:
```toml
[tool.ruff]
preview = true
```
**Per-file rule ignoring:**
```toml
[tool.ruff.lint.per-file-ignores]
"__init__.py" = ["F401"] # Allow unused imports in __init__.py
"tests/*.py" = ["S101"] # Allow assert in tests
```
**Customize rule selection:**
```bash
ruff check --select E,F,W,C,N
ruff check --select ALL --ignore E501,F401
```
Leave a review
No reviews yet. Be the first to review this skill!
# Download SKILL.md from killerskills.ai/api/skills/ruff-python-linter-and-formatter/raw