用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/eron1703/claude-config-loader --skill testing命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
Load CI/CD pipeline configuration and deployment information when working with automation or deployments
Load database relationships, shared resources, and schema information when working with data models or database configuration
Load development environment information including folder structure, OrbStack setup, and system configuration
正在显示 SKILL.md
基于 SOC 职业分类
| name | testing |
| description | Access testing configuration and delegate to test-rig tool for test generation and execution |
| user-invocable | true |
Purpose: Multi-agent testing infrastructure for monoliths and microservices. Integrates test-rig CLI tool with Claude-based development workflows for rapid test creation and validation.
test-rig is globally installed at /opt/homebrew/bin/test-rig. Results return via stdout/stderr through the Bash tool.
# Navigate to your project directory and run test-rig commands via Bash
test-rig run
# 1. Initialize test infrastructure
test-rig setup
# 2. Generate tests for a component
test-rig generate user-service
# 3. Run tests
test-rig run
# 4. Check coverage
test-rig coverage
test-rig setupInitialize test infrastructure for the current project.
Behavior:
Usage:
test-rig setup
Flags:
--framework - Override framework detection (vitest, pytest, playwright)--skip-containers - Skip testcontainer setupExample:
test-rig setup --framework vitest
test-rig generate <component>Generate tests for a specific component or service.
Behavior:
tests/specs/<component>.spec.yamltests/unit/<component>/tests/integration/<component>/Usage:
test-rig generate user-service
test-rig generate payment-processor
Flags:
--type - Specify component type (service, controller, utility, model)--unit-only - Generate unit tests only (skip integration)--integration-only - Generate integration tests only (skip unit)Example:
test-rig generate auth-middleware --type controller
Current Status: Infrastructure complete. Some TODOs in test generation - consult generated specs for coverage gaps.
test-rig run [type]Run tests with flexible filtering and parallel execution.
Usage:
test-rig run # Run all tests
test-rig run unit # Unit tests only
test-rig run integration # Integration tests only
test-rig run e2e # End-to-end tests only
test-rig run --parallel # Multi-agent parallel execution
test-rig run unit --parallel # Run unit tests in parallel
Flags:
--parallel - Enable multi-agent parallel execution--agents <n> - Number of parallel agents (default: 4, max: 12)--coverage - Generate coverage report--watch - Watch mode (re-run on file changes)--timeout <ms> - Test timeout in milliseconds--bail - Stop on first test failure--verbose - Verbose outputExamples:
test-rig run --parallel --agents 8
test-rig run integration --coverage
test-rig run unit --watch
test-rig run --bail --verbose
test-rig coverageGenerate and display code coverage report.
Usage:
test-rig coverage # Generate coverage report
test-rig coverage --threshold 80 # Enforce minimum threshold
test-rig coverage --html # Generate HTML report
Flags:
--threshold <n> - Enforce minimum coverage percentage--html - Generate HTML report (output to coverage/)--lcov - Generate LCOV reportExample:
test-rig coverage --threshold 80 --html
test-rig analyzeAnalyze codebase for testability and identify gaps.
Usage:
test-rig analyze
Outputs:
test-rig doctorCheck test setup health and verify environment.
Usage:
test-rig doctor
Checks:
test-rig --help / test-rig --versionDisplay help information or version number.
test-rig --help
test-rig --version
Test-rig is designed to support Red-Green-Refactor cycles in collaborative development.
Use test-rig generate to scaffold tests based on component analysis:
# 1. Generate tests for new component
test-rig generate payment-service
# 2. View generated spec
cat tests/specs/payment-service.spec.yaml
# 3. Review generated unit tests
cat tests/unit/payment-service/
# 4. Run tests (should fail initially)
test-rig run unit
Claude's Role: Generate tests using component analysis, focusing on expected behavior and contracts.
Implement the component to pass generated tests:
# 1. Edit component source code
# 2. Run tests in watch mode
test-rig run unit --watch
# 3. Tests pass when implementation is complete
Claude's Role: Generate implementation code that satisfies test contracts.
# 1. Refactor code (improve structure, performance, readability)
# 2. Run tests continuously to ensure nothing breaks
test-rig run unit --watch
# 3. Commit only when tests pass
test-rig run && git commit
Claude's Role: Suggest refactoring opportunities while monitoring test status.
# Start fresh component
test-rig generate user-repository
# Run tests (red - should fail)
test-rig run unit
# Implement the component
# (edit src/repositories/user.ts)
# Run tests (green - should pass)
test-rig run unit
# Refactor and optimize
# (edit src/repositories/user.ts)
# Verify tests still pass
test-rig run unit
# Move to integration testing
test-rig generate user-service # Generate integration tests
test-rig run integration
When coding agents work together under supervisor guidance, test-rig enables coordination and verification.
Agent 1 (Feature Dev): Generate tests and implementation
test-rig generate new-feature
test-rig run unit --parallel
Agent 2 (Integration Dev): Verify cross-service contracts
test-rig run integration --parallel
Supervisor (Verification): Check overall health
test-rig doctor
test-rig coverage --threshold 80
Initialize: Setup shared test infrastructure
test-rig setup --framework vitest
Delegate: Direct agents to specific components
# Agent 1
test-rig generate auth-service
# Agent 2
test-rig generate payment-service
# Agent 3
test-rig generate notification-service
Monitor: Check status in parallel
test-rig doctor
test-rig run --parallel --agents 4
Validate: Ensure coverage and quality gates
test-rig coverage --threshold 80 --html
test-rig analyze
Coordinate: Verify integration points
test-rig run integration --parallel
test-rig spawns multiple agents to run tests in parallel, achieving 3-4x faster execution.
--parallelUse parallel execution when:
Avoid parallel execution when:
# Default: 4 agents
test-rig run --parallel
# Custom agent count
test-rig run --parallel --agents 8
# Run specific test type in parallel
test-rig run unit --parallel
test-rig run integration --parallel --agents 6
test-rig uses component specs (YAML) to organize tests for parallel execution:
# tests/specs/user-service.spec.yaml
component:
name: user-service
type: service
subcomponents:
- name: repository
test_file: tests/unit/user-service/repository.spec.ts
dependencies: [database]
- name: validator
test_file: tests/unit/user-service/validator.spec.ts
dependencies: []
- name: service
test_file: tests/unit/user-service/service.spec.ts
dependencies: [repository, validator]
Each agent:
# Run integration tests in parallel with testcontainer isolation
test-rig run integration --parallel --agents 4
Isolation Mechanism:
# Verbose mode shows per-agent progress
test-rig run --parallel --verbose
# Expected output:
# [Agent 1] Running component: user-service
# [Agent 2] Running component: payment-service
# [Agent 3] Running component: notification-service
# [Agent 1] ✓ user-service (1.2s)
# [Agent 2] ✗ payment-service (2.1s) - 3 failures
# GitHub Actions example
name: Tests
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- run: npm install -g @hcb-consulting/test-rig
- run: test-rig run --parallel --agents 4
You're starting a new Node.js project and need comprehensive test infrastructure.
Step 1: Initialize
cd ~/projects/my-new-project
test-rig setup
Step 2: Verify Structure
# Check generated structure
ls -la tests/
# Output:
# ├── specs/
# ├── unit/
# ├── integration/
# ├── e2e/
# ├── factories/
# ├── fixtures/
# ├── mocks/
# └── utils/
Step 3: Review Configuration
cat test-rig.config.yaml
Step 4: Test Execution
test-rig run
Example test-rig.config.yaml:
framework: vitest
parallel_agents: 4
containers:
- postgres:5432
- redis:6379
coverage_threshold:
unit: 80
integration: 60
You've created a new EmailService component and need comprehensive tests.
Step 1: Generate Tests
test-rig generate email-service
Step 2: Review Generated Spec
cat tests/specs/email-service.spec.yaml
Expected output shows component structure and dependencies.
Step 3: Review Generated Tests
ls tests/unit/email-service/
# Output:
# ├── email-service.spec.ts
# ├── smtp-client.spec.ts
# ├── template-engine.spec.ts
# └── ...
Step 4: Run and Verify
# Run unit tests for this component
test-rig run unit
# View coverage
test-rig coverage
Step 5: Add Integration Tests If integration tests weren't generated, create manually:
cat > tests/integration/email-service/delivery.spec.ts << 'EOF'
import { describe, it, expect, beforeAll, afterAll } from 'vitest';
import { EmailService } from '../../../src/services/email-service';
describe('EmailService Integration', () => {
let emailService: EmailService;
beforeAll(() => {
emailService = new EmailService({
smtpHost: process.env.SMTP_HOST || 'localhost',
smtpPort: 1025,
});
});
it('should send email through SMTP', async () => {
const result = await emailService.send({
to: 'test@example.com',
subject: 'Test',
body: 'Test email',
});
expect(result.success).toBe(true);
});
});
EOF
# Run integration tests
test-rig run integration
Ensure code quality and test passage before committing.
Setup Pre-commit Hook:
cat > .git/hooks/pre-commit << 'EOF'
#!/bin/bash
set -e
echo "Running tests before commit..."
test-rig run --bail
if [ $? -eq 0 ]; then
echo "✓ All tests passed"
else
echo "✗ Tests failed - commit aborted"
exit 1
fi
EOF
chmod +x .git/hooks/pre-commit
Manual Pre-commit Workflow:
# 1. Run all tests
test-rig run
# 2. If passing, check coverage
test-rig coverage
# 3. If coverage is acceptable, commit
git add .
git commit -m "Add feature X"
Fast Pre-commit (Unit Tests Only):
# For rapid feedback during development
test-rig run unit --bail
# Only run full suite before final commit
test-rig run
# .github/workflows/test.yml
name: Test Suite
on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
jobs:
test:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:14
env:
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: '18'
- name: Install test-rig
run: npm install -g @hcb-consulting/test-rig
- name: Run tests in parallel
# .gitlab-ci.yml
stages:
- test
test:
image: node:18
services:
- postgres:14
before_script:
- npm install -g @hcb-consulting/test-rig
script:
- test-rig run --parallel --agents 4
coverage: '/coverage: \d+\.\d+%/'
#!/bin/bash
# scripts/pre-deploy.sh
set -e
echo "Running pre-deployment tests..."
# 1. Run all tests
echo "Running test suite..."
test-rig run --parallel
# 2. Verify coverage thresholds
echo "Checking coverage..."
test-rig coverage --threshold 80
# 3. Analyze for issues
echo "Analyzing codebase..."
test-rig analyze
# 4. Check system health
echo "System health check..."
test-rig doctor
echo "✓ All pre-deployment checks passed"
Cause: test-rig is not globally installed or not in PATH.
Solution:
# Check if installed
which test-rig
# Install globally
npm install -g @hcb-consulting/test-rig
# Or use full path
/opt/homebrew/bin/test-rig run
Cause: Testcontainers are using ports that are already allocated.
Solution:
# Kill existing containers
docker ps -a | grep test-rig | awk '{print $1}' | xargs docker rm -f
# Run tests again
test-rig run --parallel
Cause: Testcontainers taking too long to start or network latency.
Solution:
# Increase timeout
test-rig run integration --timeout 30000
# Or reduce parallel agents to free resources
test-rig run integration --parallel --agents 2
Cause: Insufficient test coverage for the codebase.
Solution:
# 1. Analyze which code is untested
test-rig analyze
# 2. Generate tests for low-coverage components
test-rig generate low-coverage-component
# 3. Run and verify
test-rig run --parallel
test-rig coverage --html
# 4. Open HTML report
open coverage/index.html
Cause: test-rig's test generation is incomplete for complex components.
Solution:
# 1. Review generated spec
cat tests/specs/component-name.spec.yaml
# 2. Manually add missing subcomponents
# Edit the spec to include missing testable units
# 3. Generate additional tests
# Manually create test files for uncovered areas
# 4. Run and verify
test-rig run
Example Manual Spec Addition:
# tests/specs/user-service.spec.yaml
component:
name: user-service
type: service
subcomponents:
- name: repository
test_file: tests/unit/user-service/repository.spec.ts
dependencies: [database]
# TODO: Add validator subcomponent
# - name: validator
# test_file: tests/unit/user-service/validator.spec.ts
# dependencies: []
# Manually add missing subcomponent
- name: auth-middleware
test_file: tests/unit/user-service/auth-middleware.spec.ts
dependencies: [jwt]
Cause: Environment differences (database versions, missing services, timing).
Solution:
# 1. Check system health
test-rig doctor
# 2. Run with verbose output to see environment
test-rig run --verbose
# 3. Check CI environment matches local setup
# Verify test-rig.config.yaml container versions
# 4. Run tests with longer timeouts in CI
test-rig run --timeout 30000 --parallel --agents 4
# Development: Use test-rig for structure and automation
test-rig generate new-feature
test-rig run unit --watch
# Debugging: Drop into manual testing temporarily
# Run specific test file, use debugger
npm test -- tests/unit/problematic-component.spec.ts --inspect
# Pre-commit: Return to test-rig for comprehensive validation
test-rig run --bail
# CI/CD: test-rig for reproducible, parallel execution
test-rig run --parallel --agents 4
Create test-rig.config.yaml in your project root:
framework: vitest # vitest, pytest, or playwright
parallel_agents: 4
containers:
- postgres:5432
- redis:6379
- mongodb:27017
coverage_threshold:
unit: 80
integration: 60
overall: 75
timeouts:
unit: 10000 # milliseconds
integration: 30000
e2e: 60000
Configured test infrastructure for known projects:
Detailed documentation and examples available at:
Note: test-rig provides the infrastructure. Claude handles component analysis, test generation, and implementation logic through the Bash tool. Results come back via stdout/stderr immediately.