test
Smart test runner that scopes tests based on changed files
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Smart test runner that scopes tests based on changed files
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Automatically implement all sub-issues of an epic in dependency order
Implement a GitHub issue with automated PR creation
End-of-session retrospective. Captures knowledge from any working session (debug, implementation, config, deployment) as reusable scripts, CLAUDE.md procedures, or skill proposals. Run before ending a session to prevent knowledge loss.
Decompose a large GitHub issue into sub-issues and create a tracking draft PR
OWASP-guided security code review for a specific domain or issue
Project kickoff checklist based on lessons learned from previous projects. Generates a tailored checklist and optionally creates GitHub issues.
| name | test |
| description | Smart test runner that scopes tests based on changed files |
| argument-hint | [--all|--affected] |
| user-invocable | true |
Run tests scoped to your changes. Avoids the false choice between running specific tests manually or the entire suite.
Mode is determined by $ARGUMENTS:
--affected: run tests affected by current changes (default)--all: run the full test suiteCheck which test frameworks are available:
pyproject.toml with [tool.pytest], pytest.ini, setup.cfg with [tool:pytest], or a tests/ directory with test_*.py filespackage.json with jest in dependencies/devDependencies, jest.config.*, or __tests__/ directoriesvitest.config.* or package.json with vitestStore the detected framework(s). If multiple are detected (e.g., pytest for backend + jest for frontend), handle both.
git diff --name-only
git diff --cached --name-only
Combine both lists (unstaged + staged changes). Exclude non-source files: *.md, *.json, *.yaml, *.yml, *.toml, *.cfg, *.ini, *.txt, *.lock, *.svg, *.png, *.jpg.
For each changed source file, find related test files using these strategies:
Strategy 1 — Naming conventions:
src/auth.py → search for **/test_auth*.py and **/auth_test.pysrc/Login.tsx → search for **/Login.test.*, **/Login.spec.*src/services/auth.py → also try tests/services/test_auth*.pyStrategy 2 — Import analysis:
**/test_*.py or **/*.test.*), use Grep to check if it imports the changed moduleStrategy 3 — Changed test files:
Determine if changes touch integration-sensitive areas:
**/routes/**, **/views/**, **/controllers/**, **/api/****/models/**, **/schemas/**, **/entities/****/middleware/**, **/auth/**, **/security/****/migrations/**, **/alembic/**Run only the test files mapped from Phase 2.
For pytest:
~/.claude/bin/project-test.sh <test_file_1> <test_file_2> ... -v
For jest:
npx jest --testPathPattern="<pattern>" --verbose
If no test files were mapped: report "No affected tests found for the changed files" and stop (unless --all was specified).
Report results: passed, failed, skipped counts + failure details.
Only runs if: Tier 1 passed AND changed files include integration-sensitive areas (routes, models, middleware, database).
Look for integration test directories:
tests/integration/, tests/e2e/, __tests__/integration/*integration*, *e2e*Run the integration tests:
~/.claude/bin/project-test.sh tests/integration/ -v
Report results separately from Tier 1.
--all)Run the complete test suite:
~/.claude/bin/project-test.sh -v
Or for JS:
npx jest --verbose
Generate the test report:
## Test Report
**Mode:** affected / all
**Framework:** pytest / jest / vitest
**Changed files:** <count> source files
### Change → Test Mapping
| Source File | Test File(s) | Strategy |
|------------|-------------|----------|
| src/auth.py | tests/test_auth.py | naming |
| src/utils.py | tests/test_helpers.py | import |
| src/models.py | — | no test found |
### Results
| Tier | Scope | Passed | Failed | Skipped |
|------|-------|--------|--------|---------|
| 1 — Affected | 3 test files | 24 | 0 | 2 |
| 2 — Integration | tests/integration/ | 8 | 0 | 0 |
### Failures (if any)
<For each failure: test name, assertion error, relevant output>
### Verdict
**<ALL PASS / FAILURES>**
If there are failures, include the full assertion error and relevant context so the user can decide whether to fix or investigate further.