一键导入
test-runner
Run the relevant tests for the current change and summarize results. Use in Flow 3 (Build) and optionally in Flow 5 (Gate).
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Run the relevant tests for the current change and summarize results. Use in Flow 3 (Build) and optionally in Flow 5 (Gate).
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Run linters/formatters on changed files and apply safe, mechanical fixes. Use in Flow 3 and Flow 4.
Open questions register. Use for: QID generation, OQ-SIG-001 format IDs, append questions, open_questions.md. Generate sequential QIDs, append questions with context. Use in clarifier when registering open questions instead of guessing. Invoke via bash .claude/scripts/demoswarm.sh openq next-id|append.
Run policy-as-code checks (e.g., OPA/Conftest) based on the policy_plan. Use in Flow 2 and Flow 4.
Grep/wc replacement for .runs artifacts. Use for: count, extract, Machine Summary, receipt reading, marker counts. Null-safe counting (REQ/NFR/QID/RSK markers), YAML block parsing, BDD scenario counting. Deterministic read-only - no judgment. Use when cleanup agents need mechanical counts/extraction. Invoke via bash .claude/scripts/demoswarm.sh.
Update index.json status. Use for: upsert index.json, update status/last_flow/updated_at. Deterministic writes - stable diffs, no creation. Use only in run-prep and *-cleanup agents. Invoke via bash .claude/scripts/demoswarm.sh index upsert-status.
Publish gate secrets scanning. Use for: safe_to_publish, scan for secrets, redact in-place. Determines publish gate status. Scan files for secrets (locations only - NEVER prints secret content). GitHub tokens, AWS keys, private keys, bearer tokens. Use ONLY in secrets-sanitizer. Invoke via bash .claude/scripts/demoswarm.sh secrets scan|redact.
| name | test-runner |
| description | Run the relevant tests for the current change and summarize results. Use in Flow 3 (Build) and optionally in Flow 5 (Gate). |
| allowed-tools | Bash, Read, Write |
You are a helper for running tests in this repository.
The test-runner is a mechanical skill that executes tests and captures output. It does not make judgment calls about test quality or coverage. Those decisions belong to agents (test-critic, test-author).
Execute the repository's test suite with appropriate scoping and capture structured output for downstream agents. The skill:
What this skill does NOT do:
| Context | Selection Strategy | Example |
|---|---|---|
| AC loop (Flow 3) | AC-scoped, fail-fast | Run only tests for AC-001 |
| Post-AC verification | Changed-file scope | Tests for files touched in this AC |
| Global hardening (Flow 3) | Full suite | All tests after all ACs complete |
| Gate verification (Flow 5) | Full suite, no fail-fast | Comprehensive verification |
| Quick sanity check | Smoke tests only | Fast feedback during iteration |
Use when: Global hardening, Gate verification, or no scope information available.
# Rust
cargo test --workspace --tests --color=always
# Python (pytest)
pytest --color=yes -v
# JavaScript (jest)
npm test -- --colors
# Go
go test ./...
Use when: Focused verification of what changed since main.
# Get changed files
git diff --name-only origin/main...HEAD
# Filter to test files and run those specifically
# (Framework-specific filtering)
Use when: Implementation changed, need to run tests that exercise that code.
For Rust:
cargo test -p <crate> -- <test-name-pattern>
cargo test --test <integration-test-name>
For pytest:
pytest tests/unit/test_<module>.py -v
pytest -k "auth or login"
Use when: Verifying a specific Acceptance Criterion in the AC loop.
Test naming conventions for AC filtering:
test_ac_001_* (name prefix)@AC-001 marker/tagtests/ac_001_*.py# pytest with marker
pytest -m "AC_001" --color=yes
# cargo test with pattern
cargo test ac_001
# jest with pattern
npm test -- --testNamePattern="AC-001"
Use when: Quick sanity check, not full verification.
# If smoke marker exists
pytest -m smoke --color=yes
# Or first N tests
pytest --maxfail=5 -x
# Full suite
cargo test --workspace --tests --color=always
# Specific crate
cargo test -p <crate-name>
# Pattern match
cargo test <pattern>
# Single test
cargo test <full::path::to::test>
# Integration test file
cargo test --test <name>
# With fail-fast (implicit with --test-threads=1)
cargo test -- --test-threads=1
# Full suite
pytest --color=yes -v
# Specific file
pytest tests/unit/test_auth.py -v
# Pattern match
pytest -k "login or session" -v
# Marker-based
pytest -m "unit" -v
pytest -m "AC_001" -v
# Fail-fast
pytest -x --color=yes
# With coverage
pytest --cov=src --cov-report=term-missing
# Full suite
npm test -- --colors
# Specific file
npm test -- --colors tests/auth.test.ts
# Pattern match
npm test -- --testNamePattern="login"
# Fail-fast
npm test -- --bail --colors
# With coverage
npm test -- --coverage
# Full suite
go test ./...
# Specific package
go test ./pkg/auth/...
# Pattern match
go test -run "TestLogin" ./...
# Fail-fast
go test -failfast ./...
# Verbose
go test -v ./...
Save raw test output to test_output.log (overwrite per run).
Save parsed summary to test_summary.md with this structure:
# Test Summary
## Overall Status
- **Result:** PASS | FAIL
- **Exit Code:** <int>
- **Duration:** <time>
## Counts
- Passed: <int>
- Failed: <int>
- Skipped: <int>
- xfailed: <int>
- xpassed: <int>
## Failing Tests (if any)
- `path::to::test_name` - <short error>
- `path::to::other_test` - <short error>
## Top Error Snippets
<first 5-10 lines of first failure>
For machine parsing, include a canonical line:
passed=15 failed=2 skipped=1 xfailed=0 xpassed=0
Use null for any count that cannot be reliably extracted.
| Code | Meaning |
|---|---|
| 0 | All tests passed |
| 1+ | One or more tests failed |
| null | Command could not execute |
When tests fail:
test_output.logtest_summary.mdThe test-runner skill does not fix failing tests. It reports results. Routing decisions belong to the orchestrator. Fixes belong to code-implementer or test-author.
The test-runner itself does not classify flakiness. However, it should:
For actual flakiness classification, the orchestrator routes to flakiness-detector, which:
The test-executor agent invokes this skill and writes the formal artifact:
.runs/<run-id>/build/test_execution.mdThe test-executor handles:
The test-author agent may invoke this skill to verify tests work:
The flakiness-detector reads test-runner output to understand what failed, then re-runs to classify. It does not call test-runner directly; it runs tests itself with a rerun budget.
If demo-swarm.config.json exists, read test commands from:
{
"commands": {
"test": "cargo test --workspace --tests --color=always",
"test_scoped": "cargo test -p {crate}",
"test_ac": "cargo test {ac_pattern}"
},
"flakiness": {
"budget_seconds": 180,
"rerun_count": 3,
"command": null
}
}
If no config exists, detect the stack:
Cargo.toml present → Rust/cargo testpackage.json with test script → npm testpytest.ini or pyproject.toml → pytestgo.mod present → go testDo not invent commands. If detection fails, record missing_required and bounce to pack-customizer.
# Run tests for AC-001 only, fail-fast
cargo test ac_001 -- --test-threads=1
Output in test_summary.md:
# Test Summary
## Overall Status
- **Result:** FAIL
- **Exit Code:** 1
- **Duration:** 4.2s
## Counts
- Passed: 3
- Failed: 1
- Skipped: 0
## Failing Tests
- `auth::tests::test_ac_001_invalid_password` - assertion failed: expected 401, got 200
cargo test --workspace --tests --color=always
Output:
# Test Summary
## Overall Status
- **Result:** PASS
- **Exit Code:** 0
- **Duration:** 45.3s
## Counts
- Passed: 127
- Failed: 0
- Skipped: 3
- xfailed: 2
- xpassed: 0
## Notes
- 3 tests skipped: require external service
- 2 xfail tests: known issues tracked in #123, #124
# Identify changed files
git diff --name-only origin/main...HEAD | grep '\.rs$'
# Run tests for changed crates
cargo test -p auth_service -p session_manager
Symptom: cargo: command not found or similar.
Solution: This is an environment issue. Record as ENV_TOOLING and bounce to fix environment. Do not continue with broken tooling.
Symptom: Test output does not match expected format.
Solution: Record counts as null rather than guessing. Note the parsing issue in summary. The skill contract is to report accurately, not to fabricate.
Symptom: Tests do not complete within reasonable time.
Solution: Note the timeout in summary. If the run was partial, include whatever counts were observed. Record as potentially flaky for flakiness-detector to investigate.
Symptom: Test command runs but finds nothing to test.
Solution: This is valid output. Report passed=0 failed=0 skipped=0. The orchestrator decides if this is expected (new feature without tests yet) or a problem (tests deleted).
Prefer scoped test runs:
git diff --name-only origin/main...HEAD to list changed files when available.Runtime flags and run bounds:
Capture output and artifacts:
test_output.log (overwrite per run) and a parsed summary to test_summary.md.test_summary.md should include: overall status (PASS/FAIL), failing test names, top error snippets, and counts.Failure handling:
test_summary.md.Do not modify source or tests.
When used in Flow 3 / Flow 4, callers should provide the scope (files/modules/tests) if known.