jpskill.com
🛠️ 開発・MCP コミュニティ

quality-fixer

Automatically apply safe quality fixes including formatting (Black, isort), linting (Ruff auto-fixes), and resolve formatter conflicts. Use when quality checks fail or before committing code.

⚡ おすすめ: コマンド1行でインストール(60秒)

下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。

🍎 Mac / 🐧 Linux
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o quality-fixer.zip https://jpskill.com/download/17340.zip && unzip -o quality-fixer.zip && rm quality-fixer.zip
🪟 Windows (PowerShell)
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/17340.zip -OutFile "$d\quality-fixer.zip"; Expand-Archive "$d\quality-fixer.zip" -DestinationPath $d -Force; ri "$d\quality-fixer.zip"

完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。

💾 手動でダウンロードしたい(コマンドが難しい人向け)
  1. 1. 下の青いボタンを押して quality-fixer.zip をダウンロード
  2. 2. ZIPファイルをダブルクリックで解凍 → quality-fixer フォルダができる
  3. 3. そのフォルダを C:\Users\あなたの名前\.claude\skills\(Win)または ~/.claude/skills/(Mac)へ移動
  4. 4. Claude Code を再起動

⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。

🎯 このSkillでできること

下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。

📦 インストール方法 (3ステップ)

  1. 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
  2. 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
  3. 3. 展開してできたフォルダを、ホームフォルダの .claude/skills/ に置く
    • · macOS / Linux: ~/.claude/skills/
    • · Windows: %USERPROFILE%\.claude\skills\

Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。

詳しい使い方ガイドを見る →
最終更新
2026-05-18
取得日時
2026-05-18
同梱ファイル
1

📖 Skill本文(日本語訳)

※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。

Quality Fix Applier

⚠️ 必須: 最初にプロジェクトドキュメントを読んでください

品質修正を適用する前に、以下のプロジェクトドキュメントを読んで理解する必要があります。

コアプロジェクトドキュメント

  1. README.md - プロジェクトの概要、機能、および始め方
  2. AI_DOCS/project-context.md - 技術スタック、アーキテクチャ、開発ワークフロー
  3. AI_DOCS/code-conventions.md - コードスタイル、フォーマット、ベストプラクティス
  4. AI_DOCS/tdd-workflow.md - TDDプロセス、テスト標準、カバレッジ要件

セッションコンテキスト(利用可能な場合)

  1. .ai-context/ACTIVE_TASKS.md - 現在のタスクと優先順位
  2. .ai-context/CONVENTIONS.md - プロジェクト固有の規約
  3. .ai-context/RECENT_DECISIONS.md - 最近のアーキテクチャ上の決定
  4. .ai-context/LAST_SESSION_SUMMARY.md - 前回のセッションの要約

追加のAIドキュメント

  1. AI_DOCS/ai-tools.md - セッション管理ワークフロー
  2. AI_DOCS/ai-skills.md - 利用可能なその他の専門的なスキル/エージェント

これが重要な理由

  • ツール構成: どのformatterとlinterが構成されているかを理解する
  • コード標準: プロジェクトの規約に沿った修正を適用する
  • 安全ルール: どの自動修正が安全で、手動レビューが必要かを知る
  • 統合: 他の品質ツール(Black、Ruff、isort)と連携する

これらのファイルを読んだ後、以下の品質修正タスクに進んでください。


概要

Pythonコードに安全な品質修正を自動的に適用し、フォーマットの問題、lintの問題、およびformatterの競合を解決します。

いつ使用するか

  • コードを書いた後、make checkを実行する前
  • make lintまたはmake formatが修正可能な問題を報告した場合
  • BlackとRuffのformatterの競合を解決する場合
  • 品質ゲートが通過するように、コードをコミットする前
  • すべての安全な自動修正を適用したい場合

このSkillで修正できること

フォーマットの問題

  • Blackコードフォーマット
  • isortインポートソート
  • 行の長さの調整
  • 空白の正規化

