From ai-tools
Diagnose and fix test failures using resource-aware parallel subagents with automatic test framework detection
npx claudepluginhub waynebrantley/aitools --plugin ai-toolsThis skill uses the workspace's default tool permissions.
Systematically fix test failures using parallel subagents with intelligent coordination, resource-aware execution, and iterative verification.
preview.mjsscripts/adapters/base-adapter.mjsscripts/adapters/dotnet.mjsscripts/adapters/playwright.mjsscripts/adapters/vitest.mjsscripts/detect-frontend-dir.mjsscripts/detect-test-environment.mjsscripts/find-skipped-tests.mjsscripts/parse-validate-output.mjsscripts/run-discovery.mjsscripts/run-final-validation.mjsscripts/run-validation.mjsscripts/verify-fix.mjsscripts/verify-progress.mjstests/adapters/base-adapter.test.mjstests/adapters/dotnet.test.mjstests/adapters/playwright.test.mjstests/adapters/vitest.test.mjstests/detect-frontend-dir.test.mjstests/detect-test-environment.test.mjsRetrieves texts, DMs, one-time codes, and inspects threads in ECC workflows. Provides evidence of exact sources checked for verification before replies.
Delivers expertise for HS tariff classification, customs documentation, duty optimization, restricted party screening, and trade compliance across jurisdictions.
Process documents with Nutrient API: convert formats (PDF, DOCX, XLSX, images), OCR scans (100+ languages), extract text/tables, redact PII, sign, fill forms.
Systematically fix test failures using parallel subagents with intelligent coordination, resource-aware execution, and iterative verification.
Supported Test Frameworks:
IMPORTANT: Use the TodoWrite tool throughout this workflow to track progress and ensure ALL steps are completed. Create todos at the start and update them as you progress through each phase.
Before starting, create a comprehensive todo list:
TodoWrite:
1. Detect test frameworks (pending)
2. Select framework(s) to fix (pending)
3. Run test discovery (pending)
4. Calculate parallelism (pending)
5. Fix files in parallel (pending)
6. Verify all files processed (pending)
7. Run final validation (pending)
8. Check for skipped tests (pending)
Mark each todo as in_progress when starting, and completed when finished. Add file-specific todos during the fixing phase.
Auto-detect test framework and run discovery:
node scripts/detect-test-environment.mjs # Detect framework
Output: JSON array of detected frameworks (may contain multiple entries)
If multiple test frameworks are detected, prompt the user to select which to fix.
Selection Strategy:
A. If 2-4 frameworks detected - Use AskUserQuestion with multiSelect: true:
Which test framework(s) would you like to fix?
Options:
B. If >4 frameworks detected - Show grouped, numbered list and ask for text response:
Display frameworks grouped by type:
Detected 6 test frameworks:
.NET Test (4 projects):
JavaScript (2 projects): 5. Vitest (unit tests) 6. Playwright (e2e tests)
Which would you like to fix (or all)?
Store Selection: Keep the selected framework config(s) for the workflow.
Processing:
Run tests and validation for the selected framework(s):
node scripts/run-discovery.mjs # Run tests + validation
Parse output to identify files with errors:
node scripts/parse-validate-output.mjs table
Output: List of files sorted by error count (fix high-impact files first)
Determine optimal parallelism based on system resources and test framework:
# Auto-calculates based on:
# - Vitest/Jest: 2GB per agent
# - Playwright: 5GB per agent (browser instances)
# - .NET Test: 3GB per agent
node calculate-parallelism.mjs --mem-per-agent=<framework_value>
Uses calculate-parallelism skill for resource-aware execution (2-6 parallel agents).
CRITICAL: Process ALL files with errors, not just the first one!
TodoWrite Integration: When you receive the file list, create a todo for each file:
TodoWrite (add to existing list):
- Fix tests/unit/auth.test.ts (5 failures) (pending)
- Fix tests/integration/api.spec.ts (3 failures) (pending)
- Fix tests/e2e/checkout.spec.ts (2 failures) (pending)
... (one todo per file)
As you spawn subagents, mark files as in_progress. When verified, mark as completed.
For each file in error list:
Spawn Fix Subagent (respecting MAX_PARALLEL limit):
Task: Fix all issues in {filename}
Context:
- File: {path}
- Framework: {detected_framework}
- Issues: {test failures, type errors, lint errors}
Requirements:
- Fix ALL issues in this file only
- Do NOT modify other files
- Follow project standards (check CLAUDE.md)
- Maintain test coverage
- Verify with: node scripts/verify-fix.mjs {file}
- Do NOT run whole-project commands (eslint ., eslint src, tsc)
Success: Zero test failures, type errors, and lint errors
Verify Fix:
node scripts/verify-fix.mjs {file}
Evaluate Result:
Verify ALL files were processed:
node scripts/verify-progress.mjs initial-files.txt fixed-files.txt
If files remain, spawn subagents for remaining files.
IMPORTANT: Run this as a single sequential command directly in the main agent. Do NOT spawn subagents or use the Task tool for this step.
Run complete validation after ALL files processed:
node scripts/run-final-validation.mjs
Expected: All tests passing, zero type/lint errors.
If issues remain: Identify regressions, spawn fix subagents for the specific failing files, then re-run this validation step (max 2 cycles).
After all errors fixed, check for skipped tests:
node scripts/find-skipped-tests.mjs
If found, ask user if they want to fix and re-enable them.
run_in_background: true when spawning fix subagents. Always use foreground Task calls so you know exactly when each agent completes.Auto-detection via detect-test-environment.mjs:
Vitest/Jest:
vitest, jest, or vite in package.jsonpnpm/npm/yarn exec vitest run**/*.test.ts, **/*.spec.tsxPlaywright:
@playwright/test in package.json or playwright.config.tsnpx playwright test**/*.spec.ts, e2e/**/*.test.ts.NET Test:
Microsoft.NET.Test.Sdk, NUnit3, xunit, MSTest in .csprojdotnet test <project>.csprojdotnet format, dotnet build**/*Test.cs, **/*Tests.csBefore running the full skill, preview what would be detected and fixed:
# From skill directory
node preview.mjs [target-directory]
# Uses Git repository root if no directory specified
node preview.mjs
What it does:
Perfect for:
subagent_type="general-purpose"Phase 1 - Initial Planning:
1. Detect test frameworks (in_progress)
2. Select framework(s) to fix (pending)
3. Run test discovery (pending)
4. Calculate parallelism (pending)
5. Fix files in parallel (pending)
6. Verify all files processed (pending)
7. Run final validation (pending)
8. Check for skipped tests (pending)
Phase 2 - During Parallel Fixing:
1. Detect test frameworks (completed)
2. Select framework(s) to fix (completed)
3. Run test discovery (completed)
4. Calculate parallelism (completed)
5. Fix tests/unit/auth.test.ts (5 failures) (in_progress)
6. Fix tests/integration/api.spec.ts (3 failures) (in_progress)
7. Fix tests/e2e/checkout.spec.ts (2 failures) (pending)
8. Fix tests/unit/validation.test.ts (1 failure) (pending)
9. Verify all files processed (pending)
10. Run final validation (pending)
11. Check for skipped tests (pending)
Phase 3 - Near Completion:
1-8. [All file fixes] (completed)
9. Verify all files processed (completed)
10. Run final validation (in_progress)
11. Check for skipped tests (pending)
All scripts are in scripts/ directory and work cross-platform:
detect-test-environment.mjs - Auto-detect framework and config
node scripts/detect-test-environment.mjs [directory]
# Outputs JSON with framework, projectRoot, config
run-discovery.mjs - Run tests + validation for discovery
node scripts/run-discovery.mjs
# Saves to test-output.txt and validate-output.txt
parse-validate-output.mjs - Parse and group errors by file
cat test-output.txt validate-output.txt | node scripts/parse-validate-output.mjs
verify-fix.mjs - Verify single file fix
node scripts/verify-fix.mjs <file> [--json]
# Exit 0: fixed, 1: errors remain
verify-progress.mjs - Check all files processed
node scripts/verify-progress.mjs initial.txt fixed.txt
run-final-validation.mjs - Final validation after all fixes
node scripts/run-final-validation.mjs
find-skipped-tests.mjs - Find skipped tests
node scripts/find-skipped-tests.mjs [--json]
Each fix subagent MUST:
node scripts/verify-fix.mjs {file} to validate the fix. Do NOT run eslint ., eslint src, or any whole-project validation commands. Always target the specific file being fixed.eslint ., eslint src, tsc) — always target the specific fileCRITICAL: Do NOT work around script failures.
If any script in this skill produces no output, fails, or returns unexpected results:
If a script fails, ask the user how to proceed before continuing.
Subagent and Runtime Errors:
Skill succeeds when BOTH pass (framework-specific):
Vitest/Jest: vitest run passes + prettier + eslint + tsc passes
Playwright: playwright test passes + prettier + eslint + tsc passes
.NET Test: dotnet test passes + dotnet format + dotnet build passes
After success, check for skipped tests and offer to fix them.
Remember: Process ALL files with errors, not just the first one! Resource-aware execution ensures optimal performance without overwhelming the system.
Version: 1.0.0 License: MIT Author: Wayne Brantley