/pre-push - Pre-push Validation Skill
Final validation before pushing commits to remote repository.
Purpose
Ensure code quality and branch conventions are correct before pushing to prevent CI failures and maintain repository standards.
⚠️ CRITICAL: Always Use This Skill - Never Bypass
This skill exists to ensure CI-equivalent checks are run locally.
NEVER run these commands directly:
| ❌ Wrong (Missing Flags) | ✅ Correct (Use This Skill) |
|---|---|
cargo clippy --all-targets | /pre-push includes -D warnings |
cargo fmt --check | /pre-push includes --all flag |
cargo test | /pre-push includes --all flag |
Why This Matters (Issue #59 Incident)
Running cargo clippy without -D warnings caused a CI failure:
- •Clippy showed warnings but exit code was 0 (success)
- •Push proceeded despite warnings
- •CI failed because it uses
-D warningswhich treats warnings as errors
Prevention: Always invoke /pre-push instead of running individual commands manually.
Commands This Skill Runs
This skill ensures the following commands are run with exact CI-matching flags:
cargo test --all # All tests cargo fmt --all -- --check # Format check cargo clippy --all-targets --all-features -- -D warnings # Clippy with warnings as errors
Validation Checklist
All of the following MUST pass before pushing:
1. Full Test Suite
cargo test --all
All tests must pass.
2. Format Verification
cargo fmt --all -- --check
If this fails, run cargo fmt --all and commit the changes.
3. Clippy Verification
cargo clippy --all-targets --all-features -- -D warnings
Zero warnings required.
4. Branch Naming Convention
git branch --show-current
Verify branch name follows convention based on Issue labels (priority order):
| Priority | Issue Label | Branch Prefix | Example |
|---|---|---|---|
| 1 | enhancement | feature/ | feature/84-agent-skills |
| 2 | bug | bugfix/ | bugfix/42-fix-parsing |
| 3 | refactor | refactor/ | refactor/30-cleanup-code |
| 4 | documentation | doc/ | doc/50-update-readme |
| 5 | (no label) | feature/ | feature/99-misc-task |
Additional: hotfix/<issue>-<desc> for critical production fixes
FORBIDDEN branches for direct push:
- •
main- Use PR only - •
develop- Use PR only (if applicable)
5. Remote Branch Target
git remote -v git branch -vv
Verify:
- • Pushing to correct remote (typically
origin) - • Not accidentally pushing to upstream/fork
Steps
Step 1: Run Full Test Suite
cargo test --all
If tests fail:
- •Fix the failing tests
- •Commit the fixes
- •Re-run tests
Step 2: Verify Formatting
cargo fmt --all -- --check
If formatting issues found:
- •Run
cargo fmt --all - •Commit formatting changes
- •Re-run check
Step 3: Run Clippy
cargo clippy --all-targets --all-features -- -D warnings
If warnings found:
- •Fix all warnings
- •Commit fixes
- •Re-run clippy
Step 4: Check Branch Name
BRANCH=$(git branch --show-current) echo "Current branch: $BRANCH"
Verify:
- • Matches naming convention
- • Not on
mainordevelop - • Issue number in branch name (if applicable)
Step 5: Verify Unpushed Commits
git log origin/$(git branch --show-current)..HEAD --oneline 2>/dev/null || git log --oneline -5
Review what will be pushed.
Step 6: Final Confirmation
Before pushing, confirm:
- • All tests pass
- • Formatting is clean
- • No clippy warnings
- • Branch name is correct
- • Commits are reviewed
Step 7: Push
git push -u origin $(git branch --show-current)
Error Handling
Test Failures
STOP: Tests are failing. Fix all test failures before pushing.
- •Identify failing tests
- •Debug and fix
- •Commit fixes
- •Re-run
/pre-push
Format Failures
STOP: Code formatting issues detected. Running cargo fmt...
- •Run
cargo fmt --all - •Review changes
- •Commit formatting
- •Continue with push
Clippy Warnings
STOP: Clippy warnings detected. Fix all warnings before pushing.
- •Read each warning
- •Fix the issues
- •Commit fixes
- •Re-run clippy
Wrong Branch
WARNING: You are on branch 'main'. Direct pushes to main are not allowed.
CRITICAL: Always create branches from origin/develop:
git fetch origin git checkout -b feature/<issue>-<description> origin/develop
- •Create a feature branch from origin/develop (not main!)
- •Push the feature branch
- •Create a PR targeting
develop
Example Usage
User: "pushする前にチェックして"
Claude executes /pre-push skill:
- •Runs
cargo test --all- PASS - •Runs
cargo fmt --all -- --check- PASS - •Runs
cargo clippy --all-targets --all-features -- -D warnings- PASS - •Checks branch:
feature/84-agent-skills- VALID - •Reviews unpushed commits
- •Reports: "All checks passed. Ready to push."
- •If user confirms, executes
git push -u origin feature/84-agent-skills
Summary Output
After all checks pass, output:
Pre-push Validation Complete ============================ [PASS] Tests: All X tests passed [PASS] Format: Code is properly formatted [PASS] Clippy: No warnings [PASS] Branch: feature/84-agent-skills (valid naming) [INFO] Commits to push: X commits Ready to push to origin/feature/84-agent-skills