본문으로 건너뛰기
cccskills
무료GitHub에 공개

ruff

Fix all Python lint violations and enforce consistent formatting in one command.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

설치 방법 보기

포함된 파일(1)

  • SKILL.md6.4 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

What I do

I run ruff to auto-fix all fixable lint violations and enforce consistent code formatting in one step:

  • Auto-fix lint violations — unused imports, line length, style issues, import sorting, and more
  • Enforce formatting — consistent code style via ruff's Black-compatible formatter
  • Surface unfixable issues — show exactly which violations need manual attention, with rule codes and locations
  • Configure ruff — add a minimal [tool.ruff] section to pyproject.toml if ruff isn't yet configured

When to use me

  • You want to clean up a Python file or entire project before committing
  • CI is failing on lint or format checks and you want to auto-fix everything fixable
  • You want to see what violations remain after auto-fix so you know what to fix manually
  • You're setting up ruff in a project that doesn't have it configured yet

Example usage

/ruff
/ruff check
/ruff format
/ruff init
"fix linting"
"fix all lint issues"

Workflow

Fixing lint violations automatically

Run ruff check --fix to auto-fix all fixable lint violations in the current directory:

ruff check --fix .

ruff fixes violations it can safely transform automatically — including:

  • Unused imports (F401)
  • Import sorting (I001) — replaces isort
  • Unnecessary f-strings, redundant open modes, and other style issues
  • pyupgrade-style modernisations (e.g. Union[X, Y] → X | Y for Python 3.10+)

Interpreting output:

  • ruff prints each fixed violation: Fixed 1 error. or Found 3 errors (3 fixed, 0 remaining).
  • Exit code 0: all violations fixed or none found
  • Exit code 1: violations remain that could not be auto-fixed (see Understanding unfixable violations)

Example output:

Found 5 errors (5 fixed, 0 remaining).

Enforcing consistent formatting

Run ruff format to apply consistent code style across all Python files:

ruff format .

ruff's formatter is Black-compatible — it produces the same output as Black for the vast majority of code. It handles:

  • Line length normalisation (default 88 characters)
  • Quote normalisation (double quotes by default)
  • Trailing comma handling
  • Blank line normalisation

Formatting is separate from linting: ruff check --fix fixes lint rules; ruff format fixes style. Run both for a complete cleanup:

ruff check --fix . && ruff format .

This is the recommended default invocation — lint first, then format. The order matters because formatting after linting ensures the final output is consistently styled even when lint fixes change code structure.


Understanding unfixable violations

After running ruff check --fix ., any remaining output represents violations that require manual attention:

ruff check .    # dry run: show all current violations without fixing

Example output:

src/main.py:42:5: E501 Line too long (96 > 88 characters)
src/utils.py:18:1: F841 Local variable `result` is assigned to but never used
tests/test_api.py:7:1: S101 Use of `assert` detected

Reading the output: file:line:col: RULE-CODE message

Common unfixable rules:

RuleNameFix
E501Line too longManually break the line or raise line-length in config
F841Unused variableRemove or use the variable
F811Redefinition of unused nameRemove duplicate definition
S101Assert detectedReplace with proper exception in production code
B006Mutable default argumentUse None default + if arg is None: arg = [] pattern
PLR0913Too many argumentsRefactor to use a dataclass or config object

When unfixable violations are found, the skill shows the count, lists each with its rule code and location, and explains how to resolve the most common ones.


Configuring ruff in pyproject.toml

If ruff is not yet configured in the project, add a [tool.ruff] section to pyproject.toml:

[tool.ruff]
line-length = 88
target-version = "py311"    # match your Python version

[tool.ruff.lint]
select = ["E", "F", "I", "B", "S"]   # pycodestyle + pyflakes + isort + bugbear + bandit
ignore = ["S101"]                      # ignore assert in tests

[tool.ruff.lint.per-file-ignores]
"tests/**/*.py" = ["S101", "PLR2004"]  # allow assert and magic values in tests

Alternatively, use a standalone ruff.toml at the project root (same format, without [tool.ruff] prefix):

line-length = 88
target-version = "py311"

[lint]
select = ["E", "F", "I"]

Rule set guidance:

CodeRulesetReplaces
E, Wpycodestyleflake8 E/W
Fpyflakesflake8 F
Iisortisort
Bflake8-bugbearflake8-bugbear
Sflake8-banditbandit
UPpyupgradepyupgrade
RUFruff-specific—

Start with ["E", "F", "I"] as a minimal set and add more as your project adopts stricter standards.


Tips for Success

  1. Run ruff check --fix . && ruff format . as your standard cleanup — this covers both lint and format in one pass. Alias it or add it to a Makefile target.

  2. Dry run before fixing: ruff check . (no --fix) shows all violations without modifying files — useful to understand the scope before applying changes.

  3. ruff replaces multiple tools — ruff covers flake8, isort, pyupgrade, and parts of pylint. If you're migrating, you can remove those tools from pyproject.toml dev dependencies once ruff is configured.

  4. Add ruff to pre-commit: ruff runs in milliseconds on large codebases, making it ideal for pre-commit hooks. The official hooks are available at github.com/astral-sh/ruff-pre-commit.

  5. CI auto-patch: In CI, run ruff check --fix . && ruff format . && git diff --exit-code to fail the build if unfixed violations or unformatted files are committed.

  6. Check ruff is installed: ruff --version. Install with pip install ruff, uv add --dev ruff, or brew install ruff.

  7. E501 (line too long) is often not worth fixing manually — consider raising line-length in [tool.ruff] to 100 or 120 if your codebase has many long lines and reformatting isn't feasible.

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Implement comprehensive error handling for Python code paths to keep services resilient and user-friendly. Use when failures are currently silent or exceptions leak through.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

Unique-AG/ai52026년 10월 19일 업데이트

Tabular and numerical data analysis with descriptive statistics and insights. Use when the user provides data, tables, CSVs, or numbers and wants analysis.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

Unique-AG/ai52026년 10월 19일 업데이트

Financial factsheet analysis with key metrics extraction and investment rationale

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

Unique-AG/ai52026년 10월 19일 업데이트

ci-fix

무료

Diagnose and fix CI failures without leaving your editor.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

Unique-AG/ai52026년 10월 19일 업데이트

Reproduce ai-repo PR checks locally with Poe and CI scripts, including per-package typecheck and coverage behavior. Use when validating changes before push or when user asks which local commands match CI.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

Unique-AG/ai52026년 10월 19일 업데이트

Ask clarifying questions before implementing to ensure Python requirements are understood. Use when a task lacks detail, dependencies are unclear, or multiple interpretations are possible.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

Unique-AG/ai52026년 10월 19일 업데이트

Unique-AG의 스킬 모두 보기

이 스킬의 문제 신고