6.2 KiB
6.2 KiB
description, preapprovedTools
| description | preapprovedTools | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| Run npm run check:all if available and resolve all issues found |
|
You are tasked with running quality checks and resolving all issues found. Follow these steps:
Workflow Overview
flowchart TD
Start([Start]) --> DetectEnv[Run npm run to list scripts]
DetectEnv --> HasScript{check:all available?}
HasScript -->|No| AskUser[Ask about alternative scripts]
HasScript -->|Yes| RunChecks[Run npm run check:all]
RunChecks --> ParseOutput[Parse errors, warnings, failures]
ParseOutput --> CreateTodos[Create TodoWrite list for all issues]
CreateTodos --> HasIssues{Issues found?}
HasIssues -->|No| Success[All checks pass]
HasIssues -->|Yes| NextIssue[Get next issue from todo]
NextIssue --> MarkInProgress[Mark todo as in_progress]
MarkInProgress --> ReadCode[Read affected files]
ReadCode --> UnderstandIssue[Analyze root cause]
UnderstandIssue --> FixIssue[Apply targeted fix with Edit]
FixIssue --> Verify[Re-run npm run check:all]
Verify --> FixWorked{Issue resolved?}
FixWorked -->|Yes| MarkComplete[Mark todo as completed]
FixWorked -->|No| Attempts{Attempts < 3?}
Attempts -->|Yes| TryAgain[Try alternative approach]
TryAgain --> ReadCode
Attempts -->|No| MarkBlocked[Mark as blocked, ask user]
MarkComplete --> MoreIssues{More issues?}
MarkBlocked --> MoreIssues
MoreIssues -->|Yes| NextIssue
MoreIssues -->|No| FinalCheck[Run full npm run check:all]
FinalCheck --> AllPassed{All checks pass?}
AllPassed -->|No| NewIssues[Add new issues to todo]
NewIssues --> NextIssue
AllPassed -->|Yes| Summary[Provide completion summary]
Summary --> End([End])
Success --> End
AskUser --> End
style Start fill:#90EE90
style End fill:#90EE90
style Success fill:#90EE90
style MarkBlocked fill:#FFB6C1
style AllPassed fill:#87CEEB
1. Environment Detection
First, check if this is a Node.js project and if the check:all script is available:
- Run
npm runto list all available scripts - Check if
check:allis in the output - If the script is not available, inform the user and ask if they want to:
- Run alternative scripts (list the available ones from npm run output)
- Skip the check phase and just review existing issues
2. Run Quality Checks
If npm run check:all is available:
-
Run the check command:
npm run check:all -
Capture and analyze output:
- Parse the output to identify all errors, warnings, and failures
- Categorize issues by type:
- Type errors (TypeScript)
- Linting errors (ESLint, etc.)
- Test failures
- Formatting issues
- Other build/check errors
-
Create a task plan using TodoWrite:
- Create one todo item for each distinct issue or group of related issues
- Use descriptive names like "Fix type error in auth.ts:42" or "Resolve 5 ESLint errors in utils/"
- Set the first task to in_progress
3. Resolve Issues Systematically
For each issue found:
-
Read affected files:
- Use Read tool to examine the problematic code
- Understand the context and root cause
-
Fix the issue:
- Use Edit tool to make targeted fixes
- Ensure fixes are minimal and focused
- Prefer fixing root causes over suppressing warnings
-
Verify the fix:
- Re-run
npm run check:allto confirm the issue is resolved - If new issues appear, add them to the todo list
- Mark the current todo as completed when verified
- Re-run
-
Move to next issue:
- Update TodoWrite to mark current task completed
- Set next task to in_progress
- Continue until all issues are resolved
4. Final Verification
After resolving all issues:
-
Run full check suite:
npm run check:all -
Verify clean output:
- Ensure all checks pass with no errors or warnings
- If any issues remain, add them to the todo list and continue resolving
-
Summary:
- Provide a summary of all issues resolved
- Note any issues that couldn't be automatically fixed (if any)
Resolution Strategies
Type Errors
- Add missing type annotations
- Fix type mismatches
- Add proper null/undefined checks
- Update interface definitions if needed
- Consider using type assertions only as last resort
Linting Errors
- Fix formatting issues
- Remove unused variables/imports
- Add missing dependencies to useEffect/useCallback
- Fix accessibility issues (a11y)
- Resolve complexity warnings with refactoring
Test Failures
- Update test expectations if code behavior changed correctly
- Fix broken test setup/teardown
- Add missing mocks or test data
- Fix async timing issues
- Update snapshots if UI changed intentionally
Formatting Issues
- Let the formatter handle these automatically
- Run
npm run formator similar if available - Ensure .prettierrc or similar config is respected
Important Rules
- Never suppress errors without understanding them - always fix the root cause
- Keep changes focused - one issue at a time
- Verify after each fix - don't accumulate untested changes
- Use TodoWrite to track progress and give user visibility
- Ask for clarification if an issue's resolution is ambiguous
- Document breaking changes if any fixes require API changes
- Preserve functionality - fixes should not change working behavior
- Stay idempotent - re-running should be safe if interrupted
Error Handling
If a fix creates new issues:
- Undo the problematic change
- Add the new issue to the todo list
- Try an alternative approach
- Ask user for guidance if stuck
If stuck on an issue for more than 2-3 attempts:
- Mark it in the todo list as blocked
- Ask the user for guidance
- Move to next issue and return later
Workflow Summary
- Detect environment and check if npm run check:all is available
- Run checks and capture all issues
- Create comprehensive todo list with all issues
- Resolve issues one by one, verifying each fix
- Re-run full check suite to confirm all issues resolved
- Provide summary of work completed
Proceed with running the checks and resolving all issues found.