Skills DirectorySkills Directory
SkillsLearnSecurityCategoriesDocsBlogPro
Sign InSubmit Skill
Skills Directory

Security-tested agent skills for Claude, coding agents, and AI workflows.

Directory

  • Browse Skills
  • All Skills A–Z
  • Claude Skills
  • Claude Code Skills
  • Agent Skills
  • Categories
  • Authors
  • Submit a Skill

Learn

  • Learn Hub
  • Install Claude Skills
  • Write SKILL.md
  • Skills vs MCP
  • Directories Compared

Security

  • Security
  • Methodology
  • Secure Claude Skills
  • Security Badges
  • Chrome Extension
  • Skill Manager

Company

  • About
  • Community
  • Blog
  • API Docs
  • Advertise

2026 Skills Directory. All rights reserved.

ProTermsPrivacyRefunds
Back to skills

Sync Main

ASecurity

Update the repo's default branch from remote and merge it into the current branch, or all open PR branches. Despite the name (kept for continuity), this syncs whatever the repo's default branch actually is — main on trunk repos, develop on git-flow repos — and on git-flow repos also fast-forwards local main from origin/main.

3 stars
0 votes
0 copies
1 views
Added 9/19/2026
ai-agentsgobashgit

Works with

cli

Security Analysis

A100/100

Scanned 9/23/2026

$npx -y skills add dryvist/claude-code-plugins --skill sync-main --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Sync Main?

Add the live security badge to your README — it updates automatically with every re-scan.

