Ruff and Pre-Commit Lint and Format Setup Prompt
Stand up a fast, opinionated Python lint and format pipeline using Ruff (linter + formatter) wired into pre-commit and CI — replacing the flake8/isort/black stack with one tool and a clean pyproject.toml config.
- Target user
- Python teams standardizing code style and catching bugs before review
- Difficulty
- Beginner
- Tools
- Claude, ChatGPT
The prompt
You are a senior Python tooling engineer who has migrated teams off the flake8 + isort + black + pyupgrade pile onto Ruff, cutting CI lint time from minutes to seconds. You configure it once, sensibly. I will provide: - My repo layout and Python version(s) - Any existing config (setup.cfg, .flake8, pyproject black/isort sections) - How strict the team wants to be and any rules we must not enforce Your job: 1. **Single config in pyproject.toml** — produce a `[tool.ruff]` section: `target-version`, `line-length`, `src`, and a curated `[tool.ruff.lint]` `select` (start with `E,F,I,UP,B,SIM,C4` and explain each family) plus a small justified `ignore`. Configure `[tool.ruff.format]` to replace black. 2. **Migrate, don't dump** — map my existing flake8/isort/black settings into Ruff equivalents, flag rules that have no equivalent, and note which legacy config files to delete. 3. **Per-file ignores** — set sensible `[tool.ruff.lint.per-file-ignores]` for `tests/` (allow asserts, longer lines) and `__init__.py` (re-export `F401`). 4. **pre-commit** — give a `.pre-commit-config.yaml` using `ruff-pre-commit` with two hooks: `ruff` (with `--fix`) and `ruff-format`. Pin the rev and explain `pre-commit autoupdate`. 5. **CI** — a minimal CI step running `ruff check --output-format=github .` and `ruff format --check .` so violations annotate PRs and fail the build without auto-fixing in CI. 6. **Rollout without a 5000-line diff** — recommend formatting in one isolated commit, adding it to `.git-blame-ignore-revs`, and optionally `--add-noqa` to baseline existing lint debt so the team isn't blocked. 7. **Editor** — note the VS Code / Neovim Ruff integration for format-on-save so style is fixed before commit. Output: (a) the full `[tool.ruff]` pyproject block, (b) `.pre-commit-config.yaml`, (c) the CI snippet, (d) a list of files to delete, (e) the rollout commit plan including `.git-blame-ignore-revs`. Bias toward: one tool, a curated rule set with each family justified, and a rollout that doesn't bury the team in churn.
Run this prompt with AI
Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.
Related prompts
-
Ruff and Black Pre-commit Pipeline Setup Prompt
Stand up a pre-commit configuration that runs Ruff (lint + import sort) and Black formatting on staged Python files locally and in CI, with a non-conflicting tool ordering
-
ShellCheck-Driven Bash Hardening Pass Prompt
Run a legacy Bash script through a ShellCheck-informed hardening review that resolves every warning by category, applies strict-mode and quoting fixes, and produces a safe, production-ready rewrite.
-
Bash Word-Splitting and Quoting Hardening Prompt
Audit and rewrite a Bash script to eliminate unquoted-expansion bugs, unsafe word splitting, and glob injection while preserving intended behavior
-
Bash Exit-Code and Pipefail Propagation Audit Prompt
Audit a Bash script for swallowed failures, missing pipefail, and broken exit-code propagation through pipes, subshells, and command substitution
More Bash & Python Automation prompts & error guides
Browse every Bash & Python Automation prompt and troubleshooting guide in one place.
Reading prompts? Get all 500 in one free PDF
500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.
- 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
- Instant PDF download — yours free, forever
- Plus one practical AI-workflow email a week (no spam)
Single opt-in · unsubscribe anytime · no spam.