ruff-formatter

📁 frizzle-chan/mudd 📅 Jan 27, 2026
21
总安装量
8
周安装量
#17498
全站排名
安装命令
npx skills add https://github.com/frizzle-chan/mudd --skill ruff-formatter

Agent 安装分布

opencode 7
gemini-cli 5
claude-code 5
github-copilot 5
codex 4
trae 3

Skill 文档

Ruff Formatter

Fast Python code formatter, drop-in replacement for Black with >99.9% compatibility.

Quick Reference

# Format all files in current directory
ruff format .

# Format specific file(s)
ruff format path/to/file.py

# Check without modifying (CI/pre-commit)
ruff format --check .

# Show diff of what would change
ruff format --diff .

Fixing Formatting Issues

When ruff format --check fails:

  1. Run ruff format . to auto-fix all formatting
  2. Review changes with git diff
  3. Commit the formatted code

For import sorting issues, run linter first:

ruff check --select I --fix .  # Sort imports
ruff format .                   # Then format

Format Suppression

Disable formatting for specific code:

# fmt: off
matrix = [
    [1, 0, 0],
    [0, 1, 0],
    [0, 0, 1],
]
# fmt: on

x = 1  # fmt: skip

Configuration

In pyproject.toml or ruff.toml:

[tool.ruff.format]
quote-style = "double"      # or "single"
indent-style = "space"      # or "tab"
line-length = 88            # default
docstring-code-format = true

Exit Codes

  • 0: Success (files formatted or already formatted)
  • 1: With --check: files need formatting
  • 2: Error (invalid config, CLI error)