Skip to main content
ClaudeWave
ES, Spanish
Slash Command1.4k estrellas del repoactualizado 22d ago

add-tests

The add-tests command automatically generates comprehensive test suites for specified source files or recently modified code lacking coverage. Use this when onboarding new code to a project, after refactoring existing functions, or to improve test coverage on files that changed in recent commits. The command detects the project's test framework, analyzes code behavior and edge cases, and creates tests following existing project conventions.

Instalar en Claude Code
Copiar
mkdir -p ~/.claude/commands && curl -fsSL https://raw.githubusercontent.com/CloudAI-X/claude-workflow-v2/HEAD/commands/add-tests.md -o ~/.claude/commands/add-tests.md
Después abre una sesión nueva de Claude Code; el slash command carga automáticamente.

add-tests.md

## Context

- Recently modified files: !`git diff --name-only HEAD~3 2>/dev/null | grep -E '\.(ts|tsx|js|jsx|py|go|rs)$' | head -10 || echo "No recent changes"`
- Test framework detection: !`cat package.json 2>/dev/null | grep -E '"(jest|vitest|mocha)"' | head -1 || ls pytest.ini pyproject.toml 2>/dev/null | head -1 || echo "Unknown test framework"`
- Existing test files: !`find . -name "*test*" -o -name "*spec*" 2>/dev/null | grep -E '\.(ts|tsx|js|jsx|py|go)$' | head -10 || echo "No test files found"`
- Test directory structure: !`ls -la tests/ test/ __tests__/ spec/ 2>/dev/null | head -20 || echo "No standard test directory"`

## Task

Add tests for the specified target:

1. Identify the file/function to test
2. Find the corresponding test file (or create one following project conventions)
3. Analyze the code to understand:
   - Input/output behavior
   - Edge cases
   - Error conditions
4. Write comprehensive tests covering:
   - Happy path
   - Edge cases
   - Error handling
5. Run the tests to verify they pass

Target: $ARGUMENTS

If no target specified, focus on recently modified files that lack test coverage.