# checks.md — Code Quality Pack --- ## Scope This pack audits source code for common quality issues: linting violations, formatting drift, unused imports, oversized methods and files, and unhandled error paths (empty catch blocks). It covers all languages for the language-agnostic checks (long-method, large-file, empty-catch-block) and JavaScript/TypeScript projects for the ESLint-based checks. The ESLint-based checks (eslint-violation, unused-import) use LLM detection; the worker agent may run `npx eslint` for advisory results, but does not rely on the spine's eslint wrapper (which is config-isolated to a fixed eval-rule surface under the `lint/*` namespace). This pack does NOT cover security vulnerabilities, dependency health, architectural patterns, or TypeScript/React-specific type checks — those belong in their respective packs. **Pack ID:** `ccgm/code-quality` **Applies when:** `always` --- ## applies_when Rationale | Condition | Reason | |-----------|--------| | `always` | Long-method, large-file, and empty-catch-block are language-agnostic structural smells detectable by the LLM in any codebase. The ESLint-based checks (eslint-violation, unused-import) use LLM detection and the worker agent scopes its eslint invocations to JS/TS files only, so running on all repos produces no false noise on non-JS codebases. | --- ## Checks --- ### `code-quality/eslint-violation` **Severity:** `medium` **Confidence:** `high` **Detection:** `llm` #### Detection The LLM agent scans JavaScript and TypeScript source files for common ESLint rule violations. The worker agent may run `npx eslint` (read-only, results advisory) on JS/TS files exactly as the original category prompt's agent did; however, the spine's eslint wrapper (`scripts/spine/wrap-eslint.sh`) is config-isolated via `--no-config-lookup` and runs only a narrow hardcoded eval-rule surface (`no-eval`, `no-implied-eval`, `no-new-func`), emitting findings under the `lint/*` namespace — it does NOT run these rule classes and does NOT emit `code-quality/eslint-violation` check IDs. Detection is therefore LLM-owned. **Tool (if detection = tool or hybrid):** n/a Rule / rule-id: n/a Fallback when tool absent: n/a (detection is always llm) **LLM instruction (if detection = llm or hybrid):** ``` READ AND APPLY: ~/.claude/skills/audit/reference/code-quality.md Use the code smell categories, thresholds, and severity guidelines from that file to inform your checks. Do not rely on memory — open and apply the file. READ AND APPLY: ~/.claude/skills/audit/reference/fix-patterns.md Use the Fix Type Reference table from that file to assign fix_type and fix_confidence to each finding. Do not rely on memory — open and apply the file. Scan JavaScript and TypeScript source files for common ESLint rule violations that are statically detectable. You may run `npx eslint` on JS/TS files for advisory results if the project has ESLint installed; treat its output as one signal among several. Rule classes to check (via LLM inspection of source files): - no-unused-vars: variables declared but never referenced (note: unused IMPORTS are reported separately under code-quality/unused-import) - no-console: console.log/warn/error left in production code - eqeqeq: == or != used instead of === or !== - no-var: var declarations instead of let/const - prefer-const: let declarations that are never reassigned For each finding report: file path, line number, the rule name, and the offending code snippet. Mark auto_fixable: true (eslint --fix resolves these mechanically). ``` #### Spine Wiring ```yaml check_id: code-quality/eslint-violation detection: llm ``` Note: the spine's `wrap-eslint.sh` runs only `no-eval` / `no-implied-eval` / `no-new-func` with `--no-config-lookup`, emitting findings under the `lint/*` namespace. It does NOT run the rule classes above and does NOT emit `code-quality/eslint-violation` IDs. Wave 2's reliability pack will wire eslint rules to the spine properly. #### Severity / Confidence **Severity rationale:** ESLint violations indicate code that breaks project-defined quality rules. Medium severity: violations create maintenance debt and can mask bugs, but do not typically cause immediate runtime failures on their own. **Confidence rationale:** The LLM covers common statically-detectable rule patterns (eqeqeq, no-var, prefer-const, no-console, no-unused-vars) with high reliability. High confidence. **Rubric entry:** `code-quality/eslint-violation` #### Fixture **True positive** (`src/utils/format.js`): ```js // FINDS: == used instead of === (eqeqeq violation) function isAdmin(role) { return role == 'admin'; } ``` **True negative** (should produce NO finding): ```js // OK: strict equality used function isAdmin(role) { return role === 'admin'; } ``` --- ### `code-quality/prettier-violation` **Severity:** `low` **Confidence:** `high` **Detection:** `llm` #### Detection The LLM agent checks for formatting inconsistencies against the project's Prettier configuration or common defaults. **Tool (if detection = tool or hybrid):** n/a Rule / rule-id: n/a Fallback when tool absent: llm **LLM instruction (if detection = llm or hybrid):** ``` READ AND APPLY: ~/.claude/skills/audit/reference/code-quality.md Use the code smell categories and formatting guidelines from that file to inform your checks. Do not rely on memory — open and apply the file. READ AND APPLY: ~/.claude/skills/audit/reference/fix-patterns.md Use the Fix Type Reference table from that file to assign fix_type and fix_confidence to each finding. Do not rely on memory — open and apply the file. Check JavaScript and TypeScript files for Prettier formatting violations. If a .prettierrc, prettier.config.js, or "prettier" key in package.json exists, use that configuration; otherwise assume Prettier defaults (2-space indent, double quotes, trailing commas in ES5 positions, 80-char print width). Look for: - Inconsistent indentation (tabs vs spaces, wrong indent width) - Lines exceeding the configured print width - Missing or extra trailing commas - Inconsistent quote style (single vs double) - Inconsistent semicolon usage Run: npx prettier --check . (if prettier is installed locally) If Prettier is not available, flag the most egregious formatting inconsistencies found by visual inspection of representative files. For each finding report: file path, line number or range, and description of the formatting violation. Mark auto_fixable: true (prettier --write resolves these). ``` #### Spine Wiring ```yaml check_id: code-quality/prettier-violation detection: llm ``` #### Severity / Confidence **Severity rationale:** Formatting violations are purely cosmetic and do not affect runtime behavior. Low severity: they create diff noise and review friction but pose no functional risk. **Confidence rationale:** Prettier's rules are deterministic given a config. When the LLM evaluates against explicit Prettier config, matches are precise. High confidence. **Rubric entry:** `code-quality/prettier-violation` #### Fixture **True positive** (`src/components/Button.tsx`): ```tsx // FINDS: inconsistent indentation (tabs used, project uses spaces) function Button({label}) { return } ``` **True negative** (should produce NO finding): ```tsx // OK: consistent 2-space indentation, double quotes, no missing semicolons function Button({ label }: { label: string }) { return ; } ``` --- ### `code-quality/unused-import` **Severity:** `low` **Confidence:** `high` **Detection:** `llm` #### Detection The LLM agent scans JavaScript and TypeScript source files for import or require statements where the imported binding is never referenced in the file body. The spine's eslint wrapper accepts no per-pack rules; `no-unused-vars` never runs in the spine's eslint surface. Detection is therefore LLM-owned. **Tool (if detection = tool or hybrid):** n/a Rule / rule-id: n/a Fallback when tool absent: n/a (detection is always llm) **LLM instruction (if detection = llm or hybrid):** ``` READ AND APPLY: ~/.claude/skills/audit/reference/code-quality.md Use the code smell categories and severity guidelines from that file to inform your checks. Do not rely on memory — open and apply the file. READ AND APPLY: ~/.claude/skills/audit/reference/fix-patterns.md Use the Fix Type Reference table from that file to assign fix_type and fix_confidence to each finding. Do not rely on memory — open and apply the file. Scan JavaScript and TypeScript source files for import or require statements where the imported binding is never referenced in the file body. This includes: - Named imports: import { Foo } from './foo' where Foo is never used - Default imports: import Bar from './bar' where Bar is never used - Namespace imports: import * as Baz from './baz' where Baz is never used - CommonJS: const { x } = require('./x') where x is never used Do NOT flag: - Type-only imports used only as type annotations (import type { ... }) - Re-exports: export { Foo } from './foo' - Imports used in JSX (e.g. React import in older React) For each finding report: file path, line number, the unused binding name, and the import statement. Mark auto_fixable: true (eslint --fix removes these). ``` #### Spine Wiring ```yaml check_id: code-quality/unused-import detection: llm ``` Note: the spine's `wrap-eslint.sh` accepts no per-pack rule configuration; `no-unused-vars` never runs in the spine's eslint surface. The LLM agent handles this check directly. #### Severity / Confidence **Severity rationale:** Unused imports are dead code that inflate bundle size and create confusion about what a file depends on. Low severity: they add noise but do not cause runtime errors in most cases. **Confidence rationale:** Static analysis of import/use pairs is straightforward. LLM-based scanning produces precise results for this pattern. High confidence. **Rubric entry:** `code-quality/unused-import` #### Fixture **True positive** (`src/pages/Dashboard.tsx`): ```tsx // FINDS: Spinner is imported but never referenced below import React from 'react'; import { Spinner } from '../components/Spinner'; export function Dashboard() { return