Linter-Driven Development Workflow (TypeScript + React)
DEFAULT ENTRY POINT: This skill should be automatically invoked for ALL code changes when the plugin is enabled.
META ORCHESTRATOR for implementation workflow: design → test → lint → refactor → review → commit.
Use for any commit: features, bug fixes, refactors.
Auto-Invocation
When this plugin is enabled in a project, this skill is the default workflow for:
- New feature implementation
- Bug fixes
- Refactoring
- Any code change that should result in a commit
The CLAUDE.md file at the plugin root enforces this automatic invocation.
Core Principles
CRITICAL - Read Before Starting:
Never Disable Rules by Default
- DO NOT add
eslint-disable, @ts-ignore, @ts-expect-error, or similar comments without explicit user approval
- ALWAYS strive to fix the underlying issue through refactoring, not by suppressing warnings
- ONLY disable rules as an absolute last resort when no other solution exists, and always ask user first
- When approved: Add a comment explaining WHY the rule is disabled
Fix, Don't Suppress
- Linter warnings exist for good reasons - they indicate real issues
- Use @refactoring patterns to address complexity and code quality issues
- If a rule seems wrong for the project, discuss with user rather than silently disabling
Clean Code at Every Step
- All checks must pass without suppressions before commit
- Tests pass, linter passes, types pass - no exceptions
Prerequisites
IMPORTANT: Before using this skill, the project MUST have linter configurations:
Required Configurations
TypeScript (tsconfig.json)
- Type checking configured for your project
ESLint (eslint.config.mjs or .eslintrc.js)
- Must include
eslint-plugin-sonarjs for complexity metrics
- Recommended: TypeScript ESLint, React plugins
- Complexity thresholds: cognitive, cyclomatic, expression
Prettier (.prettierrc.json or prettier.config.js or .prettierrc)
- Consistent formatting rules defined
- Integration with ESLint recommended
Stylelint (stylelint.config.js) - if using CSS/SCSS
- CSS/SCSS linting rules configured
Required npm Scripts
Project must have scripts for running quality checks. Script names vary by project - detect them from package.json.
Common patterns to look for:
- Testing:
test, test:unit, vitest, jest
- Type checking:
typecheck, type-check, tsc, check-types
- Linting (check):
lint, lint:check, eslint, lintcheck
- Linting (fix):
lint:fix, eslint:fix, lint --fix
- Formatting (check):
format, format:check, prettier:check, formatcheck
- Formatting (fix):
format:fix, prettier:write, prettier --write
- Styling (check):
stylelint, style:check, stylecheck
- Styling (fix):
stylelint:fix, style:fix
- Combined check:
check, checkall, validate, verify
- Combined fix:
fix, fixall, format:all
Detection strategy: Read package.json scripts and identify which commands serve each purpose.
Step 0: Detect Project Setup
FIRST STEP - Do this before starting any workflow:
Detect Package Manager
- Check for lock files in project root:
yarn.lock → Use yarn commands
package-lock.json or npm-shrinkwrap.json → Use npm commands
pnpm-lock.yaml → Use pnpm commands
- No lock file → Ask user which package manager to use
Detect Available Scripts
- Read
package.json scripts section
- Identify which scripts exist for each purpose:
- Type checking (e.g.,
typecheck, type-check, tsc)
- Linting check (e.g.,
lint, eslint, lint:check)
- Linting fix (e.g.,
lint:fix, eslint:fix)
- Formatting check (e.g.,
format:check, prettier:check)
- Formatting fix (e.g.,
format:fix, prettier:write)
- Testing (e.g.,
test, vitest, jest)
- Combined checks (e.g.,
check, checkall, validate)
- Combined fixes (e.g.,
fix, fixall)
Build Command Map
- Store detected commands for use throughout workflow
- Example:
{ typecheck: 'typecheck', lint: 'lint', lintFix: 'lint:fix', test: 'test' }
Remember: Use detected package manager + detected script names consistently throughout ALL workflow phases.
Verification
Before starting, verify setup by running detected commands:
If scripts are missing:
- Check if functionality exists but with different script name
- Look for combined commands (e.g.,
check that runs multiple tools)
- If truly missing, ask user:
- "What command should I run to check/fix linting?"
- "Where is this documented?" (suggest adding to README.md or CLAUDE.md)
- If no script exists, run tool directly (e.g.,
eslint .) or skip that phase
Command detection examples:
# If package.json has:
"scripts": {
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"check": "tsc && eslint .",
"test": "vitest"
}
# Detected commands:
typecheck: (not found, will run 'tsc' directly)
lint: 'lint'
lintFix: 'lint:fix'
test: 'test'
combined: 'check'
When to Use
- Implementing any code change that should result in a commit
- Need automatic workflow management with quality gates
- Want to ensure: clean code + tests + linting + design validation + accessibility
Workflow Phases
IMPORTANT: Start every workflow by detecting the package manager (Step 0 in Prerequisites).
Phase 1: Design (if needed)
- If new components/types/major changes needed → invoke @component-designing skill
- Output: Component design plan with types, hooks, and structure
Phase 2: Implementation
- Follow @testing skill principles (React Testing Library with Jest/Vitest)
- Write tests + implementation in parallel (not necessarily test-first)
- Follow project's Prettier/ESLint formatting rules
- Use project's test runner (Jest, Vitest, or other)
- Aim for 100% coverage on new leaf components/hooks (pure logic with no external dependencies)
- Leaf types: Pure logic (can compose other leaf types), no API/DB/file system access
- Orchestrating types: Coordinate leaf types and external systems, need integration tests
- Test from user perspective (public API only)
Phase 3: Linter Loop
Use detected package manager and script names from Step 0 for all commands below.
Run quality checks in this order (using detected script names from package.json):
- Type Check: Run detected typecheck script (look for:
typecheck, type-check, tsc)
- Lint Check: Run detected lint check script (look for:
lint, lint:check, eslint)
- Format Check: Run detected format check script (look for:
format:check, prettier:check)
- Style Check: Run detected style check script (look for:
stylelint, style:check) - if CSS/SCSS in project
Handling missing scripts:
- If type check script not found → Run
tsc --noEmit directly
- If lint check script not found → Run
eslint . directly
- If format check script not found → Run
prettier --check . directly
- If style check script not found and CSS/SCSS exists → Skip if Stylelint not installed
If any failures detected:
- Run auto-fixes using detected fix scripts:
- Lint fix: Run detected lint fix script (look for:
lint:fix, eslint:fix)
- Format fix: Run detected format fix script (look for:
format:fix, prettier:write)
- Style fix: Run detected style fix script (look for:
stylelint:fix, style:fix)
- Re-run quality checks
- If still failing (complexity, design issues):
- NEVER disable linter rules by default: Do NOT add
eslint-disable, @ts-ignore, @ts-expect-error, or similar comments unless explicitly approved by the user
- Always fix, not disable: Strive to fix the underlying issue through refactoring, not by suppressing warnings
- Only disable as last resort: If absolutely necessary and no other solution exists, ask user for explicit approval before disabling any rule
- When approved: Add a comment explaining WHY the rule is disabled
- Interpret failures (cognitive complexity, cyclomatic complexity, etc.)
- Invoke @refactoring skill to fix (use storifying, extract functions/hooks, early returns)
- Check for existing utilities: Before creating new helpers, check if type guards, utilities, or constants already exist in the codebase
- Avoid repeated
typeof checks: Use or create type guard utilities (e.g., isString, isNumber) instead of repeating typeof value === 'string'
- Re-run checks
- Repeat until all checks pass clean
Alternative: If project has combined commands (detected in Step 0):
- Check: Use detected combined check script
- Fix: Use detected combined fix script
Example workflow:
# Step 0: Detect commands from package.json
# Found: { packageManager: 'npm', typecheck: 'typecheck', lint: 'lint', lintFix: 'lint:fix', ... }
# Run checks using detected script names
[package-manager] run [detected-typecheck-script]
[package-manager] run [detected-lint-script]
[package-manager] run [detected-format-check-script]
# If failures, run fixes using detected fix scripts
[package-manager] run [detected-lint-fix-script]
[package-manager] run [detected-format-fix-script]
# Re-run checks to verify
[package-manager] run [detected-typecheck-script]
[package-manager] run [detected-lint-script]
[package-manager] run [detected-format-check-script]
Phase 4: Pre-Commit Design Review (ADVISORY)
- Invoke @pre-commit-review skill
- Review validates design principles (not code correctness)
- Includes accessibility checks (ARIA, semantic HTML, keyboard nav)
- Categorized findings: Design Debt / Readability Debt / Polish Opportunities
- If issues found in broader file context, flag for potential refactor
- User decides: commit as-is, apply fixes, or expand scope
Phase 5: Commit Ready
- Type checking passes ✅
- ESLint passes ✅
- Prettier passes ✅
- Stylelint passes ✅
- Tests pass with target coverage ✅
- Design review complete (advisory) ✅
- Present summary + commit message suggestion
Output Format
📋 COMMIT READINESS SUMMARY
✅ Type Check: Passed (0 errors)
✅ ESLint: Passed (0 issues)
✅ Prettier: Passed (all files formatted)
✅ Stylelint: Passed (0 style issues)
✅ Tests: 92% coverage (3 leaf hooks at 100%, 1 orchestrating component, 18 test cases)
⚠️ Design Review: 3 findings (see below)
🎯 COMMIT SCOPE
Modified:
- src/components/LoginForm.tsx (+65, -20 lines)
- src/hooks/useAuth.ts (+30, -5 lines)
Added:
- src/types/auth.ts (new: UserId, Email types)
- src/contexts/AuthContext.tsx (new context provider)
Tests:
- src/components/LoginForm.test.tsx (+95 lines)
- src/hooks/useAuth.test.ts (new)
- src/types/auth.test.ts (new)
⚠️ DESIGN REVIEW FINDINGS
🔴 DESIGN DEBT (Recommended to fix):
- src/components/LoginForm.tsx:45 - Primitive obsession detected
Current: function validateEmail(email: string): boolean
Better: Use Zod schema or branded Email type with validation
Why: Type safety, validation guarantee, prevents invalid emails
Fix: Use @component-designing to create self-validating Email type
- src/hooks/useAuth.ts:78 - Prop drilling detected
Auth state passed through 3+ component levels
Why: Tight coupling, hard to maintain
Fix: Extract AuthContext or use composition pattern
🟡 READABILITY DEBT (Consider fixing):
- src/components/LoginForm.tsx:120 - Mixed abstraction levels
Component mixes validation logic with UI rendering
Why: Harder to understand and test independently
Fix: Use @refactoring to extract custom hooks (useValidation)
- src/components/LoginForm.tsx:88 - Cognitive complexity: 18 (max: 15)
Nested conditionals for form validation
Why: Hard to understand logic flow
Fix: Use @refactoring to extract validation functions or use Zod
🟢 POLISH OPPORTUNITIES:
- src/types/auth.ts:12 - Missing JSDoc comments
Public types should have documentation
- src/components/LoginForm.tsx:45 - Consider semantic HTML
Use <form> with proper ARIA labels for better accessibility
- src/hooks/useAuth.ts:34 - Missing error boundaries
Consider wrapping async operations with error handling
📝 BROADER CONTEXT:
While reviewing LoginForm.tsx, noticed similar validation patterns in
RegisterForm.tsx and ProfileForm.tsx (src/components/). Consider
extracting a shared validation hook or creating branded types for common
fields (Email, Username, Password) used across the application.
💡 SUGGESTED COMMIT MESSAGE
Add self-validating Email and UserId types to auth feature
- Introduce Email type with RFC 5322 validation using Zod
- Introduce UserId branded type for type safety
- Refactor LoginForm to use validated types
- Extract useAuth hook for auth state management
- Add AuthContext to eliminate prop drilling
- Achieve 92% test coverage with React Testing Library
Follows component composition principles and reduces primitive obsession.
────────────────────────────────────────
Would you like to:
1. Commit as-is (ignore design findings)
2. Fix design debt only (🔴), then commit
3. Fix design + readability debt (🔴 + 🟡), then commit
4. Fix all findings (🔴 🟡 🟢), then commit
5. Refactor broader scope (address validation patterns across features), then commit
Complexity Thresholds (SonarJS)
These metrics trigger @refactoring when exceeded:
- Cognitive Complexity: max 15 (how hard to understand)
- Cyclomatic Complexity: max 10 (number of paths through code)
- Expression Complexity: max 5 (operators in single expression)
- Function Length: max 200 lines
- File Length: max 600 lines
- Nesting Level: max 4 (depth of nested control structures)
- Max Union Size: max 4 types (union types with too many options)
Priority Levels
🔴 High Priority: Type Safety Issues
Rules that can cause runtime errors:
@typescript-eslint/no-unsafe-member-access (416 violations)
@typescript-eslint/no-unsafe-assignment (267 violations)
@typescript-eslint/no-explicit-any (194 violations)
@typescript-eslint/no-unsafe-argument (101 violations)
@typescript-eslint/no-unsafe-call (72 violations)
@typescript-eslint/no-unsafe-return (50 violations)
Fix Strategy: Use proper types, type guards, Zod schemas, or branded types
🟡 Medium Priority: Code Quality & Maintainability
Rules that affect readability and maintenance:
no-magic-numbers (243 violations) - Extract to named constants
react/forbid-dom-props (94 violations) - No inline styles, use CSS modules
sonarjs/cyclomatic-complexity (34 violations) - Reduce branches, early returns
sonarjs/prefer-read-only-props (25 violations) - Props should be immutable
react-hooks/exhaustive-deps (41 violations) - Fix dependencies or simplify
Fix Strategy: Apply @refactoring patterns (storifying, early returns, extract functions)
🟢 Low Priority: Style & Convention
Rules that improve consistency:
no-console (28 violations) - Use proper logging
- Import/export conventions
- Styling conventions (camelCase, keyframes naming)
Fix Strategy: Auto-fix or manual cleanup
Workflow Control
Sequential Phases: Each phase depends on previous phase completion
- Design must complete before implementation
- Implementation must complete before linting
- Linting must pass before review
- Review must complete before commit
Iterative Linting: Phase 3 loops until clean
Advisory Review: Phase 4 never blocks, always asks user
Integration with Other Skills
This orchestrator invokes other skills automatically:
- @component-designing (Phase 1, if needed)
- @testing (Phase 2, principles applied)
- @refactoring (Phase 3, when linter fails on complexity)
- @pre-commit-review (Phase 4, always)
After committing, consider:
- If feature complete → invoke @documentation skill
- If more work needed → run this workflow again for next commit
Common Linter Failures and Resolutions
TypeScript Errors (detected typecheck script)
- Type mismatches → Fix types or add proper type guards
- Missing types → Add explicit types or interfaces
- Cannot fix automatically → Manual intervention required
ESLint Failures (detected lint check script)
Auto-fixable:
- Import sorting (simple-import-sort)
- Unused imports (unused-imports)
- Formatting issues covered by Prettier
- Simple style violations
Requires refactoring (invoke @refactoring):
- Cognitive/cyclomatic complexity
- Max lines per function
- Expression complexity
- Nested control flow
- React hooks violations
- Component design issues
Prettier Failures (detected format check script)
- Always auto-fixable with detected format fix script or
prettier --write .
- No manual intervention needed
Stylelint Failures (detected style check script)
- Most auto-fixable with detected style fix script or
stylelint "**/*.{css,scss}" --fix
- Class naming violations may require manual fixes
Best Practices
- Run checks frequently during development
- Fix one complexity issue at a time (don't batch refactoring)
- Trust the advisory review (design debt causes future pain)
- Test after each refactoring (ensure behavior unchanged)
- Commit frequently (small, focused commits)
Implementation Phases
Phase 1: Type Safety Foundation (🔴 High Priority)
Phase 2: Code Quality (🟡 Medium Priority)
Phase 3: Polish (🟢 Low Priority)
Acceptance Criteria
CRITICAL: All criteria must be met before completing this skill.
Mandatory Requirements (Must Pass)
No Linter Rule Disabling in Changed Files
All Quality Checks Pass Clean
All Tests Pass
Iterative Verification
Verification Workflow
IMPORTANT: Detect available scripts from the project's package.json before running checks.
# Iteration 1: Initial check
Run all quality check commands detected from package.json:
- TypeScript check (e.g., typecheck, type-check, tsc)
- Linting check (e.g., lint, lint:check, eslint)
- Format check (e.g., format:check, prettier:check)
- Tests (e.g., test, test:unit, vitest)
# If failures: fix issues, then...
# Iteration 2: Verify fixes didn't introduce new issues
Run the same quality check commands again
# If still clean: proceed to commit
# If new failures: fix and repeat until two consecutive clean runs
Pre-Commit Checklist
Before marking workflow complete:
✅ ACCEPTANCE CRITERIA CHECKLIST
Linter Compliance:
[ ] No eslint-disable comments added to changed files
[ ] No @ts-ignore/@ts-expect-error added to changed files
[ ] All linter issues fixed through proper refactoring
[ ] If any disabling approved: comment explains WHY
Quality Gates:
[ ] TypeScript: 0 errors
[ ] ESLint: 0 errors/warnings in changed files
[ ] Prettier: All files formatted
[ ] Tests: All passing
Iteration Verification:
[ ] Ran checks twice consecutively
[ ] Both runs passed clean
[ ] No oscillating fixes (fix A breaks B, fix B breaks A)
Ready to commit: All boxes checked ✅
What Blocks Completion
The following will BLOCK skill completion:
- Any new linter disabling comment in changed files (without explicit user approval)
- Any failing quality check (typecheck, lint, format, test)
- Single-run verification (must run checks twice)
- Unresolved complexity issues (must refactor, not disable)
Acceptable Exceptions (Require User Approval)
Only with explicit user consent:
- Disabling a rule for a specific line with documented justification
- Skipping a quality check due to known project issues
- Accepting technical debt with plan to address later
When disabling a rule with approval, add a comment explaining WHY:
// ❌ Bad: Disabled without explanation
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const data: any = response.body
// ✅ Good: Disabled with justification
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Legacy API returns untyped response, migration planned in JIRA-123
const data: any = response.body
Document any exceptions in commit message.
Additional Resources
- Common Linter Failures section above for resolution strategies
- @refactoring skill - For complexity issues (cognitive, cyclomatic, expression)
- @component-designing skill - For type safety and architecture issues
- @pre-commit-review skill - For design validation (runs automatically in Phase 4)
1---2name: linter-driven-development-23description: META ORCHESTRATOR for complete implementation workflow - design, test, lint, refactor, review, commit. Use for any code change that should result in a commit (features, bug fixes, refactors). Ensures clean code with tests, linting passes, and design validation.4---56# Linter-Driven Development Workflow (TypeScript + React)78**DEFAULT ENTRY POINT**: This skill should be automatically invoked for ALL code changes when the plugin is enabled.910META ORCHESTRATOR for implementation workflow: design → test → lint → refactor → review → commit.11Use for any commit: features, bug fixes, refactors.1213## Auto-Invocation1415When this plugin is enabled in a project, this skill is the **default workflow** for:16- New feature implementation17- Bug fixes18- Refactoring19- Any code change that should result in a commit2021The CLAUDE.md file at the plugin root enforces this automatic invocation.2223## Core Principles2425**CRITICAL - Read Before Starting**:26271. **Never Disable Rules by Default**28 - **DO NOT** add `eslint-disable`, `@ts-ignore`, `@ts-expect-error`, or similar comments without explicit user approval29 - **ALWAYS** strive to fix the underlying issue through refactoring, not by suppressing warnings30 - **ONLY** disable rules as an absolute last resort when no other solution exists, and always ask user first31 - **When approved**: Add a comment explaining WHY the rule is disabled32332. **Fix, Don't Suppress**34 - Linter warnings exist for good reasons - they indicate real issues35 - Use @refactoring patterns to address complexity and code quality issues36 - If a rule seems wrong for the project, discuss with user rather than silently disabling37383. **Clean Code at Every Step**39 - All checks must pass without suppressions before commit40 - Tests pass, linter passes, types pass - no exceptions4142## Prerequisites4344**IMPORTANT**: Before using this skill, the project MUST have linter configurations:4546### Required Configurations47481. **TypeScript** (`tsconfig.json`)49 - Type checking configured for your project50512. **ESLint** (`eslint.config.mjs` or `.eslintrc.js`)52 - Must include `eslint-plugin-sonarjs` for complexity metrics53 - Recommended: TypeScript ESLint, React plugins54 - Complexity thresholds: cognitive, cyclomatic, expression55563. **Prettier** (`.prettierrc.json` or `prettier.config.js` or `.prettierrc`)57 - Consistent formatting rules defined58 - Integration with ESLint recommended59604. **Stylelint** (`stylelint.config.js`) - if using CSS/SCSS61 - CSS/SCSS linting rules configured6263### Required npm Scripts6465Project must have scripts for running quality checks. **Script names vary by project** - detect them from `package.json`.6667Common patterns to look for:68- **Testing**: `test`, `test:unit`, `vitest`, `jest`69- **Type checking**: `typecheck`, `type-check`, `tsc`, `check-types`70- **Linting (check)**: `lint`, `lint:check`, `eslint`, `lintcheck`71- **Linting (fix)**: `lint:fix`, `eslint:fix`, `lint --fix`72- **Formatting (check)**: `format`, `format:check`, `prettier:check`, `formatcheck`73- **Formatting (fix)**: `format:fix`, `prettier:write`, `prettier --write`74- **Styling (check)**: `stylelint`, `style:check`, `stylecheck`75- **Styling (fix)**: `stylelint:fix`, `style:fix`76- **Combined check**: `check`, `checkall`, `validate`, `verify`77- **Combined fix**: `fix`, `fixall`, `format:all`7879**Detection strategy**: Read `package.json` scripts and identify which commands serve each purpose.8081### Step 0: Detect Project Setup8283**FIRST STEP - Do this before starting any workflow**:84851. **Detect Package Manager**86 - Check for lock files in project root:87 - `yarn.lock` → Use `yarn` commands88 - `package-lock.json` or `npm-shrinkwrap.json` → Use `npm` commands89 - `pnpm-lock.yaml` → Use `pnpm` commands90 - No lock file → Ask user which package manager to use91922. **Detect Available Scripts**93 - Read `package.json` scripts section94 - Identify which scripts exist for each purpose:95 - Type checking (e.g., `typecheck`, `type-check`, `tsc`)96 - Linting check (e.g., `lint`, `eslint`, `lint:check`)97 - Linting fix (e.g., `lint:fix`, `eslint:fix`)98 - Formatting check (e.g., `format:check`, `prettier:check`)99 - Formatting fix (e.g., `format:fix`, `prettier:write`)100 - Testing (e.g., `test`, `vitest`, `jest`)101 - Combined checks (e.g., `check`, `checkall`, `validate`)102 - Combined fixes (e.g., `fix`, `fixall`)1031043. **Build Command Map**105 - Store detected commands for use throughout workflow106 - Example: `{ typecheck: 'typecheck', lint: 'lint', lintFix: 'lint:fix', test: 'test' }`107108**Remember**: Use detected package manager + detected script names consistently throughout ALL workflow phases.109110### Verification111112Before starting, verify setup by running detected commands:113- [ ] Type checking works (using detected typecheck script)114- [ ] Linting works (using detected lint script)115- [ ] Formatting works (using detected format script)116- [ ] Tests work (using detected test script)117- [ ] SonarJS plugin installed and configured118119**If scripts are missing**:1201. Check if functionality exists but with different script name1212. Look for combined commands (e.g., `check` that runs multiple tools)1223. If truly missing, ask user:123 - "What command should I run to check/fix linting?"124 - "Where is this documented?" (suggest adding to README.md or CLAUDE.md)1254. If no script exists, run tool directly (e.g., `eslint .`) or skip that phase126127**Command detection examples**:128```bash129# If package.json has:130"scripts": {131 "lint": "eslint .",132 "lint:fix": "eslint . --fix",133 "check": "tsc && eslint .",134 "test": "vitest"135}136137# Detected commands:138typecheck: (not found, will run 'tsc' directly)139lint: 'lint'140lintFix: 'lint:fix'141test: 'test'142combined: 'check'143```144145---146147## When to Use148- Implementing any code change that should result in a commit149- Need automatic workflow management with quality gates150- Want to ensure: clean code + tests + linting + design validation + accessibility151152## Workflow Phases153154**IMPORTANT**: Start every workflow by detecting the package manager (Step 0 in Prerequisites).155156### Phase 1: Design (if needed)157- If new components/types/major changes needed → invoke @component-designing skill158- Output: Component design plan with types, hooks, and structure159160### Phase 2: Implementation161- Follow @testing skill principles (React Testing Library with Jest/Vitest)162- Write tests + implementation in parallel (not necessarily test-first)163- Follow project's Prettier/ESLint formatting rules164- Use project's test runner (Jest, Vitest, or other)165- Aim for 100% coverage on new leaf components/hooks (pure logic with no external dependencies)166 - Leaf types: Pure logic (can compose other leaf types), no API/DB/file system access167 - Orchestrating types: Coordinate leaf types and external systems, need integration tests168- Test from user perspective (public API only)169170### Phase 3: Linter Loop171172**Use detected package manager and script names from Step 0** for all commands below.173174Run quality checks in this order (using detected script names from package.json):1751. **Type Check**: Run detected typecheck script (look for: `typecheck`, `type-check`, `tsc`)1762. **Lint Check**: Run detected lint check script (look for: `lint`, `lint:check`, `eslint`)1773. **Format Check**: Run detected format check script (look for: `format:check`, `prettier:check`)1784. **Style Check**: Run detected style check script (look for: `stylelint`, `style:check`) - if CSS/SCSS in project179180**Handling missing scripts**:181- If type check script not found → Run `tsc --noEmit` directly182- If lint check script not found → Run `eslint .` directly183- If format check script not found → Run `prettier --check .` directly184- If style check script not found and CSS/SCSS exists → Skip if Stylelint not installed185186If any failures detected:187- Run auto-fixes using detected fix scripts:188 - **Lint fix**: Run detected lint fix script (look for: `lint:fix`, `eslint:fix`)189 - **Format fix**: Run detected format fix script (look for: `format:fix`, `prettier:write`)190 - **Style fix**: Run detected style fix script (look for: `stylelint:fix`, `style:fix`)191- Re-run quality checks192- If still failing (complexity, design issues):193 - **NEVER disable linter rules by default**: Do NOT add `eslint-disable`, `@ts-ignore`, `@ts-expect-error`, or similar comments unless explicitly approved by the user194 - **Always fix, not disable**: Strive to fix the underlying issue through refactoring, not by suppressing warnings195 - **Only disable as last resort**: If absolutely necessary and no other solution exists, ask user for explicit approval before disabling any rule196 - **When approved**: Add a comment explaining WHY the rule is disabled197 - Interpret failures (cognitive complexity, cyclomatic complexity, etc.)198 - Invoke @refactoring skill to fix (use storifying, extract functions/hooks, early returns)199 - **Check for existing utilities**: Before creating new helpers, check if type guards, utilities, or constants already exist in the codebase200 - **Avoid repeated `typeof` checks**: Use or create type guard utilities (e.g., `isString`, `isNumber`) instead of repeating `typeof value === 'string'`201 - Re-run checks202- Repeat until all checks pass clean203204**Alternative**: If project has combined commands (detected in Step 0):205- Check: Use detected combined check script206- Fix: Use detected combined fix script207208**Example workflow**:209```210# Step 0: Detect commands from package.json211# Found: { packageManager: 'npm', typecheck: 'typecheck', lint: 'lint', lintFix: 'lint:fix', ... }212213# Run checks using detected script names214[package-manager] run [detected-typecheck-script]215[package-manager] run [detected-lint-script]216[package-manager] run [detected-format-check-script]217218# If failures, run fixes using detected fix scripts219[package-manager] run [detected-lint-fix-script]220[package-manager] run [detected-format-fix-script]221222# Re-run checks to verify223[package-manager] run [detected-typecheck-script]224[package-manager] run [detected-lint-script]225[package-manager] run [detected-format-check-script]226```227228### Phase 4: Pre-Commit Design Review (ADVISORY)229- Invoke @pre-commit-review skill230- Review validates design principles (not code correctness)231- Includes accessibility checks (ARIA, semantic HTML, keyboard nav)232- Categorized findings: Design Debt / Readability Debt / Polish Opportunities233- If issues found in broader file context, flag for potential refactor234- **User decides**: commit as-is, apply fixes, or expand scope235236### Phase 5: Commit Ready237- Type checking passes ✅238- ESLint passes ✅239- Prettier passes ✅240- Stylelint passes ✅241- Tests pass with target coverage ✅242- Design review complete (advisory) ✅243- Present summary + commit message suggestion244245## Output Format246247```248📋 COMMIT READINESS SUMMARY249250✅ Type Check: Passed (0 errors)251✅ ESLint: Passed (0 issues)252✅ Prettier: Passed (all files formatted)253✅ Stylelint: Passed (0 style issues)254✅ Tests: 92% coverage (3 leaf hooks at 100%, 1 orchestrating component, 18 test cases)255⚠️ Design Review: 3 findings (see below)256257🎯 COMMIT SCOPE258Modified:259- src/components/LoginForm.tsx (+65, -20 lines)260- src/hooks/useAuth.ts (+30, -5 lines)261262Added:263- src/types/auth.ts (new: UserId, Email types)264- src/contexts/AuthContext.tsx (new context provider)265266Tests:267- src/components/LoginForm.test.tsx (+95 lines)268- src/hooks/useAuth.test.ts (new)269- src/types/auth.test.ts (new)270271⚠️ DESIGN REVIEW FINDINGS272273🔴 DESIGN DEBT (Recommended to fix):274- src/components/LoginForm.tsx:45 - Primitive obsession detected275 Current: function validateEmail(email: string): boolean276 Better: Use Zod schema or branded Email type with validation277 Why: Type safety, validation guarantee, prevents invalid emails278 Fix: Use @component-designing to create self-validating Email type279280- src/hooks/useAuth.ts:78 - Prop drilling detected281 Auth state passed through 3+ component levels282 Why: Tight coupling, hard to maintain283 Fix: Extract AuthContext or use composition pattern284285🟡 READABILITY DEBT (Consider fixing):286- src/components/LoginForm.tsx:120 - Mixed abstraction levels287 Component mixes validation logic with UI rendering288 Why: Harder to understand and test independently289 Fix: Use @refactoring to extract custom hooks (useValidation)290291- src/components/LoginForm.tsx:88 - Cognitive complexity: 18 (max: 15)292 Nested conditionals for form validation293 Why: Hard to understand logic flow294 Fix: Use @refactoring to extract validation functions or use Zod295296🟢 POLISH OPPORTUNITIES:297- src/types/auth.ts:12 - Missing JSDoc comments298 Public types should have documentation299- src/components/LoginForm.tsx:45 - Consider semantic HTML300 Use <form> with proper ARIA labels for better accessibility301- src/hooks/useAuth.ts:34 - Missing error boundaries302 Consider wrapping async operations with error handling303304📝 BROADER CONTEXT:305While reviewing LoginForm.tsx, noticed similar validation patterns in306RegisterForm.tsx and ProfileForm.tsx (src/components/). Consider307extracting a shared validation hook or creating branded types for common308fields (Email, Username, Password) used across the application.309310💡 SUGGESTED COMMIT MESSAGE311Add self-validating Email and UserId types to auth feature312313- Introduce Email type with RFC 5322 validation using Zod314- Introduce UserId branded type for type safety315- Refactor LoginForm to use validated types316- Extract useAuth hook for auth state management317- Add AuthContext to eliminate prop drilling318- Achieve 92% test coverage with React Testing Library319320Follows component composition principles and reduces primitive obsession.321322────────────────────────────────────────323324Would you like to:3251. Commit as-is (ignore design findings)3262. Fix design debt only (🔴), then commit3273. Fix design + readability debt (🔴 + 🟡), then commit3284. Fix all findings (🔴 🟡 🟢), then commit3295. Refactor broader scope (address validation patterns across features), then commit330```331332## Complexity Thresholds (SonarJS)333334These metrics trigger @refactoring when exceeded:335- **Cognitive Complexity**: max 15 (how hard to understand)336- **Cyclomatic Complexity**: max 10 (number of paths through code)337- **Expression Complexity**: max 5 (operators in single expression)338- **Function Length**: max 200 lines339- **File Length**: max 600 lines340- **Nesting Level**: max 4 (depth of nested control structures)341- **Max Union Size**: max 4 types (union types with too many options)342343## Priority Levels344345### 🔴 High Priority: Type Safety Issues346Rules that can cause runtime errors:347- `@typescript-eslint/no-unsafe-member-access` (416 violations)348- `@typescript-eslint/no-unsafe-assignment` (267 violations)349- `@typescript-eslint/no-explicit-any` (194 violations)350- `@typescript-eslint/no-unsafe-argument` (101 violations)351- `@typescript-eslint/no-unsafe-call` (72 violations)352- `@typescript-eslint/no-unsafe-return` (50 violations)353354**Fix Strategy**: Use proper types, type guards, Zod schemas, or branded types355356### 🟡 Medium Priority: Code Quality & Maintainability357Rules that affect readability and maintenance:358- `no-magic-numbers` (243 violations) - Extract to named constants359- `react/forbid-dom-props` (94 violations) - No inline styles, use CSS modules360- `sonarjs/cyclomatic-complexity` (34 violations) - Reduce branches, early returns361- `sonarjs/prefer-read-only-props` (25 violations) - Props should be immutable362- `react-hooks/exhaustive-deps` (41 violations) - Fix dependencies or simplify363364**Fix Strategy**: Apply @refactoring patterns (storifying, early returns, extract functions)365366### 🟢 Low Priority: Style & Convention367Rules that improve consistency:368- `no-console` (28 violations) - Use proper logging369- Import/export conventions370- Styling conventions (camelCase, keyframes naming)371372**Fix Strategy**: Auto-fix or manual cleanup373374## Workflow Control375376**Sequential Phases**: Each phase depends on previous phase completion377- Design must complete before implementation378- Implementation must complete before linting379- Linting must pass before review380- Review must complete before commit381382**Iterative Linting**: Phase 3 loops until clean383**Advisory Review**: Phase 4 never blocks, always asks user384385## Integration with Other Skills386387This orchestrator **invokes** other skills automatically:388- @component-designing (Phase 1, if needed)389- @testing (Phase 2, principles applied)390- @refactoring (Phase 3, when linter fails on complexity)391- @pre-commit-review (Phase 4, always)392393After committing, consider:394- If feature complete → invoke @documentation skill395- If more work needed → run this workflow again for next commit396397## Common Linter Failures and Resolutions398399### TypeScript Errors (detected typecheck script)400- Type mismatches → Fix types or add proper type guards401- Missing types → Add explicit types or interfaces402- Cannot fix automatically → Manual intervention required403404### ESLint Failures (detected lint check script)405**Auto-fixable**:406- Import sorting (simple-import-sort)407- Unused imports (unused-imports)408- Formatting issues covered by Prettier409- Simple style violations410411**Requires refactoring** (invoke @refactoring):412- Cognitive/cyclomatic complexity413- Max lines per function414- Expression complexity415- Nested control flow416- React hooks violations417- Component design issues418419### Prettier Failures (detected format check script)420- Always auto-fixable with detected format fix script or `prettier --write .`421- No manual intervention needed422423### Stylelint Failures (detected style check script)424- Most auto-fixable with detected style fix script or `stylelint "**/*.{css,scss}" --fix`425- Class naming violations may require manual fixes426427## Best Practices4284291. **Run checks frequently** during development4302. **Fix one complexity issue at a time** (don't batch refactoring)4313. **Trust the advisory review** (design debt causes future pain)4324. **Test after each refactoring** (ensure behavior unchanged)4335. **Commit frequently** (small, focused commits)434435## Implementation Phases436437### Phase 1: Type Safety Foundation (🔴 High Priority)438- [ ] Fix all `@typescript-eslint/no-unsafe-*` errors439- [ ] Replace `any` types with proper types440- [ ] Add type definitions for external APIs441- [ ] Use type guards for runtime checks442- [ ] Implement Zod schemas for validation443444### Phase 2: Code Quality (🟡 Medium Priority)445- [ ] Fix complexity issues (cyclomatic, cognitive)446- [ ] Remove inline styles, use CSS modules447- [ ] Make props readonly448- [ ] Extract magic numbers to constants449- [ ] Apply refactoring patterns (IIFE → lookup, empty blocks → early returns)450451### Phase 3: Polish (🟢 Low Priority)452- [ ] Clean up console statements453- [ ] Fix remaining hooks dependencies454- [ ] Address styling conventions455- [ ] Improve comment quality456- [ ] Use EMPTY_STRING constant457458## Acceptance Criteria459460**CRITICAL: All criteria must be met before completing this skill.**461462### Mandatory Requirements (Must Pass)4634641. **No Linter Rule Disabling in Changed Files**465 - [ ] Changed files contain NO new `eslint-disable`, `eslint-disable-next-line`, `eslint-disable-line` comments466 - [ ] Changed files contain NO new `@ts-ignore`, `@ts-expect-error`, `@ts-nocheck` comments467 - [ ] Changed files contain NO new `stylelint-disable` comments468 - [ ] Pre-existing disabling comments in unchanged files are acceptable (not in scope)469 - **If disabling is absolutely necessary**: Stop and ask user for explicit approval before adding470 - **When approved**: Add a comment explaining WHY the rule is disabled4714722. **All Quality Checks Pass Clean**473 - [ ] TypeScript compilation: 0 errors474 - [ ] ESLint: 0 errors, 0 warnings in changed files475 - [ ] Prettier: All changed files formatted correctly476 - [ ] Stylelint: 0 errors in changed CSS/SCSS files (if applicable)4774783. **All Tests Pass**479 - [ ] Existing tests pass (no regressions)480 - [ ] New tests written for new code481 - [ ] Coverage targets met (100% for leaf components/hooks)4824834. **Iterative Verification**484 - [ ] Run quality checks at least twice after final changes485 - [ ] Second run confirms no new issues introduced486 - [ ] If any check fails on second run, fix and repeat until two consecutive clean runs487488### Verification Workflow489490**IMPORTANT**: Detect available scripts from the project's `package.json` before running checks.491492```493# Iteration 1: Initial check494Run all quality check commands detected from package.json:495- TypeScript check (e.g., typecheck, type-check, tsc)496- Linting check (e.g., lint, lint:check, eslint)497- Format check (e.g., format:check, prettier:check)498- Tests (e.g., test, test:unit, vitest)499500# If failures: fix issues, then...501502# Iteration 2: Verify fixes didn't introduce new issues503Run the same quality check commands again504505# If still clean: proceed to commit506# If new failures: fix and repeat until two consecutive clean runs507```508509### Pre-Commit Checklist510511Before marking workflow complete:512513```514✅ ACCEPTANCE CRITERIA CHECKLIST515516Linter Compliance:517[ ] No eslint-disable comments added to changed files518[ ] No @ts-ignore/@ts-expect-error added to changed files519[ ] All linter issues fixed through proper refactoring520[ ] If any disabling approved: comment explains WHY521522Quality Gates:523[ ] TypeScript: 0 errors524[ ] ESLint: 0 errors/warnings in changed files525[ ] Prettier: All files formatted526[ ] Tests: All passing527528Iteration Verification:529[ ] Ran checks twice consecutively530[ ] Both runs passed clean531[ ] No oscillating fixes (fix A breaks B, fix B breaks A)532533Ready to commit: All boxes checked ✅534```535536### What Blocks Completion537538The following will BLOCK skill completion:539- Any new linter disabling comment in changed files (without explicit user approval)540- Any failing quality check (typecheck, lint, format, test)541- Single-run verification (must run checks twice)542- Unresolved complexity issues (must refactor, not disable)543544### Acceptable Exceptions (Require User Approval)545546Only with explicit user consent:547- Disabling a rule for a specific line with documented justification548- Skipping a quality check due to known project issues549- Accepting technical debt with plan to address later550551**When disabling a rule with approval, add a comment explaining WHY:**552```typescript553// ❌ Bad: Disabled without explanation554// eslint-disable-next-line @typescript-eslint/no-explicit-any555const data: any = response.body556557// ✅ Good: Disabled with justification558// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Legacy API returns untyped response, migration planned in JIRA-123559const data: any = response.body560```561562**Document any exceptions in commit message.**563564## Additional Resources565566- **Common Linter Failures** section above for resolution strategies567- **@refactoring skill** - For complexity issues (cognitive, cyclomatic, expression)568- **@component-designing skill** - For type safety and architecture issues569- **@pre-commit-review skill** - For design validation (runs automatically in Phase 4)