Smart Fix Command
Intelligent problem resolver that analyzes the type of issue (build error, test failure, runtime crash, type error, lint violation) and applies the appropriate fix strategy. Automatically diagnoses and resolves common development problems.
Command
/fix
Description
Automatically diagnoses and fixes development issues by first classifying the problem type, then applying the appropriate resolution strategy. Handles build errors, test failures, type errors, lint violations, runtime crashes, and dependency conflicts.
Behavior
Arguments
$ARGUMENTS-- Error message, file path, or description of the issue. If empty, runs common check commands to detect issues automatically.
Issue Detection (when no arguments)
# Auto-detect issues by running checks npm run build 2>&1 # Build errors npm test 2>&1 # Test failures npx tsc --noEmit 2>&1 # Type errors npm run lint 2>&1 # Lint violations
Fix Strategies by Issue Type
Build Errors
- Parse the error output for file path and line number
- Read the file and surrounding context
- Identify the cause (missing import, syntax error, incompatible types)
- Apply the fix
- Re-run the build to verify
Test Failures
- Run the failing test in isolation with verbose output
- Compare expected vs actual values
- Determine if the test or the implementation is wrong
- Fix the root cause (not just the assertion)
- Run the full test suite to check for regressions
Type Errors
- Read the TypeScript error with file location
- Examine the type definitions involved
- Determine the correct type (not
any-- use proper types) - Apply type fixes: annotations, guards, or interface updates
- Re-run
tsc --noEmitto verify
Lint Violations
- Parse lint output for rule name and location
- Understand what the rule enforces
- Fix the code to satisfy the rule (not disable the rule)
- Only disable a rule if it's genuinely a false positive
- Re-run the linter to verify
Runtime Errors
- Analyze the stack trace
- Identify the throw/crash point
- Trace the data flow to find the root cause
- Add proper error handling and input validation
- Add a test that reproduces the error
Dependency Conflicts
- Check
npm lsorpip listfor version conflicts - Identify which packages have incompatible peer dependencies
- Find compatible version ranges
- Update package.json and reinstall
- Verify the build still works
Output Format
## Fix Applied **Issue Type**: Type Error **Root Cause**: `fetchUser` returns `User | undefined` but caller assumes `User` **File**: src/pages/profile.tsx:23 ### Changes Made 1. Added null check at src/pages/profile.tsx:23 2. Added loading state for undefined user 3. Updated return type annotation on fetchUser ### Verification - `tsc --noEmit`: PASS (0 errors) - `npm test`: PASS (42/42)
Examples
# Auto-detect and fix issues /fix # Fix a specific error /fix TypeError: Cannot read property 'name' of undefined at src/api.ts:42 # Fix a specific file /fix src/components/UserProfile.tsx # Fix failing tests /fix tests are failing in auth.test.ts
Reviews
No reviews yet. Be the first to review this template!
Similar Templates
Git Commit Message Generator
Generates well-structured conventional commit messages by analyzing staged changes. Follows Conventional Commits spec with scope detection.
React Component Scaffolder
Scaffolds a complete React component with TypeScript types, Tailwind styles, Storybook stories, and unit tests. Follows project conventions automatically.
CI/CD Pipeline Generator
Generates GitHub Actions workflows for CI/CD including linting, testing, building, and deploying. Detects project stack automatically.