Lintの問題(安全な自動修正)

  • 未使用のインポートの削除
  • 未使用の変数(安全な場合)
  • F-string変換
  • 単純化可能なif文
  • リスト/辞書内包表記の改善

型ヒントの問題(安全なケース)

  • returnのない関数に-> Noneを追加
  • 明らかな型ヒント(str、int、boolリテラル)を追加
  • スタブシグネチャのEllipsisを修正

Formatterの競合

  • BlackとRuffの不一致
  • 長い文字列のメッセージ変数の抽出
  • 改行の調整

使用例

プロジェクト内のすべての問題を修正

# 包括的な品質修正を実行
apply quality fixes to the entire project

アクション:

  1. make format(Black + isort)を実行
  2. --fixフラグ付きでRuffを実行
  3. formatterの競合をチェックして解決
  4. 何が修正されたかを報告

特定のファイルを修正

# 単一のファイルを修正
fix quality issues in src/python_modern_template/validators.py

アクション:

  1. 特定のファイルをフォーマット
  2. そのファイルにRuffの修正を適用
  3. 競合が発生していないことを確認
  4. 変更の差分を表示

Formatterの競合のみを解決

# 競合に焦点を当てる
resolve Black and Ruff formatter conflicts

アクション:

  1. 両方のformatterを実行
  2. それらが一致しない行を特定
  3. 競合解決戦略を適用
  4. 両方が満足していることを確認

プレビューモード(ドライラン)

# 適用せずに何が修正されるかを確認
preview quality fixes for src/

アクション:

  1. すべてのチェックをドライランモードで実行
  2. 何が変更されるかを表示
  3. 適用する前に確認を求める

ステップバイステップのプロセス

ステップ1:フォーマットを実行

# Blackフォーマットを適用
make format

# これは以下を実行します:
# - black src/ tests/
# - isort src/ tests/

修正されること:

  • コードスタイル(スペーシング、インデント、引用符)
  • インポートの整理とグループ化
  • 行の長さの遵守(88文字)

ステップ2:Ruffの自動修正を適用

# 自動修正でRuffを実行
uv run ruff check --fix src/ tests/

# 安全な修正には以下が含まれます:
# - 未使用のインポートの削除
# - 未使用の変数(安全な場合)の削除
# - F-string変換
# - 式の単純化

修正されること:

  • インポートのクリーンアップ
  • コードの単純化
  • 最新のPythonイディオム

ステップ3:Formatterの競合を検出

# BlackとRuffが一致するかどうかを確認
make format && make lint

一般的な競合:

  • 行の長さを超える長い文字列リテラル
  • 改行が必要な複雑な式
  • コメントの配置の違い

ステップ4:競合を解決

戦略1:メッセージ変数を抽出

# 修正前(競合 - 長すぎる)
logger.error("This is a very long error message that exceeds the line length limit")

# 修正後(解決済み)
msg = "This is a very long error message that exceeds the line length limit"
logger.error(msg)

戦略2:括弧を使用して改行

# 修正前(競合)
result = some_function(arg1, arg2, arg3, arg4, arg5, arg6)

# 修正後(解決済み)
result = some_function(
    arg1, arg2, arg3, arg4, arg5, arg6
)

戦略3:長い文字列を分割

# 修正前(競合)
text = "This is a very long string that should be split across multiple lines for readability"

# 修正後(解決済み)
text = (
    "This is a very long string that should be "
    "split across multiple lines for readability"
)

ステップ5:修正を確認

# 完全な品質チェックを実行
make check

合格する必要があるもの:

  • ✅ フォーマット(Black + isort)
  • ✅ Lint(Ruff + Pylint + mypy)
  • ✅ テスト(pytest)
  • ✅ セキュリティ(Bandit)

競合解決戦略

競合の特定

両方のツールを実行して比較します。

# Blackを適用
black src/python_modern_template/module.py

# Ruffをチェック
ruff check src/python_modern_template/module.py

# Ruffがまだフォーマットについて不満を言う場合、競合があります

