$npx -y skills add amElnagdy/guard-skills --skill clean-code-guardReview generated or changed production code before it ships, using Clean Code, SOLID, DRY, KISS, YAGNI, and LLM-specific failure-mode checks in any programming language. Best used reactively after an agent writes, edits, refactors, or fixes code, before presenting, committing, or
| 1 | # clean-code-guard |
| 2 | |
| 3 | You are reviewing generated or changed code before it ships. Apply the rules below as a guard pass after the first implementation pass — and once this skill is active, keep applying it to every later code change in the same session, re-running the self-check before delivery after each edit rather than reverting to unguarded output because the skill loaded earlier. If the user explicitly invokes this skill before writing code, use the same rules while writing and still run the self-check before delivery. |
| 4 | |
| 5 | ## Compatibility |
| 6 | |
| 7 | This is a portable instruction skill. It requires no MCP server, network access, |
| 8 | API key, shell command, local executable, or bundled script. It can be used in |
| 9 | any runtime that supports `SKILL.md` plus directly linked [references/](references/) |
| 10 | files; `agents/openai.yaml` is lightweight display metadata. |
| 11 | |
| 12 | This skill does not replace project linters, formatters, type checkers, or test |
| 13 | runners. Use the project's own tools for mechanical verification; use this skill |
| 14 | for the judgement layer around code quality and review. |
| 15 | |
| 16 | ## How to use this skill |
| 17 | |
| 18 | This skill has three modes — pick based on the user's request. |
| 19 | |
| 20 | **Guard-pass mode** (recommended): after code has been generated, edited, refactored, or fixed, check the diff or target files against the *Always-applied imperatives* below. Fix violations before presenting, committing, or merging the work. |
| 21 | |
| 22 | **Live mode** (explicit): when the user invokes this skill before a risky code edit, apply the same imperatives while writing, then run the *Self-check before delivery* checklist. If you violate any rule, fix it before showing the user. |
| 23 | |
| 24 | **Review mode** (triggered when the user asks you to review, audit, critique, or rate code): walk [references/review-checklist.md](references/review-checklist.md) against the target file(s) and produce a structured findings report. Do not edit code in review mode unless asked. |
| 25 | |
| 26 | Across all three modes, the rule bodies live in [references/](references/). Read the relevant reference file when: |
| 27 | - You hit a rule you don't fully remember the reasoning for. |
| 28 | - The user pushes back on a rule and you need the source citation. |
| 29 | - You're in review mode and need the full checklist. |
| 30 | - The code under review touches a specific principle (e.g., subclassing → [references/solid.md](references/solid.md); deduplication → [references/dry-kiss-yagni.md](references/dry-kiss-yagni.md)). |
| 31 | |
| 32 | The reference files are: |
| 33 | - [references/naming-and-functions.md](references/naming-and-functions.md) — names, function size, parameters, command/query separation. |
| 34 | - [references/comments-and-formatting.md](references/comments-and-formatting.md) — when to comment, when to delete, matching neighbor style. |
| 35 | - [references/solid.md](references/solid.md) — SRP, OCP, LSP, ISP, DIP with the modern phrasings and detection smells. |
| 36 | - [references/dry-kiss-yagni.md](references/dry-kiss-yagni.md) — knowledge vs code duplication, Sandi Metz's re-inline rule, McCabe complexity, Fowler's YAGNI cost categories. |
| 37 | - [references/ai-failure-modes.md](references/ai-failure-modes.md) — the 14 systematic ways LLMs produce bad code. **Read this one first if you are an AI agent reading this skill.** It is the highest-leverage file in the skill. |
| 38 | - [references/review-checklist.md](references/review-checklist.md) — structured walk-through for review mode. |
| 39 | - [references/sources.md](references/sources.md) — central bibliography for source URLs. Read it only when you need to verify or cite an external source. |
| 40 | |
| 41 | ## Examples |
| 42 | |
| 43 | - A coding agent implements an endpoint: use guard-pass mode on the diff before |
| 44 | the work is presented or committed. |
| 45 | - User asks "review this PR" or "should I merge this?": use review mode and |
| 46 | report findings from [references/review-checklist.md](references/review-checklist.md); do not edit unless |
| 47 | asked. |
| 48 | - User asks "implement this endpoint using clean-code-guard": use live mode |
| 49 | while writing, then run the self-check before delivery. |
| 50 | - User asks "refactor this function, same behavior |