Skip to main content
ClaudeWave
Slash Command894 repo starsupdated 2d ago

test-tdd

The /test-tdd slash command identifies modified source files in a repository using git status, locates their corresponding test files by matching naming patterns across common test directories, determines the appropriate test runner from package.json or file type, and executes those tests. Use this command to quickly validate changes during development by running only the tests relevant to modified code.

Install in Claude Code
Copy
mkdir -p ~/.claude/commands && curl -fsSL https://raw.githubusercontent.com/guanyang/open-agent-hub/HEAD/commands/test-tdd.md -o ~/.claude/commands/test-tdd.md
Then start a new Claude Code session; the slash command loads automatically.

test-tdd.md

# Slash Command: /test-tdd

## Core Objective
Locate and execute the test suites corresponding to modified files.

## Steps for the Agent
1. **Identify Modified Code**: Run `git status` or `git diff --name-only` to identify source code files that have changed.
2. **Find Matching Tests**: Search for matching test files in the project. For example:
   - `foo.js` ➔ search for `foo.test.js`, `foo.spec.js`, `test_foo.js` in `test/`, `spec/`, or local directories.
3. **Deduce Test Command**: Determine the correct command runner based on `package.json` scripts or file types (e.g., `npm test -- <file>`, `npx jest <file>`, `pytest <file>`, `go test <file>`).
4. **Execute**: Run the test command and display the execution results.
5. **Loop Strategy**:
   - If tests fail, suggest invoking [agent-debugger](../agents/agent-debugger.md) to inspect stack traces.