agentleFS
zyniverse-hqzyniverse-hq/skills-registry/skills/safe-push-workflow/SKILL.md

safe-push-workflow

Skill0 starsChanged 6 months agoApache-2.0View on GitHub

Detects git conflicts before pushing a feature branch to any target branch by fetching remote state and diffing divergent changes. Use when the user asks to push code, push to qa/uat/main/staging, send a branch to remote, or create a PR. For branch, commit, and PR conventions, use git-workflow.

  • Commits and pushes

The file

We split this skill into the rules it gives an agent

5 rules. About 0 are common, 4 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Do NOT activate when: push is mentioned as a future plan alongside another task (e.g.

    line 28
  2. Distinctive:

    Do NOT activate when: user is only pulling or fetching without pushing

    line 29
  3. Distinctive:

    If uncommitted changes exist, stash first:

    line 49
  4. Distinctive:

    If conflicts detected — STOP.

    line 113
  5. Very specific:

    Use HEAD...origin/target (three dots) not HEAD..origin/target (two dots) — three dots shows only divergent changes, two dots includes …

    line 158

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Safe Push Workflow

Runs a pre-push conflict detection sequence before any git push or PR — so conflicts appear in your terminal, not on GitHub.

When to use

  • Activate when: user asks to push code, push to qa, push to uat, create a PR, or send a branch to remote
  • Activate when: user confirms a push with "yes", "go ahead", or "do it" after Claude proposes it
  • Do NOT activate when: push is mentioned as a future plan alongside another task (e.g. "fix this, then I'll push")
  • Do NOT activate when: user is only pulling or fetching without pushing

Prerequisites

  • Git repository with a configured remote
  • gh CLI installed (for PR creation in Step 8)
  • Feature branch with commits ready to push
  • A companion CLAUDE.md rule so pushes reliably invoke this skill — keyword matching alone will not catch a bare "yes" confirmation. Add: "Before executing any git push, always invoke the safe-push-workflow skill."

Steps

Step 1: Save current state

git branch --show-current
git status

If uncommitted changes exist, stash first:

git stash --include-untracked

Step 2: Fetch all remote state

git fetch --all

This updates local knowledge of ALL remote branches without touching working files.

Step 3: Pull latest on current branch

git pull origin <current-branch>

Resolve any conflicts here before proceeding. Branch must be clean first.

Step 4: See what the target branch has that you don't

git log HEAD..origin/<target-branch> --oneline

Lists every commit teammates pushed to <target-branch> that you haven't seen. Read them — understand what changed.

Step 5: Preview conflict zones

git diff HEAD...origin/<target-branch> --stat

Shows which files diverged between your branch and target. If any overlap with your changes, conflicts will happen on merge — fix them now.

For detailed diff:

git diff HEAD...origin/<target-branch>

Step 6: Report status to user

Print this before any push:

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 SAFE PUSH REPORT
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 Your branch   : <current-branch>
 Target branch : <target-branch>
 Your commits  : X ahead of target
 Target commits: Y commits you haven't pulled
 Conflicting files: [list or "None"]

 Status: ✅ CLEAN — safe to push
       OR
         ⚠️  CONFLICTS DETECTED — resolve before pushing
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

If conflicts detected — STOP. List the files. Wait for user to resolve before proceeding.

Step 7: Push

git push origin <current-branch>

Step 8: Create PR

gh pr create \
  --base <target-branch> \
  --head <current-branch> \
  --title "<descriptive title>" \
  --body "## Summary
- <what changed>

## Test Plan
- [ ] Tested locally
- [ ] No conflicts with <target-branch>"

Step 9: Restore stash (if stashed in Step 1)

git stash pop

Output

  • Format: Terminal report + git push + GitHub PR
  • Location: Terminal (Safe Push Report), GitHub (PR link)
  • Example: ✅ CLEAN — safe to push followed by push and PR creation

Example

User says: "push this to qa"

Claude does: Fetches all remote refs, pulls latest on current branch, diffs against origin/qa, prints the Safe Push Report showing clean status or conflicting files, then pushes the branch and creates a PR targeting qa.

Result: PR open on GitHub with zero conflict risk — or a clear conflict report stopping the push before damage is done.

Notes

  • Use HEAD...origin/target (three dots) not HEAD..origin/target (two dots) — three dots shows only divergent changes, two dots includes shared history and gives misleading results
  • A bare "yes" reply will not re-trigger this skill via keyword matching — pair this skill with a CLAUDE.md global rule: "Before executing any git push, always invoke the safe-push-workflow skill"
  • Saves ~6–7 hours/month vs pushing blind (based on ~16 pushes/month with 30% conflict rate resolving to 45–90 min per incident)
  • Works for any target branch dynamically — qa, uat, main, staging

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.