$npx -y skills add One-Man-Company/Skills-ContextManager --skill clean-codePragmatic coding standards - concise, direct, no over-engineering, no unnecessary comments
| 1 | # Clean Code - Pragmatic AI Coding Standards |
| 2 | |
| 3 | > **CRITICAL SKILL** - Be **concise, direct, and solution-focused**. |
| 4 | |
| 5 | --- |
| 6 | |
| 7 | ## Core Principles |
| 8 | |
| 9 | | Principle | Rule | |
| 10 | |-----------|------| |
| 11 | | **SRP** | Single Responsibility - each function/class does ONE thing | |
| 12 | | **DRY** | Don't Repeat Yourself - extract duplicates, reuse | |
| 13 | | **KISS** | Keep It Simple - simplest solution that works | |
| 14 | | **YAGNI** | You Aren't Gonna Need It - don't build unused features | |
| 15 | | **Boy Scout** | Leave code cleaner than you found it | |
| 16 | |
| 17 | --- |
| 18 | |
| 19 | ## Naming Rules |
| 20 | |
| 21 | | Element | Convention | |
| 22 | |---------|------------| |
| 23 | | **Variables** | Reveal intent: `userCount` not `n` | |
| 24 | | **Functions** | Verb + noun: `getUserById()` not `user()` | |
| 25 | | **Booleans** | Question form: `isActive`, `hasPermission`, `canEdit` | |
| 26 | | **Constants** | SCREAMING_SNAKE: `MAX_RETRY_COUNT` | |
| 27 | |
| 28 | > **Rule:** If you need a comment to explain a name, rename it. |
| 29 | |
| 30 | --- |
| 31 | |
| 32 | ## Function Rules |
| 33 | |
| 34 | | Rule | Description | |
| 35 | |------|-------------| |
| 36 | | **Small** | Max 20 lines, ideally 5-10 | |
| 37 | | **One Thing** | Does one thing, does it well | |
| 38 | | **One Level** | One level of abstraction per function | |
| 39 | | **Few Args** | Max 3 arguments, prefer 0-2 | |
| 40 | | **No Side Effects** | Don't mutate inputs unexpectedly | |
| 41 | |
| 42 | --- |
| 43 | |
| 44 | ## Code Structure |
| 45 | |
| 46 | | Pattern | Apply | |
| 47 | |---------|-------| |
| 48 | | **Guard Clauses** | Early returns for edge cases | |
| 49 | | **Flat > Nested** | Avoid deep nesting (max 2 levels) | |
| 50 | | **Composition** | Small functions composed together | |
| 51 | | **Colocation** | Keep related code close | |
| 52 | |
| 53 | --- |
| 54 | |
| 55 | ## AI Coding Style |
| 56 | |
| 57 | | Situation | Action | |
| 58 | |-----------|--------| |
| 59 | | User asks for feature | Write it directly | |
| 60 | | User reports bug | Fix it, don't explain | |
| 61 | | No clear requirement | Ask, don't assume | |
| 62 | |
| 63 | --- |
| 64 | |
| 65 | ## Anti-Patterns (DON'T) |
| 66 | |
| 67 | | ❌ Pattern | ✅ Fix | |
| 68 | |-----------|-------| |
| 69 | | Comment every line | Delete obvious comments | |
| 70 | | Helper for one-liner | Inline the code | |
| 71 | | Factory for 2 objects | Direct instantiation | |
| 72 | | utils.ts with 1 function | Put code where used | |
| 73 | | "First we import..." | Just write code | |
| 74 | | Deep nesting | Guard clauses | |
| 75 | | Magic numbers | Named constants | |
| 76 | | God functions | Split by responsibility | |
| 77 | |
| 78 | --- |
| 79 | |
| 80 | ## 🔴 Before Editing ANY File (THINK FIRST!) |
| 81 | |
| 82 | **Before changing a file, ask yourself:** |
| 83 | |
| 84 | | Question | Why | |
| 85 | |----------|-----| |
| 86 | | **What imports this file?** | They might break | |
| 87 | | **What does this file import?** | Interface changes | |
| 88 | | **What tests cover this?** | Tests might fail | |
| 89 | | **Is this a shared component?** | Multiple places affected | |
| 90 | |
| 91 | **Quick Check:** |
| 92 | ``` |
| 93 | File to edit: UserService.ts |
| 94 | └── Who imports this? → UserController.ts, AuthController.ts |
| 95 | └── Do they need changes too? → Check function signatures |
| 96 | ``` |
| 97 | |
| 98 | > 🔴 **Rule:** Edit the file + all dependent files in the SAME task. |
| 99 | > 🔴 **Never leave broken imports or missing updates.** |
| 100 | |
| 101 | --- |
| 102 | |
| 103 | ## Summary |
| 104 | |
| 105 | | Do | Don't | |
| 106 | |----|-------| |
| 107 | | Write code directly | Write tutorials | |
| 108 | | Let code self-document | Add obvious comments | |
| 109 | | Fix bugs immediately | Explain the fix first | |
| 110 | | Inline small things | Create unnecessary files | |
| 111 | | Name things clearly | Use abbreviations | |
| 112 | | Keep functions small | Write 100+ line functions | |
| 113 | |
| 114 | > **Remember: The user wants working code, not a programming lesson.** |
| 115 | |
| 116 | --- |
| 117 | |
| 118 | ## 🔴 Self-Check Before Completing (MANDATORY) |
| 119 | |
| 120 | **Before saying "task complete", verify:** |
| 121 | |
| 122 | | Check | Question | |
| 123 | |-------|----------| |
| 124 | | ✅ **Goal met?** | Did I do exactly what user asked? | |
| 125 | | ✅ **Files edited?** | Did I modify all necessary files? | |
| 126 | | ✅ **Code works?** | Did I test/verify the change? | |
| 127 | | ✅ **No errors?** | Lint and TypeScript pass? | |
| 128 | | ✅ **Nothing forgotten?** | Any edge cases missed? | |
| 129 | |
| 130 | > 🔴 **Rule:** If ANY check fails, fix it before completing. |
| 131 | |
| 132 | --- |
| 133 | |
| 134 | ## Verification Scripts (MANDATORY) |
| 135 | |
| 136 | > 🔴 **CRITICAL:** Each agent runs ONLY their own skill's scripts after completing work. |
| 137 | |
| 138 | ### Agent → Script Mapping |
| 139 | |
| 140 | | Agent | Script | Command | |
| 141 | |-------|--------|---------| |
| 142 | | **frontend-specialist** | UX Audit | `python .agent/skills/frontend-design/scripts/ux_audit.py .` | |
| 143 | | **frontend-specialist** | A11y Check | `python .agent/skills/frontend-design/scripts/accessibility_checker.py .` | |
| 144 | | **backend-specialist** | API Validator | `python .agent/skills/api-patterns/scripts/api_validator.py .` | |
| 145 | | **mobile-developer** | Mobile Audit | `python .agent/skills/mobile-design/scripts/mobile_audit.py .` | |
| 146 | | **database-architect** | Schema Validate | `python .agent/skills/database-design/scripts/schema_validator.py .` | |
| 147 | | **security-auditor** | Security Scan | `python .agent/skills/vulnerability-scanner/scripts/security_scan.py .` | |
| 148 | | **seo-specialist** | SEO Check | `python .agent/skills/seo-fundamentals/scripts/seo_checker.py .` | |
| 149 | | **seo-specialist** | GEO Check | `python .agent/skills/geo-fundamentals/scripts/geo_checker.py .` | |
| 150 | | **performance-optimizer** | Lighthouse | `python .ag |