ruff

ruff 用于对 Python 代码进行 lint 和格式化。适合在需要设置 Python 代码检查、替换 flake8/black/isort、配置代码质量规则或加速代码格式化时使用。

仓库最近推送
GitHub Stars
219
Forks
38
Issues / PRs
7

安装方式

先用 Prompt 核对来源与依赖。也可下载安装包。

用 AI 助手安装

复制提示词,让助手先核对固定版本和依赖。

查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "ruff":https://skillpi.com/zh/skills/deepskill-9453609e864b76dd300abd4ca2559656e09f5683dfa13ad84103b93b770ee378。安装前核对上游来源和版本:https://github.com/TerminalSkills/skills。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。

来源与配置

github.com

配置方式待核实

请查看原始来源中的适用工具、依赖和权限要求。

安装实测待补充

ruff 用于对 Python 代码进行 lint 和格式化。适合在需要设置 Python 代码检查、替换 flake8/black/isort、配置代码质量规则或加速代码格式化时使用。

0 下载

介绍来源: third_party · TerminalSkills · 1.0.0 参考来源

SkillPi 解读

实测状态
未测试

文件浏览

在原站浏览文件 ↗

原始 SKILL.md

打开原文 ↗
Frontmatter
name: ruff
description: >-
  Lint and format Python with Ruff. Use when a user asks to set up Python
  linting, replace flake8/black/isort, configure code quality rules, or
  speed up Python code formatting.
license: Apache-2.0
compatibility: 'Python 3.7+'
metadata:
  author: terminal-skills
  version: 1.0.0
  category: development
  tags:
    - ruff
    - linting
    - formatting
    - python
    - code-quality

Ruff

Overview

Ruff is an extremely fast Python linter and formatter written in Rust. It replaces flake8, black, isort, pyupgrade, pydocstyle, and dozens more tools — running 10-100x faster. One tool for all Python code quality.

Instructions

Step 1: Setup

pip install ruff

Step 2: Configuration

# pyproject.toml — Ruff configuration
[tool.ruff]
target-version = "py311"
line-length = 100
src = ["src", "tests"]

[tool.ruff.lint]
select = [
    "E",    # pycodestyle errors
    "W",    # pycodestyle warnings
    "F",    # pyflakes
    "I",    # isort (import sorting)
    "B",    # flake8-bugbear
    "C4",   # flake8-comprehensions
    "UP",   # pyupgrade
    "SIM",  # flake8-simplify
    "TCH",  # flake8-type-checking
    "RUF",  # ruff-specific rules
]
ignore = [
    "E501",   # line too long (handled by formatter)
]
fixable = ["ALL"]

[tool.ruff.lint.isort]
known-first-party = ["my_app"]

[tool.ruff.format]
quote-style = "double"
indent-style = "space"
docstring-code-format = true

Step 3: Use

# Lint
ruff check .                   # check all files
ruff check . --fix             # auto-fix issues
ruff check . --fix --unsafe-fixes  # include risky auto-fixes

# Format
ruff format .                  # format all files
ruff format --check .          # check without modifying (CI)

# Watch mode
ruff check --watch .

Step 4: Pre-commit Hook

# .pre-commit-config.yaml
repos:
  - repo: https://github.com/astral-sh/ruff-pre-commit
    rev: v0.3.0
    hooks:
      - id: ruff
        args: [--fix]
      - id: ruff-format

Step 5: CI Integration

# .github/workflows/lint.yml
- name: Lint with Ruff
  run: |
    ruff check . --output-format=github
    ruff format --check .

Guidelines

  • Ruff replaces flake8, black, isort, pyupgrade in a single tool — remove the old ones.
  • Start with a broad rule set (select = ["E", "W", "F", "I", "B", "UP"]) and expand.
  • ruff check --fix auto-fixes most issues — safe to run in pre-commit hooks.
  • Ruff processes the entire CPython codebase in under 200ms — linting is no longer a bottleneck.
  • Use ruff format as a drop-in replacement for black — same output, 100x faster.

当前收录版本

1.0.0

核对来源版本 ↗

质量评测

满分100 · 来自 SkillPi LAB 实验室的评测报告。

场景价值92/100

亮点

  • 高价值 Python 代码质量管理工具,直接解决开发者核心痛点
  • 覆盖代码检查、格式化、CI/CD 集成等完整工作流
触发精准95/100

亮点

  • 触发词精准覆盖 Python 代码检查、格式化、工具替换等核心场景
  • 边界清晰,不易与其他 Skill 重叠
结构规范95/100

亮点

  • 五步式清晰结构:安装→配置→使用→pre-commit→CI 集成
  • 提供完整端到端示例,frontmatter 规范完整
执行可靠90/100

亮点

  • 工具来源明确,参数正确,覆盖主要使用场景
  • 提供安全检查机制(--check)和自动修复选项
证据可验 (前四项均值)93/100

取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。

正文静态检测

100 / 100 · skillpi-20261123-no-r3-v1

正文未命中当前规则。

分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。

权限与使用前检查

根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。

  • 安装或获取外部依赖

    使用官方来源并锁定版本,在隔离环境检查安装脚本。当前文档检查不覆盖后续下载的代码。

    主文档提及 · 第 32 行
文档引用的域名或地址

这些地址可能用于文档链接或示例,不是已批准的联网清单。使用前核对实际目的地及发送的数据。

  • github.com

本站展示提示不会授予权限。涉及文件改动、密钥、外部发送或费用时,仍由你使用的工具按需确认。

安全评级与访问范围

safe · 静态证据核验,不代表运行安全保证。

使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。