test-detect

Auto-detect testing framework and run relevant tests. Identifies Jest, Vitest, Playwright, Cypress, pytest, Go test, and others. Can run all tests, specific file tests, or generate basic tests for new code. Usage - /test-detect, /test-detect src/auth/login.ts, /test-detect generate src/utils.ts

24,269 stars

Best use case

test-detect is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Auto-detect testing framework and run relevant tests. Identifies Jest, Vitest, Playwright, Cypress, pytest, Go test, and others. Can run all tests, specific file tests, or generate basic tests for new code. Usage - /test-detect, /test-detect src/auth/login.ts, /test-detect generate src/utils.ts

Teams using test-detect should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/test-detect/SKILL.md --create-dirs "https://raw.githubusercontent.com/davila7/claude-code-templates/main/cli-tool/components/skills/development/test-detect/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/test-detect/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How test-detect Compares

Feature / Agenttest-detectStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Auto-detect testing framework and run relevant tests. Identifies Jest, Vitest, Playwright, Cypress, pytest, Go test, and others. Can run all tests, specific file tests, or generate basic tests for new code. Usage - /test-detect, /test-detect src/auth/login.ts, /test-detect generate src/utils.ts

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

Related Guides

SKILL.md Source

# Test Detect

Automatically detect the testing framework in the current project and run the right tests.

## Workflow

### Step 1: Detect the testing framework

Check for these files in order (first match wins):

| Check | Framework | Run Command |
|-------|-----------|-------------|
| `vitest.config.*` exists OR `vitest` in devDeps | **Vitest** | `npx vitest run` |
| `jest.config.*` exists OR `jest` in devDeps | **Jest** | `npx jest` |
| `playwright.config.*` exists | **Playwright** | `npx playwright test` |
| `cypress.config.*` exists | **Cypress** | `npx cypress run` |
| `pytest.ini` or `conftest.py` or `pyproject.toml` with `[tool.pytest]` | **pytest** | `python -m pytest` |
| `go.mod` exists | **Go test** | `go test ./...` |
| `Cargo.toml` exists | **Rust/cargo** | `cargo test` |
| `mix.exs` exists | **ExUnit** | `mix test` |
| `Gemfile` with `rspec` | **RSpec** | `bundle exec rspec` |
| `package.json` has `scripts.test` | **npm test** | `npm test` |

Report the detected framework before proceeding.

### Step 2: Parse arguments

Check `$ARGUMENTS` for the mode:

- **No arguments** or **"all"**: Run the full test suite (Step 3)
- **File path** (e.g., `src/auth/login.ts`): Run tests for that file (Step 4)
- **"generate" + file path** (e.g., `generate src/utils.ts`): Generate tests (Step 5)

### Step 3: Run full test suite

Run the detected test command. After completion:

- Report total tests, passed, failed, skipped
- If tests fail, show the first 3 failure messages with file:line references
- Suggest: "Run `/test-detect <failing-file>` to investigate a specific failure"

### Step 4: Run tests for a specific file

Given a source file path, find its test file:

**Search strategy** (try in order):
1. `__tests__/<filename>.test.<ext>` (Jest convention)
2. `<filename>.test.<ext>` (co-located)
3. `<filename>.spec.<ext>` (alternative convention)
4. `test/<filename>_test.<ext>` (Go/Python convention)
5. `tests/test_<filename>.<ext>` (pytest convention)
6. `<filename>_test.go` (Go convention)

Use Glob to find matches. If found, run only that test file:

| Framework | Command |
|-----------|---------|
| Vitest | `npx vitest run <test-file>` |
| Jest | `npx jest <test-file>` |
| Playwright | `npx playwright test <test-file>` |
| pytest | `python -m pytest <test-file>` |
| Go | `go test -run <TestName> ./<package>/` |
| Cargo | `cargo test <test_name>` |

If no test file found, ask: "No tests found for this file. Want me to generate them? Run `/test-detect generate <file>`"

### Step 5: Generate tests

Read the source file and analyze:
1. Identify all exported functions/classes/components
2. Determine the appropriate test patterns for the framework
3. Generate a test file with:
   - Import statements
   - `describe` block per function/class
   - `it`/`test` blocks covering: happy path, edge cases, error cases
   - Framework-appropriate assertions and mocking

