Home / Market / code polish

code polish

Rewrites unprofessional code comments into clear ones and performs non-semantic cleanup. Use to professionalize code without altering logic or behavior.

skill★ 507600 dlgithubCC-BY-4.0 content; MIT code; upstream exceptions applyInstall in CosmosUpstream Source

Documentation & Preview

--- name: code-polish description: Rewrites unprofessional code comments into clear ones and performs non-semantic cleanup. Use to professionalize code without altering logic or behavior. risk: critical source: community date_added: "2026-07-02"

---

Code Polish

A constraint-based protocol for normalizing code comments and performing safe, non-semantic cleanup. This skill exists because human-written code tends to carry casual, outdated, or missing comments, while the goal is professional-grade documentation without touching behavior.

This file is self-contained. Do not require any other skill file to execute this protocol.

Prime Directive

Comments and non-semantic cleanup are the job. Logic is never the job. If a change would alter what the code *does* — not just what it *says* or how it's *arranged* — it is out of scope, no matter how obviously "correct" the fix seems.

---

When to Use

Apply this skill when:

Do not apply this skill when:

---

Phase 0 — Full Read

Before editing anything, read the entire file (or the entire relevant module if the codebase is large — not just the function in question). Do not comment or clean incrementally while still reading. A comment written without full context is a guess, and guesses are how "professional" comments end up wrong.

Identify:

---

Phase 1 — Comment Audit

Classify every existing comment into one of these categories before touching it:

| Category | Example | Action | |---|---|---| | Junk / venting | // wtf is this, // idk why but it works | Remove tone, extract any real information underneath, rewrite professionally — or delete if it truly holds zero information | | Placeholder | // fix later, // TODO hack | Convert to a proper TODO: note with the actual concern stated plainly, or remove if stale/resolved | | Dead code comments | Blocks of commented-out code | Remove, unless the surrounding context makes clear it's intentionally preserved (e.g., a documented fallback) — flag these to the user rather than silently deleting | | Redundant | i++ // increment i | Delete — the code already says this | | Outdated / wrong | Comment describes behavior the code no longer has | Rewrite to match current behavior. Flag to the user that it was stale, don't just silently fix it | | Valuable but informal | // careful, this breaks if you call it twice, learned that the hard way | Preserve the *information*, rewrite the *tone*. Never delete real warnings just because the phrasing is casual | | Missing | Complex logic, non-obvious business rules, or public APIs with no docstring | Add one. Don't over-comment simple, self-explanatory lines |

---

Phase 2 — Non-Semantic Cleanup

Scope is strictly limited to changes that cannot alter behavior:

Anything beyond this — reordering logic, extracting functions, changing control flow, altering algorithms — is out of scope for this skill.

---

Phase 3 — Comment Rewrite / Addition

Apply these standards to every comment touched or added:

---

Phase 4 — Verification

Before presenting the result:

---

Phase 5 — Report Back

Summarize for the user, don't just hand back a silent diff:

---

Examples

Junk / venting → professional

// before
// ugh this took forever to figure out. api rate limits us super hard in prod so we have to do exponential backoff here. just leave it alone
function retryFetch(url, attempts) { ... }

// after
// Uses exponential backoff to handle aggressive API rate-limiting in production.
function retryFetch(url, attempts) { ... }

Redundant → removed

# before
count += 1  # increment count by 1

# after
count += 1

Valuable but informal → tone rewritten, information preserved

# before
# careful, this breaks if you call it twice, learned that the hard way

# after
# Not idempotent: calling this more than once per session corrupts the
# cache index. Callers must guard against duplicate invocation.

Missing → added

// before
public double calculate(double base, int tier) {
    return base * (tier > 2 ? 0.85 : 1.0);
}

// after
/**
 * Applies the loyalty discount. Tiers above 2 qualify for a 15% discount;
 * this threshold matches the current pricing policy, not a technical limit.
 */
public double calculate(double base, int tier) {
    return base * (tier > 2 ? 0.85 : 1.0);
}

Outdated / wrong → corrected and flagged

// before
// returns nil if user not found
func GetUser(id string) (*User, error) { ... } // now returns ErrNotFound instead

// after
// Returns ErrNotFound if the user does not exist.
func GetUser(id string) (*User, error) { ... }
// (flagged to user: original comment was stale — function used to return nil,
// now returns a named error)

---

Security & Safety Notes

This skill never:

---

Limitations