Python linter
Skill nainishshafi/developer-productivity-skills/.github/skills/python-linter
Use when the user asks to "lint python", "run the linter", "fix linting errors", "check python code style", "run ruff", "format python code", "fix imports", "check types", "run mypy", or wants to find and fix Python code quality issues using ruff and mypy.From its SKILL.md
npx -y skills add nainishshafi/developer-productivity-skills --skill python-linterAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
2 things to look at
- 1 stars1 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
- runs commandsInstructs the agent to run 8 commands, including `[ -d .venv ] || python -m venv .venv` and 7 more.
SKILL.md
2.4 KB, 580 tokens by cl100k_base, as published. Nobody here has run it
Python Linter
Run ruff (lint + format) and optionally mypy (type checking) on Python code. Auto-fixes what it can and reports what needs manual attention.
Prerequisites
- Python project with
.pyfiles
Workflow
Step 1 — Set Up .venv
Always use .venv — create it if it doesn't exist:
[ -d .venv ] || python -m venv .venv
PYTHON=$(if [ -f .venv/Scripts/python ]; then echo .venv/Scripts/python; else echo .venv/bin/python; fi)
Install ruff into the venv if not already present:
$PYTHON -m ruff --version 2>/dev/null || $PYTHON -m pip install ruff
Optionally install mypy for type checking:
$PYTHON -m mypy --version 2>/dev/null || $PYTHON -m pip install mypy
Check for an existing pyproject.toml or ruff.toml config. If neither exists, offer to create a sensible default (see references/python-linter-reference.md for the recommended config).
Step 2 — Run Ruff Lint (with auto-fix)
$PYTHON -m ruff check --fix .
--fixauto-corrects safe issues (unused imports, style violations, etc.)- Note any remaining violations that require manual fixes
- If the user wants to see all issues first without fixing:
$PYTHON -m ruff check .
Step 3 — Run Ruff Format
$PYTHON -m ruff format .
- Formats all
.pyfiles in place (replaces black + isort) - To preview changes without applying:
$PYTHON -m ruff format --diff .
Step 4 — Run Type Checking (optional)
Ask the user if they want type checking. If yes:
$PYTHON -m mypy .
Or for stricter checking:
$PYTHON -m mypy --strict .
See references/python-linter-reference.md for mypy configuration options.
Step 5 — Report Results
Summarise:
- How many lint issues were auto-fixed
- Any remaining issues that need manual attention (with file + line references)
- Formatting changes applied
- Type errors found (if mypy was run)
If issues remain, explain each one clearly and offer to fix them.
Additional Resources
references/python-linter-reference.md— Recommended ruff/mypy configs, rule sets, pyproject.toml templates, CI integration
What ships with it: 1 file
4.9 KB alongside SKILL.md