解決の決定木

  1. 長い文字列リテラル → 変数に抽出するか、行を分割する

  2. 複雑な式 → 括弧と改行を追加する

  3. 長い関数呼び出し → 引数を複数行に分割する

  4. コメントの配置 → コメントを行の上に移動する

(原文はここで切り詰められています)

📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開

Quality Fix Applier

⚠️ MANDATORY: Read Project Documentation First

BEFORE applying quality fixes, you MUST read and understand the following project documentation:

Core Project Documentation

  1. README.md - Project overview, features, and getting started
  2. AI_DOCS/project-context.md - Tech stack, architecture, development workflow
  3. AI_DOCS/code-conventions.md - Code style, formatting, best practices
  4. AI_DOCS/tdd-workflow.md - TDD process, testing standards, coverage requirements

Session Context (if available)

  1. .ai-context/ACTIVE_TASKS.md - Current tasks and priorities
  2. .ai-context/CONVENTIONS.md - Project-specific conventions
  3. .ai-context/RECENT_DECISIONS.md - Recent architectural decisions
  4. .ai-context/LAST_SESSION_SUMMARY.md - Previous session summary

Additional AI Documentation

  1. AI_DOCS/ai-tools.md - Session management workflow
  2. AI_DOCS/ai-skills.md - Other specialized skills/agents available

Why This Matters

  • Tool Configuration: Understand which formatters and linters are configured
  • Code Standards: Apply fixes that align with project conventions
  • Safety Rules: Know which auto-fixes are safe vs. require manual review
  • Integration: Coordinate with other quality tools (Black, Ruff, isort)

After reading these files, proceed with your quality fixing task below.


Overview

Automatically apply safe quality fixes to Python code, resolving formatting issues, linting problems, and formatter conflicts.

When to Use

  • After writing code, before running make check
  • When make lint or make format reports fixable issues
  • To resolve Black vs Ruff formatter conflicts
  • Before committing code to ensure quality gates pass
  • When you want to apply all safe, automatic fixes

What This Skill Fixes

Formatting Issues

  • Black code formatting
  • isort import sorting
  • Line length adjustments
  • Whitespace normalization

Linting Issues (Safe Auto-Fixes)

  • Unused imports removal
  • Unused variables (when safe)
  • F-string conversion
  • Simplifiable if statements
  • List/dict comprehension improvements

Type Hint Issues (Safe Cases)

  • Add -> None to functions without return
  • Add obvious type hints (str, int, bool literals)
  • Fix Ellipsis in stub signatures

Formatter Conflicts

  • Black vs Ruff disagreements
  • Message variable extraction for long strings
  • Line break adjustments

Usage Examples

Fix All Issues in Project

# Run comprehensive quality fixes
apply quality fixes to the entire project

Actions:

  1. Run make format (Black + isort)
  2. Run Ruff with --fix flag
  3. Check for and resolve formatter conflicts
  4. Report what was fixed

Fix Specific File

# Fix a single file
fix quality issues in src/python_modern_template/validators.py

Actions:

  1. Format the specific file
  2. Apply Ruff fixes to that file
  3. Verify no conflicts introduced
  4. Show diff of changes

Resolve Formatter Conflicts Only

# Focus on conflicts
resolve Black and Ruff formatter conflicts

Actions:

  1. Run both formatters
  2. Identify lines where they disagree
  3. Apply conflict resolution strategies
  4. Verify both are satisfied

Preview Mode (Dry Run)

# See what would be fixed without applying
preview quality fixes for src/

Actions:

  1. Run all checks in dry-run mode
  2. Show what would be changed
  3. Ask for confirmation before applying

Step-by-Step Process

Step 1: Run Formatting

# Apply Black formatting
make format

# This runs:
# - black src/ tests/
# - isort src/ tests/

What gets fixed:

  • Code style (spacing, indentation, quotes)
  • Import organization and grouping
  • Line length compliance (88 characters)

Step 2: Apply Ruff Auto-Fixes

