Sync

From eliranwong/biblemate-agentic-workspace · View interactive version

Sync is an AI agent skill from the GitHub repository eliranwong/biblemate-agentic-workspace. Fetch the latest origin/main, rebase this checkout onto it, commit local changes, and push to the remote repository. Sync is two-way: remote commits land on local main, and local commits land on the remote. Use when the user runs /sync or requests this BibleMate workflow.

How to use this skill

Skill file

Sync Skill

Overview

Use exec_command for the Git operations below, running from the repository root.

Fetch the latest origin/main, rebase this checkout onto it, commit local changes, and push. Sync is two-way: remote commits land on local main, and local commits land on the remote.

If the user provided a commit message (for example through the slash-command argument), use that message. Otherwise, generate one from the staged diff.

Steps

Phase 1: Fetch and integrate origin/main

  1. Run git status --short and git rev-parse --abbrev-ref HEAD.
  2. Run git fetch origin main. This updates origin/main and does not change the working tree.
  3. If the current branch is not main, report the branch name and that origin/main was fetched. Skip the rebase in this phase. Continue with Phase 2 and Phase 3 for the current branch.
  4. On main, record both directions:
  1. If behind is 0, continue to Phase 2.
  2. If behind is greater than 0 and git status --short is empty, run git pull --rebase origin main.
  3. If behind is greater than 0 and the working tree is dirty, run git stash push -u -m "sync", then git pull --rebase origin main, then git stash pop.
  4. If the rebase or the stash pop stops with conflicts, stop. Report the conflicted files. Leave a saved sync stash in place. Do not commit, push, abort, or force-push.

Phase 2: Commit any uncommitted changes

  1. Run git status --short again.
  2. If there are no uncommitted changes, skip to Phase 3.
  3. Run git add -A to stage ALL changes (new, modified, and deleted files).
  4. Generate a concise commit message that summarizes the changes:
  1. Run git commit -m "<message>" with the generated message.

Phase 3: Push any unpushed commits

  1. Run git rev-list --count @{upstream}..HEAD to check how many commits are ahead of the remote.
  1. If there are unpushed commits, run git push.
  2. If the push is rejected because the remote has newer commits, run git fetch origin main, then git pull --rebase origin main, then git push once more. If that second push fails, stop and report the error.
  3. If the push fails for any other reason, stop and report the error.
  4. If there are no unpushed commits, report that local commits are already on the remote.

Phase 4: Report result

  1. Report how many commits came in from origin/main, the number of files changed (if any), the commit hash (if any), and whether the push succeeded.
  2. On main, the sync is complete only when both ranges are empty:
  1. Confirm with git status -sb. A finished main sync shows main...origin/main with no ahead or behind count.

CRITICAL

Codex Runtime Notes

sibling skills from .agents/, .claude/, .grok/, or .cursor/.

.codex/skills/... paths named above.

commands only for execution, inspection, validation, and generated helper

output.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.