generic-automation-and-it/smooth-ai-stockanalysis / .agents/skills/git-sync
git-sync
VerifiedSync the current working branch with origin/main and optionally resolve merge conflicts. Use when synchronizing local branch with the latest changes from main, with automatic or manual conflict resolution.
| File | Kind | Size |
|---|---|---|
| AGENTS.md | markdown | 753 B |
| SKILL.md | skill md | 4.0 KB |
| agents/openai.yaml | config | 300 B |
| scripts/safe-sync.shexecutable | script | 1.6 KB |
scripts/safe-sync.sh
View on GitHub#!/usr/bin/env bash
# git-sync — fetch origin/main and merge into the current branch.
#
# Performs the deterministic part of both modes:
# - fetches origin/main and merges (non-interactively, --no-edit)
# - on clean merge: prints "MERGE_OK" then the last 5 commits
# - on conflict: prints "MERGE_CONFLICTS" then the unmerged files,
# LEAVING the conflicts in the working tree
# - on other failure: prints "MERGE_ERROR" (dirty tree, missing ref, hook
# failure, etc. — NOT a content conflict)
#
# Mode 1 (safe): the agent reports the conflicts and stops.
# Mode 2 (--fix): the agent resolves the conflicts left in the tree, stages, commits.
# Either way the merge decision/resolution stays with the agent; this script only
# does the fetch+merge plumbing. Exit code: 0 clean merge, 1 conflict, 2 other error.
#
# Usage: safe-sync.sh [base-ref] (default base-ref: origin/main)
set -euo pipefail
BASE_REF="${1:-origin/main}"
REMOTE="${BASE_REF%%/*}"
BRANCH="${BASE_REF#*/}"
# Fetch failures (missing remote/ref, network) are non-merge errors — keep the
# MERGE_OK/MERGE_CONFLICTS/MERGE_ERROR contract intact rather than dying via set -e.
if ! git fetch "$REMOTE" "$BRANCH"; then
echo "MERGE_ERROR"
exit 2
fi
if git merge --no-edit "$BASE_REF"; then
echo "MERGE_OK"
git log --oneline -5
exit 0
else
CONFLICTS="$(git diff --name-only --diff-filter=U)"
if [ -n "$CONFLICTS" ]; then
echo "MERGE_CONFLICTS"
printf '%s\n' "$CONFLICTS"
exit 1
fi
# Non-conflict failure: dirty working tree, missing ref, failing hook, etc.
echo "MERGE_ERROR"
exit 2
fi
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| receiving-code-reviewobra/superpowersUse when receiving code review feedback, before implementing suggestions, especially if feedback seems unclear or technically questionable - requires technical rigor and verification, not performative agreement or blind implementation | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| requesting-code-reviewobra/superpowersUse when completing tasks, implementing major features, or before merging to verify work meets requirements | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| using-git-worktreesobra/superpowersUse when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via native tools or git worktree fallback | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| verification-before-completionobra/superpowersUse when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions always | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |