agentleFS
Baba01hacker666Baba01hacker666/dummyskills/skills/python/py-lint-and-typecheck/SKILL.md

py-lint-and-typecheck

Skill0 starsChanged 2 months agoMITView on GitHub

Guides agents through resolving Python linter (Ruff, Flake8) and static type checker (Mypy, Pyright) errors without suppression comments.

The file

We split this skill into the rules it gives an agent

10 rules. About 0 are common, 4 are distinctive, and 6 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 6

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use this skill when:

    line 14
  2. Very specific:

    Do not use for JavaScript/TypeScript.

    line 20
  3. Very specific:

    Do not use for running tests.

    line 21
  4. Very specific:

    If no file is specified: run ruff check .

    line 27
  5. Very specific:

    Absolute Ban: Never add # noqa or # type: ignore comments.

    line 28
  6. Distinctive:

    Follow these numbered actions:

    line 31
  7. Very specific:

    Add proper Optional[T], Union, or return type hints.

    line 35
  8. Very specific:

    If a function returns None on failure: type return as Optional[ReturnType] or ReturnType | None.

    line 45
  9. Distinctive:

    If an import is unused (F401): delete the import line.

    line 46
  10. Distinctive:

    Stop and ask the user when:

    line 77

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Python Lint and Type-Check (Ruff & Mypy)

Executes and resolves Python static analysis diagnostics using ruff and mypy. Enforces type annotations and forbids # noqa or # type: ignore.

1. Purpose

Catch bugs, unused code, and type incompatibilities statically in Python. "Type Annotations" declare function signatures using typing (or native Python 3.10+ types int | None).

2. When to Use

Use this skill when:

  • Checking Python code before committing.
  • Resolving Mypy errors (arg-type, return-value, assignment).
  • Formatting code per PEP 8 using ruff format.

3. When Not to Use

  • Do not use for JavaScript/TypeScript; use ts-lint-and-typecheck.
  • Do not use for running tests; use py-testing.

4. Required Inputs

  • target_file: Path to Python file or directory.

5. Missing-Input Behavior

  1. If no file is specified: run ruff check . and mypy . to locate issues across the repository.
  2. Absolute Ban: Never add # noqa or # type: ignore comments.

6. Procedure

Follow these numbered actions:

  1. Action 1: Run Mypy Type Checker
    • Execute: mypy --show-error-codes <target_file>
  2. Action 2: Fix Type Mismatches at Root Cause
    • Add proper Optional[T], Union, or return type hints.
  3. Action 3: Run Ruff Linter
    • Execute: ruff check <target_file>
    • Auto-fix safe issues: ruff check <target_file> --fix
  4. Action 4: Format Code
    • Execute: ruff format <target_file>
  5. Action 5: Verify Clean Exit
    • Confirm exit code 0 on both mypy and ruff check.

7. Decision Rules

  • If a function returns None on failure: type return as Optional[ReturnType] or ReturnType | None.
  • If an import is unused (F401): delete the import line.

8. Output Format

Emit the report using this template:

### Python Lint & Type-Check Report: [File]

- **Type Checker**: `mypy [file]` -> PASS
- **Linter**: `ruff check [file]` -> PASS
- **Issues Resolved**: [Count]

#### Resolved Diagnostics
| Line | Tool | Code | Root Cause Fix |
| :--- | :--- | :--- | :--- |
| `[Line]` | Mypy | `arg-type` | Corrected argument type from str to int |

#### Verification Status
- Clean exit code 0 confirmed with zero `# noqa` comments.

9. Verification Checklist

  • mypy exits with code 0.
  • ruff check exits with code 0.
  • Zero # noqa or # type: ignore added.

10. Common Failures and Recovery

Failure SymptomCauseRecovery Action
Incompatible return value typeReturning None without OptionalUpdate return type to Optional[T].

11. Stop or Escalation Conditions

Stop and ask the user when:

  • Mypy configuration requires whole-codebase architecture migration.

12. Examples

Example 1: Successful Execution

Input:

File: src/utils.py
Error: F401 'sys' imported but unused

Output:

### Python Lint & Type-Check Report: src/utils.py

- **Type Checker**: `mypy src/utils.py` -> PASS
- **Linter**: `ruff check src/utils.py` -> PASS
- **Issues Resolved**: 1

#### Resolved Diagnostics
| Line | Tool | Code | Root Cause Fix |
| :--- | :--- | :--- | :--- |
| 3 | Ruff | `F401` | Removed unused `import sys` |

#### Verification Status
- Clean exit code 0 confirmed with zero `# noqa` comments.

Example 2: Ambiguous or Missing Input

Input:

Lint python.

Output:

### Python Lint & Type-Check Report: Halted - No Target

- **Status**: Halted

Please specify the Python file or directory to lint.

Example 3: Expected Final Output

Output:

### Python Lint & Type-Check Report: src/models.py

- **Type Checker**: `mypy src/models.py` -> PASS
- **Linter**: `ruff check src/models.py` -> PASS
- **Issues Resolved**: 2

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

Reviews can't be read right now.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.