"Validate code changes before PR update and merge. Use when preparing to update a PR, pushing changes, or running pre-merge checks: (1) run local CI parity tests, (2) add regression tests for new failures, (3) verify all tests pass before pushing or requesting review."
Install
npx skillscat add squirrel289/pax/validating-changes Install via the SkillsCat registry.
Validating Changes
Ensure code quality and prevent regressions by validating changes locally before PR updates and merges.
When to Use
- Before updating a feature branch with new commits
- After resolving merge conflicts to re-validate tests
- Before pushing to origin (pre-push gate)
- When CI tests fail and need local replication and fix
Core Validation Steps
1. Run Affected Tests Locally
Before updating a PR or pushing:
- Run:
pnpm test:affected:ci - Review output for failures
- Pass if: All tests pass
- Fail if: Any test fails — do not skip or commit
If failures occur, proceed to step 2 (add regression test).
2. Add Regression Test
When a new failure is discovered:
- Locate the test file for the failing module (e.g.,
src/packages/volar/src/position-mapping.test.ts) - Add a test case that reproduces the failure with clear scenario name (e.g., "maps positions within template blocks")
- Include comments explaining why this edge case matters
- Run the test suite for that file only:
pnpm -C <package> test -- <test-file> - Verify new test fails before your fix, then passes after
Example:
it('maps positions within template blocks', () => {
// Regression: positions falling within template syntax must map back to original
const input = 'Hello {{ name }}\nWorld';
const mappings = generatePositionMappings(input, templateRegex);
expect(mappings).toContainEqual({ originalOffset: 8, ...});
});3. Run Full Package Tests
After adding regression tests:
- Run all tests for the affected package:
pnpm -C src/packages/<package> test - Confirm all pass, including the new regression test
- If any test fails, fix the code and re-run
- Repeat until full suite passes
4. Replicate CI Failures Locally
If a PR CI check fails but local tests pass:
- Get the exact command from the GitHub Actions workflow (e.g., in
.github/workflows/*.yml) - Run that command locally in the same environment
- If you can reproduce the failure, fix the code and re-validate with step 2
- If you cannot reproduce, investigate environment differences (Node version, dependencies, etc.)
Common commands:
- Type check:
pnpm run type:check - Lint:
pnpm run lint:eslintorpnpm run lint:staged - Tests:
pnpm test:affected:ciorpnpm -C <package> test - Frontmatter validation:
pnpm run lint:frontmatter
5. Pre-Push Gate
Before pushing to origin:
- Run:
pnpm run hooks:pre-push - This runs all gating checks (lint, tests, frontmatter validation)
- Pass if: All checks pass
- Fail if: Any check fails — fix locally before pushing
The hook is configured in .husky/pre-push; if disabled, manually run the command above.
Integration with Other Skills
- executing-backlog: Invokes this skill before PR merge gates
- parallel-execution: Runs this skill per workspace after subagent code changes
- guarding-branches: Works in tandem — validate changes, then apply merge guardrails
Troubleshooting
Tests fail but I think they should pass?
- Check the test file for recent changes that might affect it
- Read the failure message carefully — it often suggests the fix
- Run the test in isolation:
vitest run <test-file>for more detail
CI passes locally but fails on GitHub?
- Environment mismatch: Check Node version, pnpm version in CI vs local
- Cache issue: Try
pnpm install --frozen-lockfileto match CI exactly - Race condition: Some tests may be order-dependent; run full suite, not individual tests
Pre-push hook is too slow?
- The hook runs many checks; if it's blocking, file an issue for optimization
- DO NOT disable the hook; instead, improve the hooks configuration per repo instructions
Regression test feels like overkill?
- It prevents the same bug from shipping twice; it's worth the token cost
- Keep regression tests concise and focused on the specific edge case
- Link the test to the issue/PR in a comment for context