# Run Ruff with auto-fix
uv run ruff check --fix src/ tests/

# Safe fixes include:
# - Remove unused imports
# - Remove unused variables (when safe)
# - F-string conversion
# - Simplify expressions

What gets fixed:

  • Import cleanup
  • Code simplification
  • Modern Python idioms

Step 3: Detect Formatter Conflicts

# Check if Black and Ruff agree
make format && make lint

Common conflicts:

  • Long string literals exceeding line length
  • Complex expressions needing line breaks
  • Comment placement differences

Step 4: Resolve Conflicts

Strategy 1: Extract Message Variables

# Before (conflict - too long)
logger.error("This is a very long error message that exceeds the line length limit")

# After (resolved)
msg = "This is a very long error message that exceeds the line length limit"
logger.error(msg)

Strategy 2: Use Parentheses for Line Breaks

# Before (conflict)
result = some_function(arg1, arg2, arg3, arg4, arg5, arg6)

# After (resolved)
result = some_function(
    arg1, arg2, arg3, arg4, arg5, arg6
)

Strategy 3: Split Long Strings

# Before (conflict)
text = "This is a very long string that should be split across multiple lines for readability"

# After (resolved)
text = (
    "This is a very long string that should be "
    "split across multiple lines for readability"
)

Step 5: Verify Fixes

# Run complete quality check
make check

Must pass:

  • ✅ Format (Black + isort)
  • ✅ Lint (Ruff + Pylint + mypy)
  • ✅ Tests (pytest)
  • ✅ Security (Bandit)

Conflict Resolution Strategies

Identifying Conflicts

Run both tools and compare:

# Apply Black
black src/python_modern_template/module.py

# Check Ruff
ruff check src/python_modern_template/module.py

# If Ruff still complains about formatting, there's a conflict

Resolution Decision Tree

  1. Long String Literals → Extract to variable or split across lines

  2. Complex Expressions → Add parentheses and line breaks

  3. Long Function Calls → Break arguments to multiple lines

  4. Comment Placement → Move comments above the line

  5. Type Annotation Complexity → Split to multiple lines with proper indentation

Example: Resolving Long String Conflict

Problem:

# Black formats this way:
raise ValueError("The email address provided is not valid because it does not contain the required @ symbol")

# Ruff complains: E501 Line too long (92 > 88)

Solution:

# Extract message variable
error_msg = (
    "The email address provided is not valid because it "
    "does not contain the required @ symbol"
)
raise ValueError(error_msg)

# Both Black and Ruff are satisfied!

What This Skill Does NOT Fix

Complex Logic Issues

  • Algorithm problems
  • Business logic errors
  • Design flaws

Non-Obvious Type Hints

  • Complex generic types
  • Union types requiring domain knowledge
  • Custom type aliases

Docstring Content

  • Will format docstrings
  • Won't write missing docstrings
  • Won't improve docstring quality

Test Failures

  • Only fixes code style
  • Doesn't fix failing tests
  • Doesn't add missing tests

Breaking Changes

  • Only applies safe, non-breaking fixes
  • Won't remove used variables
  • Won't change semantics

Output Format

After applying fixes, provide a report:

## Quality Fixes Applied

**Files Modified:** X
**Total Changes:** X lines

### Formatting Fixes
- ✅ Applied Black formatting to X files
- ✅ Sorted imports with isort in X files
- ✅ Fixed line length issues: X lines

### Linting Fixes
- ✅ Removed X unused imports
- ✅ Converted X strings to f-strings
- ✅ Simplified X expressions
- ✅ Fixed X Ruff issues

### Conflicts Resolved
- ✅ Extracted X message variables
- ✅ Split X long strings
- ✅ Reformatted X function calls

