Clean code

From samirpatil2000/skills · View interactive version

Clean code is an AI agent skill from the GitHub repository samirpatil2000/skills. Review, refactor, or rewrite code for readability and maintainability. Trigger on: "clean up", "refactor", "improve code", "code smells", "simplify", "make readable", "too long", "bad naming", "technical debt", or any request to improve existing code quality. Also trigger when code has obvious smell

How to use this skill

Skill file

Clean Code Skill

Diagnose First

Scan for: vague names · functions doing too much · deep nesting · magic values · duplicated logic · silent error handling · comments explaining what not why

Core Techniques

Rename for intent

# ❌ d, arr, flag, doStuff
# ✅ today, activeUsers, isVisible, calculateDiscount

Extract functions — if a block needs a comment, make it a named function.

Early returns — flatten nesting by returning/guarding at the top.

if (!order) return;
if (!order.isPaid) return;
// main logic here

Named constants — no magic values.

HTTP_NOT_FOUND = 404  # not just 404 inline

DRY — 2+ copies of logic → extract once.

Reduce params — >3 args → use an options object/struct.

Output Format

Quick Checklist

Tone

Specific not vague · constructive not critical · explain why not just what · flag style vs. real problems

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.