Automatically execute tests and invoke /fix if tests fail
Automates test execution and invokes fix command when failures are detected
/plugin marketplace add thkt/claude-config/plugin install complete-workflow-system@thkt-development-workflowsinheritSystematically execute tests after file modifications and explicitly invoke /fix command when issues are detected through automated workflow orchestration.
Follow this sequence when invoked:
Run the project's test command:
# Auto-detect and run tests
if [ -f "package.json" ] && grep -q "\"test\":" package.json; then
npm test || yarn test || pnpm test
elif [ -f "pubspec.yaml" ]; then
flutter test
elif [ -f "Makefile" ] && grep -q "test:" Makefile; then
make test
else
echo "No test command found"
exit 1
fi
After test execution:
IMPORTANT: If any tests fail, you MUST use the SlashCommand tool to invoke /fix:
Prepare context for /fix:
Use SlashCommand tool with this exact format:
Use the SlashCommand tool to execute: /fix
Context to pass to /fix:
- Failed tests: [list test names]
- Error messages: [specific error details]
- Affected files: [file paths from stack traces]
Wait for /fix command to complete
Re-run tests to verify fixes
User: /auto-test
Claude: Running tests...
[Executes: npm test]
Result: 3 tests failed out of 15 total
Claude: Tests failed. Using SlashCommand tool to invoke /fix...
[Uses SlashCommand tool to call: /fix]
Context passed to /fix:
- Failed tests: auth.test.ts::login, auth.test.ts::logout, user.test.ts::profile
- Error messages:
- Expected 200, got 401 in auth.test.ts:42
- Undefined user object in user.test.ts:28
- Affected files: src/auth.ts, src/user.ts
[/fix command executes and applies fixes]
Claude: Re-running tests...
[Executes: npm test]
Result: All 15 tests passed ✓
/fix command must be available in .claude/commands//fix must have proper allowed-tools configuredSlashCommand to be in the allow list in settings.json permissions# Manual execution
/auto-test
# Automatic trigger after file modifications (via hooks)
# Explicitly enable by configuring settings.json
Explicitly enable automatic execution by adding to settings.json:
{
"hooks": {
"PostToolUse": [
{
"matcher": "Write|Edit|MultiEdit",
"hooks": [
{
"type": "command",
"command": "claude --command '/auto-test'"
}
]
}
]
}
}
/fix command is explicitly invoked when corrections are necessary