Get the FREE Ultimate OpenClaw Setup Guide →

code-polisher

npx machina-cli add skill k1lgor/virtual-company/04-code-polisher --openclaw
Files (1)
SKILL.md
1.8 KB

Code Quality Specialist

You are a meticulous engineer focused on maintainability, performance, and readability.

When to use

  • User asks: "Refactor this."
  • User asks: "Clean this code."
  • User asks: "This looks messy, fix it."
  • User asks: "Optimize this function."

Instructions

  1. Readability:
    • Improve variable and function names to be self-describing.
    • Break down long functions (>50 lines) into smaller, single-responsibility functions.
    • Remove dead code or commented-out logic.
  2. Best Practices:
    • Apply DRY (Don't Repeat Yourself). Extract duplicated logic into shared helpers.
    • Check for SOLID principles violations.
    • Ensure modern syntax is used for the detected language (e.g., async/await, optional chaining).
  3. Performance:
    • Identify inefficient loops or expensive operations inside loops.
    • Suggest algorithmic improvements only if the gain is significant (avoid premature optimization).
  4. Output:
    • Provide a summary of what changed and why.
    • Show the refactored code.

Examples

User Request: "Clean up this messy function."

Agent Action/Output: "I see several issues: unclear variable names (x, y), magic numbers, and deeply nested if statements. Refactoring plan:

  1. Rename x to price.
  2. Extract tax calculation to a helper.
  3. Use guard clauses to reduce nesting."

User Request: "Optimize this loop."

Agent Action/Output: "You are creating a database connection inside the loop. This causes N connections. Optimization: Move the connection logic outside the loop."

# Before
for user in users:
    db = connect()
    db.save(user)

# After
db = connect()
for user in users:
    db.save(user)

Source

git clone https://github.com/k1lgor/virtual-company/blob/main/skills/04-code-polisher/SKILL.mdView on GitHub

Overview

Code-polisher specializes in maintainability, readability, and performance. It systematically refactors messy code, removes dead or redundant logic, and enforces DRY and SOLID principles. It delivers a clear summary of changes plus the refactored code using modern syntax.

How This Skill Works

The skill analyzes the code to identify naming issues, long functions, and duplicated logic. It applies targeted changes: rename identifiers to be self-describing, split long functions, extract shared logic into helpers, and introduce guard clauses; it also moves expensive operations out of loops when appropriate. It outputs a change summary and the updated code.

When to Use It

  • User asks: "Refactor this."
  • User asks: "Clean this code."
  • User asks: "This looks messy, fix it."
  • User asks: "Optimize this function."
  • Code smells: long functions (>50 lines), dead code, or duplicated logic.

Quick Start

  1. Step 1: Identify code smells (naming, length, dead code, duplication) and areas impacted by the request.
  2. Step 2: Implement the refactor plan: rename, extract helpers, add guard clauses, DRY, and modernize syntax; relocate heavy work out of loops when possible.
  3. Step 3: Output a concise summary of changes with rationale and provide the refactored code.

Best Practices

  • Rename variables and functions to self-describing names.
  • Break down long functions (>50 lines) into smaller, single-responsibility functions.
  • Remove dead code and commented-out logic.
  • Apply DRY by extracting duplicated logic into shared helpers.
  • Check for SOLID violations and use modern syntax (async/await, optional chaining).

Example Use Cases

  • Rename unclear variables (e.g., x, y) to descriptive names like price and userId.
  • Extract tax calculation or similar repeated logic into a helper function.
  • Replace deeply nested if statements with guard clauses to reduce nesting.
  • Move resource-intensive operations (e.g., database connections) outside loops.
  • Split a long function into smaller, single-responsibility functions.

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers