Files
Claude Agent 45e28e7e94 feat(workflow): Add workflow plugin v1.0.0
Git workflow, code quality, context management and testing commands:
- commit, push, pr, issue - git operations
- simplify, refactor, verify, check - code quality
- catchup, onboard, save, cleanup - context management
- test, format, sync - development utilities

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-22 15:23:48 +00:00

2.6 KiB

description: Smart test runner - runs tests for changed files only argument-hint: [pattern] - Optional test pattern or file to run

Smart Test Runner

Pre-computed Context

Test Framework Detection: !cat package.json 2>/dev/null | grep -E '"(jest|vitest|mocha|ava|tape)"' | head -3 || echo "No JS test framework"

Python Test Framework: !cat pyproject.toml setup.cfg 2>/dev/null | grep -E '(pytest|unittest|nose)' | head -3 || echo "No Python test framework"

Test Scripts: !cat package.json 2>/dev/null | grep -E '"test' | head -5 || echo "No test scripts"

Changed Files: !git diff --name-only HEAD~3 2>/dev/null | head -10

Related Test Files: !git diff --name-only HEAD~3 2>/dev/null | sed 's/\.\(ts\|tsx\|js\|jsx\)$/.test.\1/' | xargs -I{} sh -c 'test -f {} && echo {}' 2>/dev/null | head -5


Instructions

You are running tests intelligently - focusing on changed files when possible.

Detect Test Framework

JavaScript/TypeScript

  1. Jest
npx jest --passWithNoTests
  1. Vitest
npx vitest run
  1. npm test script
npm test

Python

  1. pytest
pytest -v
  1. unittest
python -m unittest discover

Smart Test Selection

If no argument provided, run tests related to changed files:

npx jest --findRelatedTests $(git diff --name-only HEAD~3 | tr '\n' ' ')

Jest - Run changed test files only

npx jest --testPathPattern="$(git diff --name-only HEAD~3 | grep -E '\.test\.(ts|tsx|js|jsx)$' | tr '\n' '|' | sed 's/|$//')"

Vitest - Run changed

npx vitest run --changed HEAD~3

pytest - Run specific files

pytest $(git diff --name-only HEAD~3 | grep -E '_test\.py$|test_.*\.py$' | tr '\n' ' ')

With Pattern Argument

If argument provided, run tests matching that pattern:

# Jest
npx jest --testPathPattern="$ARGUMENTS"

# Vitest
npx vitest run "$ARGUMENTS"

# pytest
pytest -k "$ARGUMENTS"

Test Output

Show test results with appropriate verbosity:

# Jest with coverage
npx jest --coverage --passWithNoTests

# pytest verbose
pytest -v --tb=short

On Failure

If tests fail:

  1. Show the failing test names
  2. Show the error messages
  3. Identify the source file that likely caused the failure
  4. Suggest fix or ask if you should investigate

Common Options

Run all tests:

/workflow:test --all

Run with coverage:

/workflow:test --coverage

Run in watch mode:

npx jest --watch
# or
npx vitest

Run specific test file:

/workflow:test src/utils.test.ts