| name | validation-troubleshooting |
| description | Universal troubleshooting guide for validation failures (tests, linting, builds). Use when tests fail, validation commands error, or build breaks. Framework-agnostic debugging strategies for common development workflow issues. |
Validation Troubleshooting Skill
Step-by-step debugging guide for when validation commands fail.
💡 Automation Available:
If VSCode hooks are installed (.github/hooks/), the validation-reminder.cjs hook will automatically remind you to run validation when code changes but no tests ran. See docs/vscode-hooks-guide.md for details.
When to Use This Skill
Use when:
- Tests fail after making changes
- Validation commands from matrix error
- Build/compilation fails
- Linting errors appear
- Type checking fails
- User mentions: "tests failing", "validation error", "build broken", "lint error"
Trigger words: "test fail", "validation fail", "build error", "lint error", "type error", "won't compile"
1. Test Failures
Step 1: Read the Error Message Carefully
DON'T:
- ❌ Immediately modify code
- ❌ Delete failing tests
- ❌ Disable test runner
DO:
- ✅ Read full error output
- ✅ Note exact line number and file
- ✅ Identify what was expected vs actual
Step 2: Isolate the Failure
Run only the failing test:
npm test -- path/to/test.test.js
pytest path/to/test.py::test_name -v
npm test -- --testNamePattern="test name"
npx vitest path/to/test.test.ts
go test -run TestName ./...
cargo test test_name
Step 3: Check Test Expectations
Common issues:
- Test expects old behavior (need to update test)
- Implementation is wrong (fix code)
- Test setup/mocking is incorrect
- Environment/config mismatch
Questions to ask:
- Is the test expectation still valid?
- Did I change behavior the test depends on?
- Are mocks/fixtures up to date?
- Does the test match CODEBASE_ESSENTIALS.md patterns?
Step 4: Debug the Test
Add logging:
console.log('Actual value:', result);
console.log('Expected:', expected);
print(f"Actual: {result}, Expected: {expected}")
println!("Actual: {:?}, Expected: {:?}", result, expected);
Run in debug mode:
node --inspect-brk node_modules/.bin/jest --runInBand
python -m pdb -m pytest path/to/test.py
rust-gdb target/debug/test_binary
Step 5: Fix and Validate
- Fix the issue (code or test)
- Run the single test again - should pass
- Run full test suite - all should pass
- Commit with clear message explaining the fix
Never claim done without running full test suite!
2. Linting Errors
Step 1: Identify Error Type
Syntax errors:
Parsing error: Unexpected token
Missing semicolon
Unexpected identifier
→ Fix: Correct syntax immediately
Style violations:
'variable' is assigned but never used
Missing trailing comma
Prefer const over let
→ Fix: Address or justify
Security issues:
Detected eval usage
Unsafe regex
XSS vulnerability
→ Fix: MUST fix, don't disable
Step 2: Auto-Fix When Possible
npm run lint:fix
npm run format
black .
cargo fmt
go fmt ./...
Step 3: Manual Fixes
Read CODEBASE_ESSENTIALS.md for style rules:
- Check "Code Patterns" section
- Verify naming conventions
- Review import ordering
DON'T disable rules without justification:
console.log(data);
console.log(data);
Step 4: Update Rules If Wrong
If rule conflicts with project patterns:
- Discuss with team/review ESSENTIALS
- Update linting config
- Document change in CODEBASE_CHANGELOG.md
- Update CODEBASE_ESSENTIALS.md if pattern changed
3. Build/Compilation Errors
Step 1: Check Error Category
Dependency errors:
Cannot find module 'package-name'
Module not found
Package not installed
→ Fix: Install dependencies
Type errors:
Type 'string' is not assignable to type 'number'
Property 'x' does not exist on type 'Y'
→ Fix: Correct types or update type definitions
Configuration errors:
Invalid configuration object
Missing environment variable
Unknown compiler option
→ Fix: Check config files
Step 2: Clean Build
rm -rf node_modules dist .cache
npm install
npm run build
rm -rf __pycache__ .pytest_cache dist
pip install -r requirements.txt
cargo clean
cargo build
go clean -cache
go build
Step 3: Check Environment
Verify versions match CODEBASE_ESSENTIALS.md:
node --version
python --version
rustc --version
go version
Check environment variables:
printenv
echo $NODE_ENV
echo $DATABASE_URL
Step 4: Incremental Debugging
- Comment out recent changes
- Build incrementally
- Identify breaking change
- Fix root cause
- Uncomment and rebuild
4. Type Checking Errors
Common TypeScript Issues
Missing type definitions:
npm install --save-dev @types/package-name
Type mismatch:
const id: number = "123";
const id: number = parseInt("123", 10);
const id: string = "123";
Null/undefined issues:
const name = user.name;
const name = user?.name;
const name = user?.name ?? 'Unknown';
Common Python Type Issues
mypy errors:
mypy src/
result = something()
5. Validation Matrix Command Failures
Strategy: Work Through Matrix Systematically
From CODEBASE_ESSENTIALS.md validation matrix:
| Command | Purpose | Expected |
|---------|---------|----------|
| npm test | Run tests | All pass |
| npm run lint | Check style | No errors |
| npm run build | Compile | No errors |
Run each command:
- If passes → ✅ Move to next
- If fails → 🔴 Debug using sections above
- Don't move forward until current command passes
Example Debugging Session
npm test
npm test -- auth.test.js
npm test
npm run lint
npm run build
Rule: Fix failures in order, don't skip ahead!
6. Common Patterns and Solutions
Pattern: "Works on my machine"
Cause: Environment differences
Solutions:
- Check Node.js/Python/Rust version matches team
- Verify environment variables set correctly
- Clear caches and reinstall dependencies
- Check for OS-specific issues (Windows vs Unix paths)
- Use Docker/containers for consistency
Pattern: "Test passes locally, fails in CI"
Cause: CI environment differences
Solutions:
- Check CI logs carefully
- Verify CI environment variables
- Check for timing issues (add proper waits)
- Ensure deterministic test data
- Check for missing CI dependencies
Pattern: "Intermittent test failures"
Cause: Non-deterministic tests
Solutions:
- Remove time-dependent logic
- Fix race conditions
- Mock random/date functions
- Ensure proper cleanup between tests
- Avoid shared state
Pattern: "Everything broke after dependency update"
Cause: Breaking changes in dependency
Solutions:
- Check dependency changelog
- Revert to previous version temporarily
- Read migration guide
- Update code to new API
- Consider alternative package
Workflow Checklist
When validation fails:
Never Do These
❌ Delete tests to make them pass
- Tests found a real issue
- Fix the code, not the test
❌ Disable linting rules without justification
- Rules exist for a reason
- Discuss with team first
❌ Skip validation steps
- "It probably works" is not good enough
- Run full matrix before claiming done
❌ Commit broken code "to fix later"
- Breaks team workflow
- Creates technical debt
❌ Change multiple things at once
- Can't identify root cause
- Fix one thing, validate, then next
Quick Reference
Emergency Triage
git diff
git log --oneline -10
git revert HEAD
npm test && npm run lint && npm run build
Getting Unstuck
If stuck for >15 minutes:
- Read error message again (slowly)
- Check CODEBASE_ESSENTIALS.md for relevant pattern
- Search project for similar code that works
- Check dependency documentation
- Ask for help (provide full error message)
Framework-agnostic troubleshooting - adapt commands to your project's tech stack.