智能测试运行
test
智能测试运行器,针对变更的代码进行测试并识别覆盖率缺口。用于运行测试、查找覆盖率缺口或测试变更的代码。
- License 许可
- MIT
- 所属仓库
- drn/dots
- 最近更新
- 2026-11-12
- Stars
- ★ 23
- Forks
- 4
01 前言 Front Matter
- name
- test
- description
- Intelligent test runner that targets changed code and identifies coverage gaps. Use for running tests, finding coverage gaps, or testing changed code.
03 SKILL.md 正文
Smart Test Runner
Analyze recent changes, run targeted tests, identify coverage gaps, and optionally write missing tests.
Arguments
$ARGUMENTS- Optional:--fullfor full test suite,--writeto auto-write missing tests, or a specific file/directory to test
Context
- Project type: !
find . -maxdepth 1 \( -name go.mod -o -name Gemfile -o -name package.json -o -name Cargo.toml -o -name pyproject.toml -o -name setup.py -o -name requirements.txt -o -name pom.xml -o -name build.gradle -o -name Makefile \) 2>/dev/null | head -5 - Changed files: !
git diff --name-only HEAD~1 2>/dev/null | head -50 - Test files: !
find . -maxdepth 4 \( -name "*_test.*" -o -name "*.test.*" -o -name "*_spec.*" -o -name "test_*" \) 2>/dev/null | head -20 - Git status: !
git status --short
Instructions
Step 1: Detect Test Framework
From the project type context above, determine:
| Indicator | Framework | Run Command |
|---|---|---|
go.mod |
Go test | go test ./... |
Gemfile |
RSpec or Minitest | bundle exec rspec or bundle exec rake test |
package.json |
Jest, Vitest, or Mocha | npm test or npx jest or npx vitest |
pyproject.toml / requirements.txt |
pytest or unittest | pytest or python -m pytest |
Cargo.toml |
cargo test | cargo test |
pom.xml / build.gradle |
JUnit | mvn test or gradle test |
If you can't detect a test framework, tell the user and ask how to run tests.
Step 2: Determine Test Scope
IF $ARGUMENTS contains "--full":
Run the full test suite
ELSE IF $ARGUMENTS contains a specific file or directory:
Run tests for that target only
ELSE:
Analyze changed files and map them to test files:
1. For each changed file, look for corresponding test file:
- Go: foo.go → foo_test.go
- Ruby: app/models/user.rb → spec/models/user_spec.rb
- JS/TS: src/utils.ts → src/utils.test.ts or __tests__/utils.test.ts
- Python: module.py → test_module.py or tests/test_module.py
- Rust: src/lib.rs → tests in same file or tests/ directory
2. Run only the mapped test files
3. If no test files map to the changes, run the full suite
Step 3: Run Tests
Run the determined tests. Capture output including:
- Pass/fail status for each test
- Failure messages with file and line numbers
- Total counts: passed, failed, skipped
If tests fail, read the failing test files and the source files they test to understand the failures.
Step 4: Measure and Analyze Coverage
First, try to use the project's coverage tool if available:
| Framework | Coverage Command |
|---|---|
| Go | go test -coverprofile=coverage.out ./... && go tool cover -func=coverage.out |
| pytest | pytest --cov --cov-report=term-missing |
| Jest | npx jest --coverage |
| RSpec | Coverage via simplecov (runs automatically if in Gemfile) |
| cargo | cargo tarpaulin (if installed) |
If a coverage tool ran, report the coverage percentage and uncovered lines.
If no coverage tool is available, fall back to manual analysis. Read each changed file and its corresponding test file (if any). Identify:
- Untested functions/methods -- changed code with no corresponding test
- Missing edge cases -- tests exist but don't cover error paths, boundary values, or nil/empty inputs
- New code without tests -- newly created files with no test file
Report each gap with: file, function/method, what's missing.
Step 5: Write Tests (if requested)
IF $ARGUMENTS contains "--write" OR user confirms:
For each coverage gap identified:
1. Write a test following existing test patterns in the project
2. Use the same test framework, naming conventions, and style
3. Run the new test to verify it passes
4. Report what was written
Step 6: Write Phase Artifact
This skill participates in a phase chain (see ~/.claude/skills/_shared/resources/phase-protocol.md).
After tests complete, write a test-{ts}.md artifact to .context/phases/ (create with mkdir -p .context/phases). The Detail section should include pass/fail status, coverage metrics, and failing test details. The Handoff section should state: ready to ship or needs fixes (with specifics).
Step 7: Report
## Test Results
### Run Summary
- **Framework:** {detected framework}
- **Scope:** {targeted / full suite}
- **Status:** PASS / FAIL
- **Passed:** {N} | **Failed:** {N} | **Skipped:** {N}
### Failures (if any)
| Test | File | Error |
|------|------|-------|
| {test name} | {file:line} | {brief error} |
### Coverage Gaps
| Source File | Function/Method | Gap |
|-------------|-----------------|-----|
| {file} | {function} | {what's missing} |
### New Tests Written (if --write)
| Test File | Tests Added | Covers |
|-----------|-------------|--------|
| {file} | {N} | {what it tests} |
### Recommendation
{1-2 sentences: overall health and what to do next}
04 同仓库更多 Skills
batch-pr-review
Review a batch of pull requests together, describe every change in plain language, and build a private Claude artifact that eases human review, with a severity-tagged and verified findings list. Use when asked to review several PRs, a stack of PRs, PRs listed in a Slack thread or message, or to summarize a batch of PRs for a reviewer.
Codex 目标设置包生成
plannotator-setup-goal
为长时间运行的 /goal 工作创建经过审查的 Codex 目标设置包。当用户想把想法、待办清单、项目使命或模糊目标,转化为项目 goals slug 文件夹下的持久化目标文件时使用;包含 Plannotator 审查关卡,覆盖简报、带验收标准的叙述性计划、验证方案、阻碍项,以及最终的 /goal 提示词。
plannotator-annotate
Open Plannotator's annotation UI for a markdown file, converted HTML file, URL, or folder and then respond to the returned annotations.
Claude 技能编写
write-skill
创建或改进 Claude Code 技能/斜杠命令,遵循结构、动态上下文和安全性方面的最佳实践。用于创建新技能、改进现有技能,或学习技能编写。
会话收尾检查
wrapup
会话结束时的检查清单,用于检测遗漏事项——未提交的变更、未合并的分支、需记录的经验教训、需完成的交接——并路由到相应的技能。用于会话收尾、结束工作、一天结束,或“还有其他要记录的吗”。
文本转语音朗读
tts
使用文本转语音(text-to-speech)大声朗读文本。当用户说“读给我听”“念给我听”“大声朗读这个”“说出这个”“朗读摘要”,或要求听到某内容被朗读时使用。