gh-sync-with-main
Bring the current git branch up to date with commits from the main branch, or check whether it needs syncing without changing it.
Skill by ahandsel
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/ahandsel-gh-sync-with-main
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
- Runs as
- Node.js package
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/gh-sync-with-main
What's inside
- Skill name
gh-sync-with-main- Description
- Bring the current git branch up to date with commits from the main branch, or check whether it needs syncing without changing it. Use when the user asks to pull latest main, sync/refresh the branch, rebase onto main, merge main into a feature branch, or verify how far the branch is ahead of or behind main.
- License
- MIT
- Instructions
- 92 lines in SKILL.md · view on GitHub
Before installing
- Ships executable scripts
Files (2)
- SKILL.md
- update-branch-from-main.mjs · scripts/
SKILL.md (first lines)
# GitHub sync with main branch skill
## Overview
Update the checked out branch from `main` with a small helper script instead of rebuilding the git sequence from scratch. Prefer rebase for a clean linear history, and switch to merge only when the user or repository workflow requires it.
Pass `--verify` for a read-only check that reports how far the branch is ahead of or behind `main`, previews conflicts, and recommends a strategy without changing anything.
## Workflow
1. Confirm the repository state first.
* Run `git status --short`.
* Run `git branch --show-current`.
* Stop if the user is already on `main`.
2. Choose the update strategy.
* Default to `rebase`.
* Use `merge` when the user explicitly asks to merge, the branch is already shared and history should not be rewritten, or the repository conventions prefer merge commits.
* In this repository the long-lived working branch is `dev` and pull requests target `main`. Rebasing `dev` rewrites history that is already on `origin/dev`, so confirm with the user or prefer `merge` when syncing `dev` itself.
3. Run the helper script.
```bash
node "${CLAUDE_SKILL_DIR}/scripts/update-branch-from-main.mjs"
```
4. Add flags only when needed.
```bash
node "${CLAUDE_SKILL_DIR}/scripts/update-branch-from-main.mjs" --strategy merge
node "${CLAUDE_SKILL_DIR}/scripts/update-branch-from-main.mjs" --base-branch main --remote origin
node "${CLAUDE_SKILL_DIR}/scripts/update-branch-from-main.mjs" --allow-dirty
```
## Verify mode
When the user only wants to know whether the branch needs syncing, run the script with `--verify` instead of syncing.
This mode is read-only: it fetches the base branch to update the remote-tracking ref, then reports the status without rebasing, merging, or changing the branch or working tree.
```bash
node "${CLAUDE_SKILL_DIR}/scripts/update-branch-from-main.mjs" --verify
node "${CLAUDE_SKILL_DIR}/scripts/update-branch-from-main.mjs" --verify --strategy merge
```
The report includes the branch name, the base ref, the working tree state, the ahead and behind commit counts, a conflict preview, and a recommendation.
* The recommendation is one of `up to date`, `sync recommended (rebase)`, or `sync recommended (merge)`, and it notes `resolve conflicts manually` when the conflict preview is `likely`.
* The `--strategy` flag selects which strategy the recommendation names; it defaults to `rebase`.
* The conflict preview uses `git merge-tree` and needs git 2.38 or newer. On older git it reports `unknown`.
* Verify exits `0` once the assessment completes, whatever it recommends, so the exit code does not signal whether a sync is needed. Read the recommendation from the output.
## Conflict handling
If git reports conflicts, stop normal automation and guide the user through resolution.
* For rebase conflicts: resolve files, `git add <files>`, then `git rebase --continue`.
* For merge conflicts: resolve files, `git add <files>`, then `git commit`.
* If the user wants to cancel: `git rebase --abort` or `git merge --abort`.
## After syncing
This repository's agent permissions deny `git push`, so never attempt to push the updated branch yourself.
Tell the user what to run and suggest they type it in the prompt so it runs in the session:
* After a merge or a fast-forward: `! git push`
* After a rebase of a branch that was already pushed: `! git push --force-with-lease`
## Guardrails
* Refuse to run on `main`. This applies to `--verify` as well, because there is nothing to compare against.
* Refuse to run with a dirty working tree unless the user explicitly accepts `--allow-dirty`. Note that `--allow-dirty` pairs best with `merge`, because `git rebase` still refuses to run with unstaged changes even after the script's own clean-tree check is bypassed. The dirty-tree refusal does not apply to `--verify`, which never changes the working tree.
* Fetch `origin/main` before changing history.
* Prefer `origin/main` over a stale local `main`.
* Show the exact git commands before execution so the user can see the plan.
* Use `--verify` when the user asks only to check the branch. It never rebases, merges, or edits the branch or working tree.
## Script behavior
The helper script:
* verifies the current branch is not the base branch
* checks whether the working tree is clean unless `--allow-dirty` is passed
* fetches the chosen base branch from the chosen remote
* rebases onto `origin/main` by default, or merges `origin/main` when requested
* exits immediately on the first git failure and leaves the repository in git's native conflict state for manual resolution
* with `--verify`, fetches the base branch and then reports the ahead and behind counts, a `git merge-tree` conflict preview, and a recommendation, without rebasing, merging, or changing the branch or working treeFrom ahandsel/tokyo-geek, MIT.
More from ahandsel/tokyo-geek
- 0.603score
audit-gh-branches
ahandsel
Audit local and remote Git branches, classify each as safe to delete, deletion candidate, needs rebase, ice, or keep active, and extract unique work as dated…
SkillAFreshness: A★ 2Claude Code +9 - 0.598score
pr-auditor
ahandsel
Blunt merge audit of a code branch or pull request written by an AI coding agent, treating its description, comments, and green checks as claims to verify…
SkillAFreshness: A★ 2Claude Code +9 - 0.598score
gh-pr-generator
ahandsel
Draft a structured pull request body from the branch diff and open the pull request with the gh CLI.
SkillAFreshness: A★ 2Claude Code +9 - 0.598score
blog-content-auditor
ahandsel
Audit a blog post for content quality - verify facts are correct and up-to-date, check style-guide compliance, and confirm the content is logically sound and…
SkillAFreshness: A★ 2Claude Code +9 - 0.598score
blog-md-linter
ahandsel
Lint and polish Markdown files in this repo - run the repo auto-fixers, refresh any table of contents, convert inline and autolink links to reference-style…
SkillAFreshness: A★ 2Claude Code +9 - 0.558score
script-auditor
ahandsel
Audit and enforce the AGENTS.md "Scripts" guidelines for helper scripts in this repo - banning Python, preferring Node.js `.mjs` modules or zsh, requiring…
SkillBFreshness: B★ 2Claude Code +9 - 0.557score
audit-pr-comments
ahandsel
Audit a user-specified PR review file with extreme scrutiny, then annotate that same file in place with a verdict for every comment (keep, rewrite, remove…
SkillBFreshness: B★ 2Claude Code +9 - 0.521score
handoff
ahandsel
Compact the current conversation into a handoff document for another agent to pick up.
SkillBFreshness: B★ 2Claude Code +9 - 0.518score
grill-me
ahandsel
A relentless interview to sharpen a plan or design.
SkillBFreshness: B★ 2Claude Code +9 - 0.512score
file-folder-name-linter
ahandsel
Lint repository file and folder names for format compliance.
SkillCFreshness: C★ 2Claude Code +9 - 0.512score
gh-pr-reporter
ahandsel
Fetch all comments on a GitHub pull request (reviews, inline review comments, and general issue comments) and emit a single consolidated Markdown report.
SkillCFreshness: C★ 2Claude Code +9 - 0.507score
general-en-polisher
ahandsel
Polish one or more Markdown files so the repo core writing rules are enforced - straight quotes (not curly), no contractions, the Oxford comma, sentence case…
SkillCFreshness: C★ 2Claude Code +9
Signals
- Stars
- 2
- Forks
- 0
- Open issues
- 1
- Last commit (this folder)
- Sep 29, 2026 (1 month ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/ahandsel/tokyo-geek
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
Same skill elsewhere
Copies of this SKILL.md published by others; search shows only one of them.
More from ahandsel
- 0.603score
audit-gh-branches
ahandsel
Audit local and remote Git branches, classify each as safe to delete, deletion candidate, needs rebase, ice, or keep active, and extract unique work as dated…
SkillAFreshness: A★ 2Claude Code +9 - 0.598score
pr-auditor
ahandsel
Blunt merge audit of a code branch or pull request written by an AI coding agent, treating its description, comments, and green checks as claims to verify…
SkillAFreshness: A★ 2Claude Code +9 - 0.598score
gh-pr-generator
ahandsel
Draft a structured pull request body from the branch diff and open the pull request with the gh CLI.
SkillAFreshness: A★ 2Claude Code +9 - 0.598score
blog-content-auditor
ahandsel
Audit a blog post for content quality - verify facts are correct and up-to-date, check style-guide compliance, and confirm the content is logically sound and…
SkillAFreshness: A★ 2Claude Code +9 - 0.598score
blog-md-linter
ahandsel
Lint and polish Markdown files in this repo - run the repo auto-fixers, refresh any table of contents, convert inline and autolink links to reference-style…
SkillAFreshness: A★ 2Claude Code +9 - 0.598score
gh-pr-generator
ahandsel
Draft a structured pull request body from the branch diff and open the pull request with the gh CLI.
SkillAFreshness: A★ 2Claude Code +9
Cite this page
gh-sync-with-main skill. Agent Mart. https://agentmart.dev/skills/ahandsel-gh-sync-with-main (last updated 2026-10-24)