$npx -y skills add fusengine/agents --skill code-qualityCode quality validation with linters, SOLID principles, DRY detection, error detection, and architecture compliance across all languages. Use when: validating code quality after modifications — SOLID compliance, DRY duplication, linter errors, or architecture violations. Do NOT u
| 1 | # Code Quality Skill |
| 2 | |
| 3 | Canonical workflow definition: `agents/sniper.md` (this skill and the sniper agent share the same 7-phase workflow — update both together). |
| 4 | |
| 5 | ## 🚨 MANDATORY 7-PHASE WORKFLOW |
| 6 | |
| 7 | ``` |
| 8 | PHASE 1: Exploration (explore-codebase) → BLOCKER |
| 9 | PHASE 2: Documentation (research-expert) → BLOCKER |
| 10 | PHASE 3: Impact Analysis (Grep usages) → BLOCKER |
| 11 | PHASE 3.5: DRY Detection (jscpd duplication) → NON-BLOCKING |
| 12 | PHASE 4: Error Detection (linters) |
| 13 | PHASE 5: Precision Correction (with docs + impact + DRY) |
| 14 | PHASE 6: Verification (re-run linters, tests, duplication) |
| 15 | ``` |
| 16 | |
| 17 | **CRITICAL**: Phases 1-3 are BLOCKERS. Never skip them. |
| 18 | **DRY**: Phase 3.5 is non-blocking but findings inform Phase 5 corrections. |
| 19 | |
| 20 | --- |
| 21 | |
| 22 | ## PHASE 1: Architecture Exploration |
| 23 | |
| 24 | **Launch explore-codebase agent FIRST**: |
| 25 | ``` |
| 26 | > Agent(subagent_type="fuse-ai-pilot:explore-codebase", prompt="...") |
| 27 | ``` |
| 28 | |
| 29 | **Gather**: |
| 30 | 1. Programming language(s) detected |
| 31 | 2. Existing linter configs (.eslintrc, .prettierrc, pyproject.toml) |
| 32 | 3. Package managers and installed linters |
| 33 | 4. Project structure and conventions |
| 34 | 5. Framework versions (package.json, go.mod, Cargo.toml) |
| 35 | 6. Architecture patterns (Clean, Hexagonal, MVC) |
| 36 | 7. State management (Zustand, Redux, Context) |
| 37 | 8. Interface/types directories location |
| 38 | |
| 39 | --- |
| 40 | |
| 41 | ## PHASE 2: Documentation Research |
| 42 | |
| 43 | **Launch research-expert agent**: |
| 44 | ``` |
| 45 | > Agent(subagent_type="fuse-ai-pilot:research-expert", prompt="Verify [library/framework] documentation for [error type]. Find [language] best practices for [specific issue].") |
| 46 | ``` |
| 47 | |
| 48 | **Request for each error**: |
| 49 | - Official API documentation |
| 50 | - Current syntax and deprecations |
| 51 | - Best practices for error patterns |
| 52 | - Version-specific breaking changes |
| 53 | - Security advisories |
| 54 | - Language-specific SOLID patterns |
| 55 | |
| 56 | --- |
| 57 | |
| 58 | ## PHASE 3: Impact Analysis |
| 59 | |
| 60 | **For EACH element to modify**: Grep usages → assess risk → document impact. |
| 61 | |
| 62 | | Risk | Criteria | Action | |
| 63 | |------|----------|--------| |
| 64 | | 🟢 LOW | Internal, 0-1 usages | Proceed | |
| 65 | | 🟡 MEDIUM | 2-5 usages, compatible | Proceed with care | |
| 66 | | 🔴 HIGH | 5+ usages OR breaking | Flag to user FIRST | |
| 67 | |
| 68 | --- |
| 69 | |
| 70 | ## PHASE 3.5: Code Duplication Detection (DRY) |
| 71 | |
| 72 | **Tool**: `jscpd` — 150+ languages — `npx jscpd ./src --threshold 5 --reporters console,json` |
| 73 | |
| 74 | | Level | Threshold | Action | |
| 75 | |-------|-----------|--------| |
| 76 | | 🟢 Excellent | < 3% | No action needed | |
| 77 | | 🟡 Good | 3-5% | Document, fix if time | |
| 78 | | 🟠 Acceptable | 5-10% | Extract shared logic | |
| 79 | | 🔴 Critical | > 10% | Mandatory refactoring | |
| 80 | |
| 81 | See [references/duplication-thresholds.md](references/duplication-thresholds.md) for per-language thresholds, config, and extraction patterns. |
| 82 | See [references/linter-commands.md](references/linter-commands.md) for language-specific jscpd commands. |
| 83 | |
| 84 | --- |
| 85 | |
| 86 | ## Linter Commands |
| 87 | See [references/linter-commands.md](references/linter-commands.md) for language-specific commands. |
| 88 | |
| 89 | --- |
| 90 | |
| 91 | ## Error Priority Matrix |
| 92 | |
| 93 | | Priority | Type | Examples | Action | |
| 94 | |----------|------|----------|--------| |
| 95 | | **Critical** | Security | SQL injection, XSS, CSRF, auth bypass | Fix IMMEDIATELY | |
| 96 | | **High** | Logic | SOLID violations, memory leaks, race conditions | Fix same session | |
| 97 | | **High** | DRY | Code duplication > 10%, copy-paste logic blocks | Mandatory refactoring | |
| 98 | | **Medium** | DRY | Code duplication 5-10%, repeated patterns | Extract shared logic | |
| 99 | | **Medium** | Performance | N+1 queries, deprecated APIs, inefficient algorithms | Fix if time | |
| 100 | | **Low** | Style | Formatting, naming, missing docs | Fix if time | |
| 101 | |
| 102 | --- |
| 103 | |
| 104 | ## SOLID Validation |
| 105 | See [references/solid-validation.md](references/solid-validation.md) for S-O-L-I-D detection patterns and fix examples. |
| 106 | |
| 107 | --- |
| 108 | |
| 109 | ## File Size Rules |
| 110 | See [references/file-size-rules.md](references/file-size-rules.md) for LoC limits, calculation, and split strategies. |
| 111 | |
| 112 | --- |
| 113 | |
| 114 | ## Architecture Rules |
| 115 | See [references/architecture-patterns.md](references/architecture-patterns.md) for project structures and patterns. |
| 116 | |
| 117 | --- |
| 118 | |
| 119 | ## Validation Report Format |
| 120 | See [references/validation-report.md](references/validation-report.md) for the complete sniper report template. |
| 121 | |
| 122 | --- |
| 123 | |
| 124 | ## Complete Workflow Example |
| 125 | See [references/examples.md](references/examples.md) for detailed walkthrough. |
| 126 | |
| 127 | --- |
| 128 | |
| 129 | ## Forbidden Behaviors |
| 130 | |
| 131 | ### Workflow Violations |
| 132 | - ❌ Skip PHASE 1 (explore-codebase) |
| 133 | - ❌ Skip PHASE 2 (research-expert) |
| 134 | - ❌ Skip PHASE 3 (impact analysis) |
| 135 | - ❌ Skip PHASE 3.5 (DRY detection) |
| 136 | - ❌ Jump to corrections without completing Phases 1-3 |
| 137 | - ❌ Proceed when BLOCKER is active |
| 138 | |
| 139 | ### Code Qualit |