Security grade badge for Sync Main
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/dryvist-sync-main/badge)](https://www.skillsdirectory.com/skills/dryvist-sync-main)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
Files
SKILL.md
---
name: sync-main
description: >-
  Update the repo's default branch from remote and merge it into the current
  branch, or all open PR branches. Despite the name (kept for continuity),
  this syncs whatever the repo's default branch actually is — main on trunk
  repos, develop on git-flow repos — and on git-flow repos also
  fast-forwards local main from origin/main.
---

# Sync Main

Update the local default branch from remote and merge it into the current working branch,
or all open PR branches when using the `all` parameter.

The skill keeps the name `sync-main` for continuity, but it syncs the repo's
actual default branch, not a literal `main`. On a trunk repo that is the same
thing; on a git-flow repo the default branch is `develop`, and this skill
treats `develop` as the sync target throughout.

## Scope Parameter

| Usage | Scope |
| ----- | ----- |
| `/sync-main` | Current branch only |
| `/sync-main all` | All open PR branches |

**CURRENT REPOSITORY ONLY** - This command never crosses into other repositories.

## Prerequisites

- You must be in a feature branch worktree (not on the default branch itself)
- The current branch should have no uncommitted changes

## Resolve the Default Branch (Both Modes)

```bash
DEFAULT_BRANCH=$(gh repo view --json defaultBranchRef --jq '.defaultBranchRef.name')
```

See /gh-cli-patterns (github-workflows) Canonical Default-Branch Detection for
what `main` vs `develop` implies. Use `<DEFAULT_BRANCH>` everywhere below.

## Single Branch Mode (Default)

1. **Verify state**: `git branch --show-current`, `git status --porcelain`
   - STOP if on `<DEFAULT_BRANCH>` or uncommitted changes
2. **Sync default branch**: `git fetch --all --prune --force && git pull` (in the `<DEFAULT_BRANCH>` worktree)
3. **Check for updates**: `git fetch origin --force <DEFAULT_BRANCH>`
4. **Report**: Show commits behind with `git log --oneline HEAD..origin/<DEFAULT_BRANCH>` (informational only)
5. **Merge**: `git merge origin/<DEFAULT_BRANCH> --no-edit`
   - If already up-to-date: skip to step 7 and report
   - If merge succeeds cleanly: continue to step 6
   - If conflicts occur: **STOP, do not push**. Report conflict status and follow the **Conflict Resolution** section below
6. **Push (only if merge succeeded cleanly)**: `git push origin $(git branch --show-current)`
7. **Report**: branch, `<DEFAULT_BRANCH>` SHA, merge status

### Git-Flow Extra Step: Fast-Forward Local Main

If `<DEFAULT_BRANCH> == develop` (git-flow repo) and a local `main` worktree
exists, also fast-forward it from `origin/main` so it never goes silently
stale between promotions:

```bash
git -C <path-to-main-worktree> fetch origin main
git -C <path-to-main-worktree> merge --ff-only origin/main
```

Resolve `<path-to-main-worktree>` from `git worktree list --porcelain`,
matching the `branch refs/heads/main` entry. If no local `main` worktree
exists, skip this step — there is nothing to fast-forward. Never push here;
`main` on a git-flow repo only moves via `/promote-release` (github-workflows).

## All Branches Mode (Orchestrator)

Report sync status for all open PR branches.

### Steps

1. **Get repo**: `gh repo view --json nameWithOwner`
2. **Update default branch**: CRITICAL - must happen first (and its git-flow extra step above)
3. **List open PRs**: `gh pr list --state open --json number,headRefName,title`
4. **Check each PR**: Launch subagents in parallel (invoke `superpowers:dispatching-parallel-agents`).
   Each checks if behind `<DEFAULT_BRANCH>`. Do NOT merge or push.
5. **Report**: repo, `<DEFAULT_BRANCH>` SHA, merge-readiness for each PR (current/behind/conflict)
6. **Sync conflict-free branches**: For each branch classified as `behind` (not `conflict`) in step 5,
   merge `origin/<DEFAULT_BRANCH>` using `git merge origin/<DEFAULT_BRANCH> --no-edit`. Branches already classified as `conflict`
   in step 5 are skipped entirely — no merge is attempted on them, so no `git merge --abort` is needed.
   No confirmation required.
7. **Report conflicting branches**: Branches skipped due to pre-identified conflicts are reported for manual resolution

## Conflict Resolution

Read files, understand both versions, combine intelligently, stage resolved files, commit.

## DO NOT

- Blindly use `--theirs` or `--ours`
- Force push unless explicitly asked
- Skip reading conflicted files

## Related Skills

- **refresh-repo** (github-workflows) — PR status and default-branch sync
- **prune-branches** (github-workflows) — Stale branch and worktree cleanup
- **rebase-pr** (github-workflows) — Rebase-merge workflow that builds on a synced base branch
- **promote-release** (github-workflows) — Moves develop to main on git-flow repos; the fast-forward step here only reads main, never pushes it
- **gh-cli-patterns** (github-workflows) — Canonical default-branch detection (trunk vs git-flow)
- **git-workflow-standards** (git-workflows) — Branch hygiene and sync conventions

Attribution

dryvistdryvist
View sourceSee grades on GitHubMore from dryvist →
SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments (0)

No comments yet. Be the first to comment!

SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Related Skills

Caveman

Terse caveman voice: answer first, fluff gone, every technical fact kept. Use for /caveman, "caveman mode", "talk like caveman", "be brief", "less tokens". Stays on until "stop caveman" or "normal mode".

1100021 votes

Hyperplan

Adversarial multi-agent planning skill. Self-orchestrates 5 hostile category members (unspecified-low, unspecified-high, deep, ultrabrain, artistry) via team-mode for ruthless cross-critique debate, distills only the defensible insights, then MANDATORILY hands the distilled insight bundle to the `plan` agent for executable plan formalization. Use when planning needs maximum rigor and surfacing of weak assumptions, blind spots, and over-engineering. Triggers: 'hyperplan', 'hpp', '/hyperplan', ...

698431 votes

Writing Skills

Create and manage Claude Code skills in HASH repository following Anthropic best practices. Use when creating new skills, modifying skill-rules.json, understanding trigger patterns, working with hooks, debugging skill activation, or implementing progressive disclosure. Covers skill structure, YAML frontmatter, trigger types (keywords, intent patterns), UserPromptSubmit hook, and the 500-line rule. Includes validation and debugging with SKILL_DEBUG. Examples include rust-error-stack, cargo-dep...

3931 votes

Mcp Code Execution

Routes multi-tool workflows through MCP servers for large datasets and pipelines. Use when Bash tool overhead is limiting throughput on data-heavy tasks.

3421 votes

catchup

Recovers the conversation and failed tool calls of a previous Codex, Amp, Claude Code, Antigravity, Cline, Copilot CLI, Cursor, DeepSeek Harness, Grok Build, Kimi, OpenCode, Pi Agent, or ZCode session. Use when the user says "catch up", "what did the last session do", "get me up to speed", "I switched agents", asks to recover/summarize a previous session before continuing, or asks to diagnose or report a catchup failure. Do NOT use for the current conversation, git history, or any non-agent log.

741 votes
View all in ai-agents →