本文へ移動
cccskills
無料GitHub で公開

refactor-code

Refactor Python code to improve quality while keeping functionality intact. Use when cleaning up complexity, removing duplication, or tightening structure.

インストール方法を見る

含まれるファイル(1)

  • SKILL.md2.1 KB

SKILL.md(原文)

インストールする前に、エージェントに与えられる指示の中身を確認できます。

Refactor Code

Improve readability, maintainability, and testability without changing behavior.

When to run this skill

  • You’ve been asked to clean up tangled logic or long functions
  • Technical debt (duplication, inconsistent naming) is slowing future work
  • Tests are hard to reason about, or core modules mix responsibilities

Steps

  1. Code quality improvements

    • Break large functions or classes into smaller helpers
    • Extract reusable utilities and keep them pure when possible
    • Rename variables/functions to clearly express intent
    • Replace dict/tuple blobs with Pydantic BaseModels where appropriate
  2. Reduce complexity

    • Flatten deeply nested conditionals (guard clauses, early returns)
    • Replace repetitive code with loops/fixtures/generator helpers
    • Favor composition over inheritance; inject dependencies explicitly
    • Replace boolean flags with clear strategy objects or enums
  3. Enhance maintainability

    • Add or strengthen type hints and docstrings
    • Centralize configuration/timeouts/paths in constants or settings modules
    • Align with SOLID principles when refactoring services or handlers
    • Improve logging and error handling so future debuggers have context
  4. Optimize but stay Pythonic

    • Use list/dict comprehensions when they improve clarity
    • Avoid premature micro-optimizations—profile before optimizing loops
    • Keep dependencies explicit instead of hiding global state

Checklist

  • Extracted reusable functions or helpers
  • Removed duplication and improved naming
  • Simplified nested logic and guard clauses
  • Added or improved type hints/docstrings
  • Tuned logging/error handling to clarify intent
  • Ensured tests cover refactored paths

レビュー

まだレビューはありません。使ってみた感想をお寄せください。

同じリポジトリのスキル

概要と使いどころ

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月10日 更新

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月10日 更新

Financial factsheet analysis with key metrics extraction and investment rationale

日本語の概要は準備中です。原文の説明を表示しています。

Unique-AG/ai52026年10月10日 更新

ci-fix

無料

Diagnose and fix CI failures without leaving your editor.

日本語の概要は準備中です。原文の説明を表示しています。

Unique-AG/ai52026年10月10日 更新

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月10日 更新

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月10日 更新

Unique-AG のスキルをすべて見る

このスキルの問題を報告する