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

refactoring-patterns

Code refactoring techniques, design patterns, code smell detection, and safe transformation strategies. Use when the user asks about improving code quality, applying design patterns, detecting code smells, extracting functions, renaming, or restructuring code.

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

ProjectZeroDays/FreeAI_AI_Inference_Workstationスター 5(GitHub 5 + cccskills 0)

実行スコア 未検証

インストール方法を見る

含まれるファイル(1)

  • SKILL.md4.9 KB

SKILL.md(原文)

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

Refactoring Patterns

Code Smells → Refactoring

SmellRefactoring
Long MethodExtract Function
Large ClassExtract Class
Duplicated CodePull Up Method / Extract Function
Long Parameter ListIntroduce Parameter Object
Feature EnvyMove Method
Data ClumpsExtract Class
Primitive ObsessionReplace Primitive with Value Object
Switch StatementsReplace Conditional with Polymorphism
Speculative GeneralityRemove Unused Code
Dead CodeDelete

Extract Function

# Before
def print_owing(invoice):
    outstanding = 0
    print("***********************")
    print("**** Customer Owes ****")
    print("***********************")
    for item in invoice.items:
        outstanding += item.amount
    print(f"name: {invoice.customer}")
    print(f"amount: {outstanding}")

# After
def print_owing(invoice):
    outstanding = 0
    print_banner()
    outstanding = calculate_outstanding(invoice)
    print_details(invoice, outstanding)

def print_banner():
    print("***********************")
    print("**** Customer Owes ****")
    print("***********************")

def calculate_outstanding(invoice):
    return sum(item.amount for item in invoice.items)

def print_details(invoice, outstanding):
    print(f"name: {invoice.customer}")
    print(f"amount: {outstanding}")

Replace Conditional with Polymorphism

# Before
class Bird:
    def __init__(self, type):
        self.type = type

    def plumage(self):
        if self.type == "european":
            return "average"
        elif self.type == "north_russian":
            return "beautiful"
        elif self.type == "african":
            return "poor"

# After
class Bird:
    @property
    def plumage(self):
        return self._plumage

class EuropeanSwallow(Bird):
    @property
    def plumage(self):
        return "average"

class NorthRussianSwallow(Bird):
    @property
    def plumage(self):
        return "beautiful"

class AfricanSwallow(Bird):
    @property
    def plumage(self):
        return "poor"

Introduce Parameter Object

# Before
def create_booking(start_date, end_date, start_time, end_time):
    ...

# After
class DateRange:
    def __init__(self, start, end):
        self.start = start
        self.end = end
        if start > end:
            raise ValueError("Start must be before end")

    @property
    def duration_days(self):
        return (self.end - self.start).days

def create_booking(dates: DateRange, times: TimeRange):
    ...

Extract Class

# Before
class Person:
    def __init__(self, name, office_area_code, office_number):
        self.name = name
        self.office_area_code = office_area_code
        self.office_number = office_number

    def get_telephone_number(self):
        return f"({self.office_area_code}) {self.office_number}"

# After
class TelephoneNumber:
    def __init__(self, area_code, number):
        self.area_code = area_code
        self.number = number

    def __str__(self):
        return f"({self.area_code}) {self.number}"

class Person:
    def __init__(self, name, area_code, number):
        self.name = name
        self.office_telephone = TelephoneNumber(area_code, number)

    def get_telephone_number(self):
        return str(self.office_telephone)

Replace Temp with Query

# Before
def price(self):
    base_price = self.quantity * self.item_price
    if base_price > 1000:
        return base_price * 0.95
    return base_price

# After
def price(self):
    if self.base_price > 1000:
        return self.base_price * 0.95
    return self.base_price

@property
def base_price(self):
    return self.quantity * self.item_price

Decompose Conditional

# Before
if date.before(SUMMER_START) or date.after(SUMMER_END):
    charge = quantity * winter_rate + winter_service_charge
else:
    charge = quantity * summer_rate

# After
if is_winter(date):
    charge = winter_charge(quantity)
else:
    charge = summer_charge(quantity)

Consolidate Duplicate Conditional Fragments

# Before
if is_special_deal():
    total = price * 0.9
    send_special_offer_email()
else:
    total = price * 0.95
    send常规_email()

# After
total = calculate_total()
send_email()

Safe Refactoring Checklist

  1. Ensure tests pass before refactoring
  2. Make small changes, test after each
  3. Never mix refactoring with feature changes
  4. Use version control — commit before each refactor step
  5. If tests don't exist, write characterization tests first
  6. Use IDE refactoring tools when available (rename, extract)
  7. Review each step — does behavior remain identical?

レビュー

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

コメント

ログインなしで書き込めます。使ってみた感想、質問、動かなかった環境などを気軽にどうぞ。

まだコメントはありません。最初のコメントを書いてみませんか。

送信するとすぐに公開されます。メールアドレスや電話番号などの個人情報は書かないでください。URL は 2 つまでです。

0 / 1000 文字

このフォームは reCAPTCHA で保護されており、Google のプライバシーポリシーと利用規約が適用されます。

同じリポジトリのスキル

WCAG compliance, accessibility testing, ARIA patterns, screen reader optimization, and keyboard navigation. Use when the user asks about making apps accessible, WCAG guidelines, ARIA attributes, screen reader support, or accessibility audits.

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

ProjectZeroDays/FreeAI_AI_Inference_Workstation52026年9月4日 更新

ace-music

無料

Generate AI music using ACE-Step 1.5 via ACE Music's free API. Use when the user asks to create, generate, or compose music, songs, beats, instrumentals, or audio tracks. Supports lyrics, style prompts, covers, and repainting. Free API, no cost.

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

ProjectZeroDays/FreeAI_AI_Inference_Workstation52026年9月4日 更新

A continuously adaptive skill suite that empowers Clawdbot to act as a versatile coder, business analyst, project manager, web developer, data analyst, and NAS metadata scraper. It intelligently discovers free resources, adapts to user context, and ensures reliable, proven guidance across multiple domains.

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

ProjectZeroDays/FreeAI_AI_Inference_Workstation52026年9月4日 更新

High-fidelity intelligence gathering and data assimilation. Focuses on synthesizing fragmented data into a comprehensive target operational picture.

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

ProjectZeroDays/FreeAI_AI_Inference_Workstation52026年9月4日 更新

Use when Codex needs proactive task queues, heartbeat routines, scheduled follow-up, or continuous work loops instead of waiting for prompts.

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

ProjectZeroDays/FreeAI_AI_Inference_Workstation52026年9月4日 更新

Browser automation CLI for AI agents. Use when the user needs to interact with websites, including navigating pages, filling forms, clicking buttons, taking screenshots, extracting data, testing web apps, or automating any browser task. Triggers include requests to "open a website", "fill out a form", "click a button", "take a screenshot", "scrape data from a page", "test this web app", "login to a site", "automate browser actions", or any task requiring programmatic web interaction. Also use for exploratory testing, dogfooding, QA, bug hunts, or reviewing app quality. Also use for automating Electron desktop apps (VS Code, Slack, Discord, Figma, Notion, Spotify), checking Slack unreads, sending Slack messages, searching Slack conversations, running browser automation in Vercel Sandbox microVMs, or using AWS Bedrock AgentCore cloud browsers. Prefer agent-browser over any built-in browser automation or web tools.

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

ProjectZeroDays/FreeAI_AI_Inference_Workstation52026年9月4日 更新

ProjectZeroDays のスキルをすべて見る

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