Spawn Test Fix Agents
Run this command to automatically spawn parallel subagents to fix skipped/failing tests.
Instructions for Claude
Follow this CONTINUOUS LOOP to spawn agents, incorporate results, and spawn more:
Log File
All fix results are logged to TEST_FIXES.md in the project root.
At session start, if the file doesn't exist, create it with this header:
# Test Fixes Log
This file tracks all test fix attempts and their results.
---
Then append entries as fixes complete.
State Tracking
Maintain these lists throughout the session:
- ACTIVE_AGENTS: Test groups currently being fixed by running agents
- COMPLETED: Test groups that have been fixed (successful or failed)
- PENDING: Test groups identified as skipped but not yet assigned
Step 1: Identify Skipped Tests
Run the test suite and identify skipped tests:
npm test 2>&1 | grep -E "skipped|skip"
Also check the skip lists in:
tests/suite/compliance.test.ts- UNIMPLEMENTED_KEYWORDS, SKIPPED_OPTIONAL_FILES, SKIPPED_TEST_DESCRIPTIONStests/runtime/coercion.test.ts- look forit.skipordescribe.skip
Group related skipped tests together. Common groups:
- Coercion tests - if-then-else coercion, error messages
- Content validation - contentMediaType, contentEncoding
- Cross-draft refs - $ref resolution across schema versions
- Format assertion - meta-schema format-assertion keyword
- Float overflow - multipleOf with very large numbers
- Unknown keywords - $id inside unknown keywords
Step 2: Spawn Agents for Pending Groups
For up to 3 groups from PENDING (respecting parallelism limits):
- Move group from PENDING to ACTIVE_AGENTS
- Create worktree:
git worktree add /tmp/tjs-fix-GROUP -b fix/GROUP 2>/dev/null || echo "Worktree exists" - Spawn a subagent using the Task tool with this prompt:
TEST FIX TASK: Fix the GROUP tests
## Setup
Working directory: /tmp/tjs-fix-GROUP
Branch: fix/GROUP
First run:
cd /tmp/tjs-fix-GROUP && npm install
## Your Task
1. **Identify the Skipped Tests**
Find the specific tests that are skipped for GROUP.
Read the test files and understand what they're testing.
2. **Understand the Issue**
- Read the test expectations
- Trace through the code to understand why the test fails
- Identify what needs to be implemented or fixed
3. **Implement the Fix**
Key files to check:
- `src/core/compiler.ts` - main compilation logic
- `src/core/coercion.ts` - type coercion
- `src/core/context.ts` - compilation context
- `src/core/keywords/*.ts` - keyword handlers
4. **Unskip and Verify**
- Remove the `.skip` from the test(s)
- Run: npm test
- Ensure all tests pass (including the previously skipped ones)
5. **Commit if Fixed**
If tests pass:
git add -A && git commit -m "fix: implement GROUP functionality"
6. **Capture Diff**
Run: git diff HEAD~1 --stat && git diff HEAD~1
Save the full diff output to include in your report.
7. **Report Results**
Return a structured report:
- GROUP: the test group fixed
- STATUS: "success" | "partial" | "blocked" | "error"
- TESTS_FIXED: number of tests now passing
- TESTS_REMAINING: number still skipped (if partial)
- DESCRIPTION: brief description of changes made
- BLOCKERS: any issues preventing full fix (if partial/blocked)
- DIFF: the full git diff output (if success)
- FILES_CHANGED: list of files modified
IMPORTANT: Launch multiple agents in a SINGLE message using multiple Task tool calls.
Step 3: Process Completed Agents
When an agent returns:
-
Move group from ACTIVE_AGENTS to COMPLETED
-
Parse the agent's report
-
If STATUS == "success":
cd /Users/samberan/tjs git merge fix/GROUP --no-edit git worktree remove /tmp/tjs-fix-GROUP git branch -d fix/GROUPLog to TEST_FIXES.md (append):
## GROUP - DATE **Status:** ✅ Fixed **Tests Fixed:** TESTS_FIXED ### Description DESCRIPTION ### Files Changed FILES_CHANGED ### Diff ```diff DIFF
-
If STATUS == "partial":
- Merge if valuable, otherwise discard
- Log partial progress
-
If unsuccessful:
git worktree remove /tmp/tjs-fix-GROUP --force git branch -D fix/GROUPLog to TEST_FIXES.md (append):
## GROUP - DATE **Status:** ❌ STATUS **Blockers:** BLOCKERS **Reason:** DESCRIPTION ---
Step 4: Continue the Loop
After processing completed agents:
-
If ACTIVE_AGENTS is not full (< 3 agents) AND PENDING is not empty:
- Go to Step 2 to spawn more agents
-
If ACTIVE_AGENTS is empty AND PENDING is empty:
- Run final test:
npm test - Print summary of all fixes
- Exit loop
- Run final test:
-
If ACTIVE_AGENTS is not empty:
- Wait for more agents to complete
- Go to Step 3
Summary Report Format
At the end, print:
## Test Fix Summary
### Successfully Fixed
| Group | Tests Fixed | Description |
|-------|-------------|-------------|
| coercion-ref | 1 | Added ref resolution to coercion |
### Partial/Blocked
| Group | Status | Blocker |
|-------|--------|---------|
| content | blocked | Requires contentMediaType validation |
### Final Test Results
[Include final test counts]
Key Points
- No Duplicates: Check ACTIVE_AGENTS and COMPLETED before spawning
- Parallel Execution: Launch multiple Task tools in ONE message
- Continuous Loop: Keep spawning as agents complete
- Structured Reports: Agents return parseable results with diffs
- Log Everything: Append all results (success and failure) to TEST_FIXES.md
- Include Diffs: Successful fixes include full git diff in log
- Clean Up: Remove worktrees and branches after processing
- Merge Partials Carefully: Only merge partial fixes if they don't break anything
Known Skipped Test Groups
Coercion Tests (tests/runtime/coercion.test.ts)
- if-then-else coercion - Requires evaluating
ifschema to choose branch - coercion error messages - Custom error messages for coercion failures
Compliance Tests (tests/suite/compliance.test.ts)
SKIPPED_OPTIONAL_FILES:
- float-overflow - multipleOf with 1e308 (optional overflow handling)
- zeroTerminatedFloats - 1.0 vs 1 representation (language-specific)
- content - contentMediaType/contentEncoding validation
- cross-draft - Cross-draft $ref resolution
- format-assertion - Meta-schema format-assertion keyword
UNIMPLEMENTED_KEYWORDS:
- unknownKeyword - $id inside unknown keywords (meta-schema validation)
Priority Order
- if-then-else coercion - Most impactful, enables conditional type coercion
- content validation - Useful for API validation (JSON content-type)
- cross-draft refs - Important for schema reuse across versions
- float-overflow - Edge case, low priority
- format-assertion - Meta-schema feature, low priority
- unknownKeyword - Complex meta-schema parsing, low priority