Test Execution Skill
Pattern: Coordinator-Cached Test Execution Status: OPERATIONAL - Specialized for multi-agent concurrent testing
When to Use This Skill
USE when:
- 3+ agents need test results simultaneously
- Multi-agent swarms testing in parallel
- Preventing port/resource conflicts is critical
- Distributed testing environments
DO NOT USE when:
- Single agent testing → Use
npm testdirectly - Code validation → Use
.claude/hooks/invoke-post-edit.sh - Simple test execution → Use
npm testdirectly - Development workflow → Use standard npm scripts
Problem Statement
Concurrent test execution causes conflicts, resource contention, and flaky results. Multiple agents running tests simultaneously creates:
- Port conflicts (test servers)
- Database/file system race conditions
- Unreliable coverage reports
- Wasted computation from duplicate test runs
Solution: Coordinator Pattern
Single Test Execution: One coordinator agent runs all tests once Cached Results: Results stored in Redis + JSON file Worker Reads: All other agents read cached results (never execute tests)
Implementation
Scripts Available
- test-coordinator-pattern.sh - Coordinator runs tests, caches to Redis
- test-cache-reader.sh - Workers read cached results
- test-concurrent-conflicts.sh - Validates coordinator pattern (20 runs)
Usage
Coordinator Agent (runs tests):
# Run tests once and cache results
./.claude/skills/test-execution/test-coordinator-pattern.sh swarm-123
Worker Agents (read cache):
# Read cached test results (waits for coordinator)
./.claude/skills/test-execution/test-cache-reader.sh swarm-123 worker-1
Validate Pattern:
# Test concurrent execution (20 cycles)
./.claude/skills/test-execution/test-concurrent-conflicts.sh
Workflow
1. Coordinator detects "run tests" signal
2. Coordinator terminates existing test processes
3. Coordinator runs: npm test -- --run --reporter=json
4. Results cached to:
- Redis: swarm:${SWARM_ID}:tests:metadata
- File: test-results.json
5. Workers wait for completion signal (max 5min timeout)
6. Workers read cached results
7. All agents use same test results (no conflicts)
Performance Metrics
- Test execution: 1x instead of Nx (N = number of agents)
- Cache read latency: <100ms
- Conflict prevention: 100% (validated with 20 concurrent runs)
- Resource savings: ~90% (no duplicate test processes)
Integration with Other Skills
- Post-Edit Hooks: Use
.claude/hooks/invoke-post-edit.shfor TypeScript validation (simpler, faster) - Redis Coordination: Uses same Redis pub/sub infrastructure
- CFN Loop Validation: Can integrate test results into consensus calculation
Current Project Status
Active Tests: None in /src (legacy tests in /packages)
Jest Configuration: Installed (29.7.0) but not actively used
Recommendation: Skill is operational but currently unnecessary. Use npm test directly for development.
Future Use Cases
When multi-agent swarms become active and need concurrent testing:
- Designate one agent as test coordinator
- Coordinator uses
test-coordinator-pattern.sh - Workers use
test-cache-reader.sh - Validate with
test-concurrent-conflicts.sh