### Quality Check Results
```bash
make check

[Show output]

Files Changed

  1. src/python_modern_template/module1.py (+12, -8)
  2. src/python_modern_template/module2.py (+5, -3)
  3. tests/test_module.py (+3, -2)

Next Steps

  • Review changes with git diff
  • Run tests to ensure no breaking changes: make test
  • Commit changes if satisfied

Safety Features

Dry Run Mode

Always available for preview:

# Format preview
black --check --diff src/

# Ruff preview
ruff check --fix --diff src/

Git Integration

Verify changes before committing:

# See what changed
git diff

# Stage specific changes
git add -p

Backup Strategy

For large fixes, create a commit first:

# Commit current state
git commit -m "Before quality fixes"

# Apply fixes
[quality-fixer runs]

# Review changes
git diff HEAD~1

# Undo if needed
git reset --hard HEAD~1

Integration with Project Tools

Makefile Integration

# Just formatting
make format

# Just linting (with fixes)
make lint

# Complete check (no auto-fix)
make check

Pre-Commit Integration

Add to .pre-commit-config.yaml:

- repo: local
  hooks:
    - id: quality-fixer
      name: Quality Fixer
      entry: python .claude/skills/quality-fixer/scripts/auto_fix.py
      language: system
      types: [python]

CI Integration

Run in CI with --check mode:

# CI should verify, not fix
make check

# If it fails, developers run:
[quality-fixer to fix locally]

Advanced Features

Selective Fixing

Fix only specific types of issues:

# Only formatting
[quality-fixer] --format-only

# Only import cleanup
[quality-fixer] --imports-only

# Only conflicts
[quality-fixer] --conflicts-only

Ignore Patterns

Respect configuration in pyproject.toml:

[tool.ruff.lint]
ignore = ["E501"]  # Don't auto-fix line length in specific cases

[tool.black]
extend-exclude = '''
/(
  | generated
)/
'''

Custom Rules

Define project-specific fixes:

# .claude/skills/quality-fixer/scripts/custom_rules.py

def fix_common_typos(code: str) -> str:
    """Fix project-specific common mistakes."""
    fixes = {
        "recieve": "receive",
        "seperator": "separator",
    }
    for typo, correction in fixes.items():
        code = code.replace(typo, correction)
    return code

Best Practices

  1. Run before committing - Always clean up code before commits
  2. Review changes - Don't blindly accept all fixes, use git diff
  3. Test after fixing - Run make test to ensure no breaking changes
  4. Fix iteratively - Start with formatting, then linting, then conflicts
  5. Understand the changes - Learn from fixes to avoid future issues

Common Scenarios

Scenario 1: Before Committing

# 1. Apply fixes
[quality-fixer]

# 2. Review changes
git diff

# 3. Test
make test

# 4. Commit
git add .
git commit -m "feat: add new feature"

Scenario 2: After Code Review

# Code reviewer says: "Fix formatting and linting"

# 1. Apply fixes
[quality-fixer]

# 2. Verify all issues resolved
make check

# 3. Push
git push

Scenario 3: CI Failure

# CI reports quality issues

# 1. Pull latest
git pull

# 2. Apply fixes
[quality-fixer]

# 3. Verify locally
make check

# 4. Push fix
git commit -am "fix: resolve quality issues"
git push

Troubleshooting

"Black and Ruff still conflict after fix"

Solution: Manually review the conflicting lines and apply advanced strategies:

  • Extract complex expressions to variables
  • Restructure the code for better formatting
  • Use # noqa comments sparingly for unavoidable cases

"Auto-fix broke my tests"

Solution:

  • Revert with git checkout -- <file>
  • Review what was changed with git diff
  • Apply fixes more selectively
  • Report if a fix is unsafe (should not be applied)

"Pylint still reports issues"

Note: This skill only applies auto-fixable issues. Pylint often requires manual fixes:

  • Unused arguments → Use _ prefix or remove
  • Too many arguments → Refactor function
  • Too complex → Simplify logic

Remember

Quality fixes are TOOLS, not SUBSTITUTES for good code:

  • Write clean code from the start
  • Understand why formatters want changes
  • Learn from the fixes applied
  • Don't rely on auto-fix for everything

This skill helps you maintain code quality efficiently, but good coding practices are still essential!