**Save to the conventional location** for the detected framework:
- Jest/Vitest: `__tests__/<filename>.test.<ext>` or `<filename>.test.<ext>` (match existing convention)
- pytest: `tests/test_<filename>.py`
- Go: `<filename>_test.go` (same directory)
- RSpec: `spec/<filename>_spec.rb`

Show the generated file path and ask if the user wants to run the new tests.

## Tips

- If multiple frameworks are detected (e.g., Vitest for unit tests + Playwright for e2e), mention both and default to the unit test framework
- For monorepos, detect from the closest config file to the current directory
- If `package.json` has both `test` and `test:unit`/`test:e2e` scripts, prefer the specific one when context is clear

Related Skills

web-security-testing

24269
from davila7/claude-code-templates

Web application security testing workflow for OWASP Top 10 vulnerabilities including injection, XSS, authentication flaws, and access control issues.

api-security-testing

24269
from davila7/claude-code-templates

API security testing workflow for REST and GraphQL APIs covering authentication, authorization, rate limiting, input validation, and security best practices.

python-testing-patterns

24269
from davila7/claude-code-templates

Implement comprehensive testing strategies with pytest, fixtures, mocking, and test-driven development. Use when writing Python tests, setting up test suites, or implementing testing best practices.

k6-load-testing

24269
from davila7/claude-code-templates

Comprehensive k6 load testing skill for API, browser, and scalability testing. Write realistic load scenarios, analyze results, and integrate with CI/CD.

javascript-testing-patterns

24269
from davila7/claude-code-templates

Comprehensive guide for implementing robust testing strategies in JavaScript/TypeScript applications using modern testing frameworks and best practices.

e2e-testing-patterns

24269
from davila7/claude-code-templates

Build reliable, fast, and maintainable end-to-end test suites that provide confidence to ship code quickly and catch regressions before users do.

Cross-Site Scripting and HTML Injection Testing

24269
from davila7/claude-code-templates

This skill should be used when the user asks to "test for XSS vulnerabilities", "perform cross-site scripting attacks", "identify HTML injection flaws", "exploit client-side injection vulnerabilities", "steal cookies via XSS", or "bypass content security policies". It provides comprehensive techniques for detecting, exploiting, and understanding XSS and HTML injection attack vectors in web applications.

WordPress Penetration Testing

24269
from davila7/claude-code-templates

This skill should be used when the user asks to "pentest WordPress sites", "scan WordPress for vulnerabilities", "enumerate WordPress users, themes, or plugins", "exploit WordPress vulnerabilities", or "use WPScan". It provides comprehensive WordPress security assessment methodologies.

SSH Penetration Testing

24269
from davila7/claude-code-templates

This skill should be used when the user asks to "pentest SSH services", "enumerate SSH configurations", "brute force SSH credentials", "exploit SSH vulnerabilities", "perform SSH tunneling", or "audit SSH security". It provides comprehensive SSH penetration testing methodologies and techniques.

SQLMap Database Penetration Testing

24269
from davila7/claude-code-templates

This skill should be used when the user asks to "automate SQL injection testing," "enumerate database structure," "extract database credentials using sqlmap," "dump tables and columns from a vulnerable database," or "perform automated database penetration testing." It provides comprehensive guidance for using SQLMap to detect and exploit SQL injection vulnerabilities.

SQL Injection Testing

24269
from davila7/claude-code-templates

This skill should be used when the user asks to "test for SQL injection vulnerabilities", "perform SQLi attacks", "bypass authentication using SQL injection", "extract database information through injection", "detect SQL injection flaws", or "exploit database query vulnerabilities". It provides comprehensive techniques for identifying, exploiting, and understanding SQL injection attack vectors across different database systems.

SMTP Penetration Testing

24269
from davila7/claude-code-templates

This skill should be used when the user asks to "perform SMTP penetration testing", "enumerate email users", "test for open mail relays", "grab SMTP banners", "brute force email credentials", or "assess mail server security". It provides comprehensive techniques for testing SMTP server security.