AgentSkillsCN

Chief Of Staff Refactoring

首席幕僚重构

SKILL.md

Code Refactoring Skill

This skill provides intelligent code refactoring capabilities for the Chief of Staff plugin.

Capabilities

Extract Operations

  • Extract method/function
  • Extract variable
  • Extract class/interface
  • Extract constant

Rename Operations

  • Rename variables with scope awareness
  • Rename functions/methods
  • Rename classes/interfaces
  • Update all references

Move Operations

  • Move function to another module
  • Move class to new file
  • Reorganize imports
  • Update dependencies

Simplification

  • Simplify complex conditionals
  • Remove dead code
  • Consolidate duplicate code
  • Flatten nested structures

Modernization

  • Update to modern syntax
  • Convert callbacks to async/await
  • Use modern APIs
  • Apply language idioms

Usage

When refactoring code, I will:

  1. Analyze Structure: Understand the code's purpose and relationships.

  2. Identify Improvements: Find opportunities for cleaner code.

  3. Preserve Behavior: Ensure refactoring doesn't change functionality.

  4. Update Related Code: Modify tests and dependencies as needed.

Refactoring Patterns

  • Extract Method: Pull code into a new function
  • Inline Method: Replace function call with its body
  • Rename Symbol: Change names across the codebase
  • Move to Module: Relocate code to appropriate location
  • Simplify Conditional: Make if/else clearer
  • Remove Duplication: Consolidate repeated code

Triggers

This skill activates when:

  • You request refactoring
  • You use /refactor, /extract, or /rename commands
  • You mention cleaning up or simplifying code

Configuration

  • preserveComments: Keep comments during transformation
  • aggressiveness: How much to change (conservative, moderate, aggressive)
  • updateTests: Automatically update related tests

Examples

Extract Method

"Extract this logic into a separate function"

Rename

"Rename this variable to something more descriptive"

Simplify

"Simplify this nested conditional"

Modernize

"Update this to use async/await instead of callbacks"