跳到正文
cccskills
免费在 GitHub 公开

smells

Analyze a class or module for code smells and produce a prioritized refactoring plan. Use when the user asks for code smell analysis, says `/smells`, or runs `/refactor:smells`.

中文简介正在准备中。当前显示原文说明。

查看安装方法

包含的文件(1)

  • SKILL.md3.4 KB

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

Analyze the provided class for code smells and create a refactoring plan.

Usage

/smells $ARGUMENTS

Analysis Output

📊 Code Smell Analysis for: $ARGUMENTS

🔍 Top 5 Code Smells Detected:

  1. Poor Naming Conventions

    • Generic variable names (data, temp, obj, result)
    • Non-descriptive method names (process, handle, do)
    • Inconsistent naming patterns
    • Fix: Rename to domain-specific terms that describe purpose
  2. Long Method

    • Methods exceeding 20-30 lines
    • Multiple responsibilities in single method
    • Difficult to test and understand
    • Fix: Extract smaller, focused methods with single responsibilities
  3. Large Class (God Object)

    • Too many responsibilities in one class
    • High number of instance variables
    • Violates Single Responsibility Principle
    • Fix: Split into smaller, cohesive classes
  4. Duplicate Code

    • Copy-pasted logic across methods
    • Similar patterns with slight variations
    • Fix: Extract common logic into reusable methods
  5. Feature Envy

    • Methods that use data from other classes more than their own
    • Excessive getter/setter calls to another object
    • Fix: Move method to the class it's most interested in

📋 Refactoring Plan

Phase 1: Name Refactoring (No Behavior Changes)

  • Identify all poorly named variables, methods, and fields
  • Map current names to descriptive alternatives
  • Ensure naming follows language conventions:
    • Java/JavaScript: camelCase for methods/variables, PascalCase for classes
    • Python: snake_case for functions/variables, PascalCase for classes
  • Update all references throughout codebase
  • Run tests to ensure no behavioral changes

Phase 2: Structure Improvements

  • Address long methods by identifying extraction points
  • Plan class decomposition for God Objects
  • Identify duplicate code patterns for consolidation
  • Map feature envy methods to their proper homes

Phase 3: Implementation Order

  1. Start with naming - Low risk, high readability impact
  2. Extract methods - Reduce complexity incrementally
  3. Remove duplication - Create reusable components
  4. Reorganize classes - Move methods to appropriate classes
  5. Split large classes - Final structural improvements

🎯 Success Criteria

  • All tests pass after each refactoring step
  • Code coverage remains the same or improves
  • Cyclomatic complexity reduced
  • Improved readability scores
  • No behavioral changes introduced

⚠️ Risk Mitigation

  • Create comprehensive test suite before refactoring
  • Use version control for easy rollback
  • Refactor in small, reviewable commits
  • Document all name mappings
  • Review with team before major structural changes

Example Name Refactorings

// Before
getData() → fetchCustomerPurchaseHistory()
processItems() → calculateMonthlyRevenue()
userObj → customerProfile
temp → filteredTransactions
data → invoiceRecords
doStuff() → validatePaymentCredentials()

Next Steps

  1. Review the identified code smells
  2. Prioritize based on impact and risk
  3. Begin with Phase 1 naming refactors
  4. Proceed incrementally through the plan
  5. Measure improvements after each phase

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

Automates browser interactions for web testing, form filling, screenshots, and data extraction. Use when the user needs to navigate websites, interact with web pages, fill forms, take screenshots, test web applications, or extract information from web pages.

中文简介正在准备中。当前显示原文说明。

SDiamante13/dotfiles112026年10月2日 更新

catchup

免费

Rebuilds session context after a clear by reading git history, plans, and beads state. Triggers on 'catch up'.

中文简介正在准备中。当前显示原文说明。

SDiamante13/dotfiles112026年10月2日 更新

changelog

免费

Generate a bullet-point summary of branch changes for a PR description. Triggers on "changelog", "pr summary", "summarize branch", or "/changelog".

中文简介正在准备中。当前显示原文说明。

SDiamante13/dotfiles112026年10月2日 更新

commit

免费

Commit the current changes with quality checks, status review, staged diff inspection, appropriate tests, and a clear commit message. Use when the user says "commit", "c", asks to make a commit, or wants changes saved in git.

中文简介正在准备中。当前显示原文说明。

SDiamante13/dotfiles112026年10月2日 更新

declutter

免费

Refactor code to remove dead code, useless comments, unused variables, and unused imports. Use when asked to declutter a class, clean up noisy code, remove cruft, or run `/refactor:declutter`.

中文简介正在准备中。当前显示原文说明。

SDiamante13/dotfiles112026年10月2日 更新

dry

免费

Refactor duplicated code by extracting helpers, shared abstractions, or clearer reusable structure. Use when asked to apply DRY, remove duplication, consolidate repeated logic, or run `/refactor:dry`.

中文简介正在准备中。当前显示原文说明。

SDiamante13/dotfiles112026年10月2日 更新

查看 SDiamante13 的全部技能

报告此技能的问题