clean-code-guard
Review 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 merging the result. Use when the user asks "review this PR", "is this safe to merge?", "make this cleaner", "audit this code", "refactor this", "fix this bug", or after a coding agent produced implementation code. Can also guide writing when explicitly invoked before a risky edit. Invoke it on your own initiative the moment you finish writing, editing, or refactoring non-trivial production code, before presenting or committing — don't wait to be asked. DO NOT USE for factual/conceptual questions, CI/tooling config, git workflow, running/debugging tests, pure architecture discussion, prose writing, data analysis, or test-code review (use test-guard).
Choose how to use this skill
You do not need every option. Choose the path your AI client supports. The stable page stays the same; versioned files are immutable.
1. Native installer
This listing has no registered native installer command. Use the complete package or source fallback below, depending on what your client supports.
Do not guess an installer command or replace an existing version without reviewing the diff.
2. Complete package recommended
Download the ZIP when available. It includes SKILL.md plus the references, security notes and version metadata.
No complete ProSkills package is published for this listing yet.3. Prompt-only
Copy the prompt above when the agent can read the stable page or when you want to adopt the workflow without installing a skill.
Need only the instruction file?
Download SKILL.md only if your client requires a single file. The complete ZIP is safer for a full installation because it preserves the references and release context.
No path installs or executes anything by itself. Your agent still needs access to the project files. Before updating, compare the installed version and review the diff.
// RATINGS
Not yet listed on ClawHub or SkillsMP
// README
guard-skills
Focused guard skills for coding agents: second-pass quality gates that catch the systematic failure modes of AI-generated code, tests, and docs before they ship.
Best use: let your agent do the work, then invoke the relevant guard on the diff before you present, commit, or merge it. These skills can guide writing when you explicitly ask for that, but they are strongest as reactive review passes.
Install
Browse the package first:
npx skills add amElnagdy/guard-skills --list
Install the package:
npx skills add amElnagdy/guard-skills
Or install one guard:
npx skills add amElnagdy/guard-skills --skill clean-code-guard
npx skills add amElnagdy/guard-skills --skill test-guard
npx skills add amElnagdy/guard-skills --skill docs-guard
npx skills add amElnagdy/guard-skills --skill wp-guard
npx skills add amElnagdy/guard-skills --skill woo-guard
Install for a specific agent:
npx skills add amElnagdy/guard-skills --skill clean-code-guard --agent codex
npx skills add amElnagdy/guard-skills --skill test-guard --agent claude-code
npx skills add amElnagdy/guard-skills --skill '*' --agent cursor
Install globally:
npx skills add amElnagdy/guard-skills --global
Works with Claude Code, Codex, Cursor, OpenCode, and other supported agents via the Skills CLI.
Updating
Skills install as a copy, so a new version here does not reach your agent until you update. Refresh them with the Skills CLI:
npx skills update # all installed skills (alias: upgrade)
npx skills update clean-code-guard
Add --global for global installs or --project for project installs. Re-running npx skills add amElnagdy/guard-skills also re-fetches the latest.
How to use them
Run a guard after your agent produces work:
Use $clean-code-guard on the diff you just produced.
Use $test-guard on the tests you just wrote.
Use $docs-guard on this README update before we ship it.
Use $wp-guard on this WordPress plugin change.
Use $woo-guard on this WooCommerce checkout change.
Use a guard up front only when you want that constraint active while writing:
Use $wp-guard while implementing this REST endpoint, then self-check before delivery.
Which guard to run
| Guard | Use after the agent changed | Catches | Pair with |
|---|---|---|---|
clean-code-guard | Production code in any language | LLM code smells, over-abstraction, broad error swallowing, bad names, SOLID/DRY/KISS/YAGNI violations | Platform-specific guards |
test-guard | Test code | Mock abuse, duplicate tests, implementation-detail assertions, tests that catch nothing | clean-code-guard when test helpers contain real logic |
docs-guard | READMEs, docstrings, API docs, changelogs, tutorials | Hallucinated symbols, broken samples, docs-vs-code drift, unverifiable claims | Any guard whose behavior is documented |
wp-guard | WordPress plugin, theme, block, REST, AJAX, shortcode, query, or WP-CLI code | Escaping, sanitization, nonces, capabilities, prepared queries, i18n, query/caching mistakes | clean-code-guard; woo-guard when Woo APIs appear |
woo-guard | WooCommerce extension, checkout, order, product, gateway, shipping, or HPOS code | Direct order meta, HPOS breakage, missing compatibility declarations, checkout bypasses, money errors | wp-guard for the WordPress layer |
The skills
clean-code-guard
Applies Clean Code, SOLID, DRY/KISS/YAGNI to generated or changed code in any language, plus an AI-specific layer most rule packs miss: catch-all error swallowing, hardcoded "success" returns, hallucinated APIs, premature abstraction, comment pollution, and copy-from-similar bugs.
Why the AI layer matters: the skill references published research on duplication growth, package hallucination, and agents declaring success despite failed tests.
You'll feel it when: your agent refactors without silently changing behavior, asks before changing a contract, justifies what it deliberately left out, and stops wrapping everything in try/catch -> return ok.
test-guard
A quality gate for generated or changed test code in any language: pytest, PHPUnit/Pest, Jest/Vitest, Go tests, WordPress/WooCommerce tests, and more. Nine universal rules catch AI test bloat: mock only at system boundaries, never mock your own state objects, parametrize instead of copy-pasting, delete tests that catch nothing, and treat production regression tests as sacred.
Framework specifics live in progressive-disclosure references the agent loads only when relevant, including a dedicated reference for LLM applications.
You'll feel it when: a generated test file with MagicMock() state, duplicated test bodies, and log-message assertions comes back as "do not merge" with rule-by-rule fixes.
docs-guard
A documentation accuracy gate for READMEs, API references, docstrings, PHPDoc/JSDoc, changelogs, and tutorials. Its core move: treat documentation as a list of claims and verify every one against the codebase.
You'll feel it when: a generated README stops referencing functions that do not exist, @param tags match the real signature, samples run on a clean machine, and "blazingly fast" leaves the building.
wp-guard
A WordPress shipping guard for generated or changed plugins, themes, blocks, REST endpoints, AJAX handlers, shortcodes, WP-CLI commands, and queries. It enforces the layer generic clean-code guidance misses: escaping and sanitization, nonce plus capability checks, prepared database queries, core APIs before custom plumbing, translation-ready strings, and query/caching discipline.
You'll feel it when: a generated plugin stops echoing raw request data, a writing REST route gets a real permission callback, every string ships translation-ready, and a million-row site does not get handed posts_per_page => -1.
woo-guard
A WooCommerce shipping guard for generated or changed extensions, payment and shipping integrations, checkout customizations, and order/product logic. It sits on top of wp-guard and enforces what is WooCommerce-specific: HPOS-safe order access, CRUD over direct meta, truthful feature-compatibility declarations, server-side checkout validation, money-handling discipline, and hooks over template overrides.
You'll feel it when: order code survives HPOS, stock updates stop racing, checkout rules hold without JavaScript, and '$' . $amount never reaches a store that sells in dirhams.
How this differs
This is not a full process framework and not a broad platform catalog. Repos like WordPress/agent-skills teach agents how to build across the WordPress ecosystem. guard-skills is narrower: it gives agents review gates to run after they have produced work, so common AI failure modes get caught before the work reaches your repo.
Repository shape
Each skill is a folder with a SKILL.md entrypoint, lightweight agent metadata, and progressive-disclosure references:
skills/
├── clean-code-guard/
│ ├── SKILL.md
│ ├── agents/openai.yaml
│ └── references/
├── docs-guard/
│ ├── SKILL.md
│ ├── agents/openai.yaml
│ └── references/
├── test-guard/
│ ├── SKILL.md
│ ├── agents/openai.yaml
│ └── references/
├── woo-guard/
│ ├── SKILL.md
│ ├── agents/openai.yaml
│ └── references/
└── wp-guard/
├── SKILL.md
├── agents/openai.yaml
└── references/
The SKILL.md stays small so it loads cheaply; deeper guidance loads only when the task needs it.
Trust and validation
This package is intentionally inspectable:
- Skill content is Markdown plus lightweight
agents/openai.yamlmetadata. - There are no executable scripts, network calls, MCP server dependencies, or credentials.
- External source UR
// HOW IT'S BUILT
// FILES
2 files shipped with this skill. Inline text is the catalog copy. The upstream link is the source repository.
skills/clean-code-guard/SKILL.md7.8 KBupstream ↗
--- name: clean-code-guard description: Review 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 merging the result. Use when the user asks "review this PR", "is this safe to merge?", "make this cleaner", "audit this code", "refactor this", "fix this bug", or after a coding agent produced implementation code. Can also guide writing when explicitly invoked before a risky edit. Invoke it on your own initiative the moment you finish writing, editing, or refactoring non-trivial production code, before presenting or committing — don't wait to be asked. DO NOT USE for factual/conceptual questions, CI/tooling config, git workflow, running/debugging tests, pure architecture discussion, prose writing, data analysis, or test-code review (use test-guard). --- # clean-code-guard 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. ## Compatibility This is a portable instruction skill. It requires no MCP server, network access, API key, shell command, local executable, or bundled script. It can be used in any runtime that supports `SKILL.md` plus directly linked [references/](references/) files; `agents/openai.yaml` is lightweight display metadata. This skill does not replace project linters, formatters, type checkers, or test runners. Use the project's own tools for mechanical verification; use this skill for the judgement layer around code quality and review. ## How to use this skill This skill has three modes — pick based on the user's request. **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. **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. **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. Across all three modes, the rule bodies live in [references/](references/). Read the relevant reference file when: - You hit a rule you don't fully remember the reasoning for. - The user pushes back on a rule and you need the source citation. - You're in review mode and need the full checklist. - 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)). The reference files are: - [references/naming-and-functions.md](references/naming-and-functions.md) — names, function size, parameters, command/query separation. - [references/comments-and-formatting.md](references/comments-and-formatting.md) — when to comment, when to delete, matching neighbor style. - [references/solid.md](references/solid.md) — SRP, OCP, LSP, ISP, DIP with the modern phrasings and detection smells. - [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. - [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. - [references/review-checklist.md](references/review-checklist.md) — structured walk-through for review mode. - [references/sources.md](references/sources.md) — central bibliography for source URLs. Read it only when you need to verify or cite an external source. ## Examples - A coding agent implements an endpoint: use guard-pass mode on the diff before the work is presented or committed. - User asks "review this PR" or "should I merge this?": use review mode and report findings from [references/review-checklist.md](references/review-checklist.md); do not edit unless asked. - User asks "implement this endpoint using clean-code-guard": use live mode while writing, then run the self-check before delivery. - User asks "refactor this function, same behavior": preserve observable behavior exactly and treat any bug fix as a separate change. ## Success criteria This skill is working when code-writing tasks avoid the listed failure modes, code-review tasks produce prioritized findings with concrete evidence, and refactors preserve behavior unless the user explicitly asks for a behavior change. It should stay silent for conceptual, CI, git workflow, prose, data analysis, and test-running tasks covered by the frontmatter exclusions. ## Why this skill exists LLM-generated code has measurable, systematic failure modes that generic "follow clean code" instructions do not catch. Examples backed by published research: - **Code duplication grew 8x** in tracked codebases between 2021 and 2024 (GitClear 2025 report). - **Package hallucination rate averages 19.6%** across 16 models (Spracklen et al., USENIX Security '25). - LLMs often wrap risky operations in broad catch-all handlers that swallow errors (Karpathy). - AI agents **"declare success despite failing tests"** by returning hardcoded fixture values (Fowler, Patterns for Reducing Friction). - Function size grew from 142 to 267 LoC, cyclomatic complexity from 4.2 to 8.1 in AI-assisted commits (GitClear). The classic principles (Clean Code, SOLID, DRY/KISS/YAGNI) are still the foundation — but this skill adds the *AI-specific* layer most rule packs miss. ## Always-applied imperatives These are the rules to follow on every code change. They are imperative, not suggestions. ### Functions and names 1. **Names reveal intent.** Never use `data`, `data2`, `result`, `result_final`, `item`, `temp`, `value`, `obj`, `info`, `helper`, `manager`, `utils`, or `handle_*`/`process_*`/`do_*` without a qualifier. A name must answer *why it exists and what it does*. (Clean Code Ch. 2) 2. **Functions stay small.** Target ≤20 lines, one level of abstraction, one thing. If you can extract a function with a name that doesn't restate the body, the parent was doing more than one thing. (Clean Code Ch. 3) 3. **Four arguments is the hard ceiling.** At five, stop and introduce a request/config object (record, struct, DTO, or equivalent). Never use boolean flag arguments — split into two functions instead. 4. **No output arguments.** A function either returns a value (query) or has a side effect (command). Never both. Command names use verbs; query names use nouns or getter-style names. (CQS) ### Comments and structure 5. **Comments explain *why*, never *what*.** Delete any comment that paraphrases the line below it. Delete step-number scaffolding comments. Delete commented-out code — version control exists. (Clean Code Ch. 4) 6. **Match the file's existing style.** Read the file you're editing and at least one neighbor before writing. Mirror the casing, import order, error handling, logging, and HTTP/DB client choices. Do not introduce a second pattern. ### SOLID 7. **One actor per module.** A class should be answerable to one stakeholder group (Accounting, Auth, RepoREADME.mdupstream ↗
Contents are not inlined in the catalog. Open the upstream file.
Plain-text copy, no login: /skill-bundles/amelnagdy-guard-skills-skills-clean-code-guard.md