pre-push
Run all validations before pushing to remote
Files1
View on GitHubSKILL.md.claude/skills/pre-push/SKILL.md
GitHub/pre-push - Pre-push Validation Skill
Final validation before pushing commits to remote repository.
Purpose
Validate branch conventions and push commits to remote. Quality checks (fmt, clippy, tests)
are delegated to the .githooks/pre-push hook, which runs automatically when git push executes.
Hook delegation:
.githooks/pre-pushruns the canonical fmt / clippy / test block (see.claude/conventions/ci-checks.md) on everygit push. Runmake setuponce to activate the hook if you haven't already.
Validation Checklist
All of the following MUST pass before pushing:
1. Branch Naming Convention
git branch --show-current
Verify the branch name follows .claude/conventions/branching.md → "Branch Naming
(label → prefix)" (read it if unsure which prefix the Issue's labels map to).
FORBIDDEN branches for direct push:
main- Use PR onlydevelop- Use PR only (if applicable)
2. 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: 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 2: 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 3: Final Confirmation
Before pushing, confirm:
- Branch name is correct
- Commits are reviewed
-
.githooks/pre-pushhook is active (make setuphas been run)
Step 4: Push
git push -u origin $(git branch --show-current)
The .githooks/pre-push hook will automatically run the canonical check block
(.claude/conventions/ci-checks.md) before the push completes.
Error Handling
Hook Failures (fmt / clippy / test)
If the .githooks/pre-push hook reports a failure:
- Read the hook output to identify which check failed
- Fix the issue (format error, clippy warning, or test failure)
- Commit the fix
- Re-run
/pre-push
Wrong Branch
WARNING: You are on branch 'main'. Direct pushes to main are not allowed.
CRITICAL: Never push to main/develop. Instead:
- Create a feature branch per
.claude/conventions/branching.md→ "Branch Base" (Normal Mode: fromorigin/develop, nevermain; Stacked Mode only on an explicit user request — never inferred) - Push the feature branch
- Create a PR via the
/prskill, which resolves the target branch into$BASE_BRANCH
Hook Not Active
If the hook does not run (no [pre-push] output during push):
make setup
Then re-run the push.
Example Usage
User: "pushする前にチェックして"
Claude executes /pre-push skill:
- Checks branch:
feature/84-agent-skills- VALID - Reviews unpushed commits
- Reports: "Branch and commits look good. Pushing now (hook will run quality checks)."
- Executes
git push -u origin feature/84-agent-skills .githooks/pre-pushruns fmt/clippy/test automatically
Summary Output
After push completes successfully, output:
Pre-push Complete
=================
[PASS] Branch: feature/84-agent-skills (valid naming)
[PASS] Hook: cargo fmt, clippy, tests passed
[INFO] Commits pushed: X commits
Pushed to origin/feature/84-agent-skills