← Browse

@hua-bang/refactor

A

Refactor code to improve structure, readability, and maintainability without changing behavior

skillclaude

Install

agr install @hua-bang/refactor --target claude

Writes 1 file into .claude/skills/, pinned to git-ec659083.

  • .claude/skills/refactor/SKILL.md

Document


name: refactor description: Refactor code to improve structure, readability, and maintainability without changing behavior version: 1.0.0 author: Pulse Coder Team

Code Refactoring Skill

This skill guides systematic code refactoring while preserving functionality.

Refactoring Principles

Extract Method/Function

  • Break down large functions into smaller, focused ones
  • Name functions based on their purpose
  • Each function should do one thing well

Simplify Conditionals

  • Replace complex conditions with well-named functions
  • Use early returns to reduce nesting
  • Consider guard clauses

Remove Duplication

  • Identify repeated code patterns
  • Extract common logic into reusable functions
  • Use abstraction wisely (avoid premature optimization)

Improve Naming

  • Use descriptive, meaningful names
  • Follow language conventions
  • Avoid abbreviations unless widely known

Organize Code

  • Group related functionality
  • Separate concerns
  • Follow single responsibility principle

Refactoring Workflow

  1. Understand First: Read and understand the existing code
  2. Ensure Tests: Make sure tests exist or write them
  3. Small Steps: Make incremental changes
  4. Test After Each Step: Verify functionality is preserved
  5. Review: Check if the code is clearer than before

Common Refactoring Patterns

  • Extract Method
  • Extract Variable
  • Inline Method/Variable
  • Replace Magic Number with Named Constant
  • Replace Conditional with Polymorphism
  • Move Method/Field
  • Rename Method/Variable

Safety Guidelines

  • Never change behavior while refactoring
  • Keep refactoring separate from feature work
  • Run tests after each change
  • Use version control to track changes
  • Consider reverting if complexity increases

Trustgrade A

  • passBody integrity

    Whether the stored document is plausibly the kind of file the artifact declares, rather than something fetched by mistake.

  • passType matchnot applicable to this artifact type

    Whether the artifact is really the kind of thing its metadata claims it is.

  • passFreshness

    How long since the source repository was last pushed to.

  • passPrompt injection

    Scans the artifact's own text for instructions aimed at your agent rather than at you.

  • passLicense

    Whether the source repository declares an SPDX license permissive enough to redistribute.

How the grade is calculated

Each check contributes 0 points when it passes, 1 when it warns, and 2 when it fails. The total maps to a letter:

  • Aevery check passed
  • Bone warning
  • Ctwo warnings
  • Dprompt injection or body integrity failed, or three warnings
  • Fone of those failed, and something else is wrong

These are automated hygiene checks, not a security audit, and not a dependency or vulnerability scan. A grade of A means nothing was flagged — not that the artifact is safe.

Versions

  • git-ec6590837e642026-07-31