ruff

Automate Python code linting and formatting with Ruff.

Updated Mar 10, 2024
One-click install
npx skills add https://github.com/Mjvolk3/Swanki --skill ruff-mjvolk3
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: ruff
Source: https://github.com/Mjvolk3/Swanki/tree/main/.claude/skills/ruff
Command: npx skills add https://github.com/Mjvolk3/Swanki --skill ruff-mjvolk3

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill automates the process of checking and fixing Python code for style, quality, and potential errors, ensuring adherence to project standards and improving code maintainability.

Core Features & Use Cases

  • Linting: Runs the Ruff linter to identify style violations (Pycodestyle, Pyflakes), import errors, and code quality issues (Pyupgrade, Pydocstyle).
  • Auto-fixing: Automatically corrects many common issues like import sorting, unused imports, and syntax modernization.
  • Manual Fix Guidance: Provides clear instructions for resolving errors that cannot be auto-fixed, such as missing docstrings or line length issues.
  • Use Case: After writing new Python code, run this Skill to automatically format it, fix common errors, and ensure it meets the project's coding standards before committing.

Quick Start

Run the ruff skill to check and fix all staged Python files.

Frequently Asked Questions about ruff

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I automate Python code linting and formatting in my development workflow?

Automating Python code linting and formatting involves running the Ruff tool to apply check and format commands with specific rule configurations, auto-fixing style violations and import errors to maintain code quality before committing.

What is the best way to automatically fix Python style violations and unused imports?

The best way to auto-fix Python style violations and unused imports is using the Ruff linter, which automatically corrects common issues like import sorting and syntax modernization while providing guidance for manual fixes like missing docstrings.

How does Ruff check Python code quality and what rules does it apply?

Ruff checks Python code quality by applying rules from Pycodestyle, Pyflakes, Pyupgrade, and Pydocstyle to identify style violations, import errors, and potential code quality issues, offering auto-fixing capabilities for many common errors.

Can I use this tool to check only staged Python files before committing?

Yes, you can run the tool to check and fix all staged Python files, ensuring that newly written code meets project coding standards and adheres to specific rule configurations before it is committed to version control.

Why does Python linting leave some errors unresolved after auto-fixing?

Python linting leaves some errors unresolved after auto-fixing because certain issues like missing docstrings or line length violations cannot be automatically corrected, requiring manual fix guidance to resolve the specific error.

Do I need to configure specific rules to modernize Python syntax and sort imports?

No, you do not need to configure separate tools to modernize Python syntax and sort imports because the Ruff tool applies Pyupgrade rules for syntax modernization and automatically fixes import sorting during its standard check and format execution.