Skip to content
🎉 Launch sale:50% off everything over $22 — automatically applied at checkout· ends Aug 2Shop the sale →
DevOps AI ToolKit
Newsletter
All prompts
AI for Bash & Python Automation Difficulty: Beginner ClaudeChatGPT

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

More Bash & Python Automation prompts & error guides

Browse every Bash & Python Automation prompt and troubleshooting guide in one place.

Free download · 368-page PDF

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.