git-sync-workspace
Skill9 starsChanged 3 months agoMITView on GitHub
Sync every git repo in a Cursor multi-root workspace to its remote default branch: discover roots, preflight each repo, fetch --all --prune, checkout default, pull --ff-only. Skips dirty or unsafe repos with a clear report. Use for "sync workspace", "update all repos", "back to main", or reset workspace repos to remote HEAD without losing uncommitted work.
- Deletes or force-pushes
In this repository43 other files it gives its agents.
- accessibility-auditSkill
- add-documentationSkill
- add-error-handlingSkill
- address-github-pr-commentsSkill
- agent-risk-reviewSkill
- agent-work-receiptSkill
- automation-roi-auditSkill
- blind-spot-passSkill
- code-reviewSkill
- commit-changes-mainSkill
- commit-same-branchSkill
- commitSkill
- create-pr-mainSkill
- debug-issueSkill
- decision-auditSkill
- define-agent-goalSkill
- design-agent-loopSkill
- fix-compile-errorsSkill
- fix-git-issuesSkill
- gauntlet-loopSkill
- generate-api-docsSkill
- generate-pr-descriptionSkill
- instruction-ablationSkill
- light-review-existing-diffsSkill
- lint-fixSkill
- lint-suiteSkill
- merge-open-prsSkill
- optimize-performanceSkill
- pathfinderSkill
- prompt-eval-debugSkill
- refactor-codeSkill
- requirement-to-implementationSkill
- run-all-tests-and-fixSkill
- scoped-auditSkill
- security-auditSkill
- seo-auditSkill
- setup-new-featureSkill
- structure-promptSkill
- tddSkill
- thermo-nuclear-code-quality-reviewSkill
- update-memory-bankSkill
- update-readmeSkill
- write-unit-testsSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
15 rules. About 0 are common, 7 are distinctive, and 8 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈7
Distinctive · estimate
This author's own choices. Worth a look.
8
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Very specific: line 19
Use when the user wants every repo in a multi-root workspace updated after context-switching, before cross-repo assessments, or when …
- Distinctive: line 23
Run phases in order. Preflight every repo before any write.
- Very specific: line 28
Host profile (fallback): if no workspace file, read optional profiles/repos.yaml beside this skill (see Host overlay).
- Very specific: line 29
Ask (last resort): if discovery yields nothing, ask the user which paths to include.
- Distinctive: line 31
If the user scopes the request (e.g.
- Distinctive: line 35
Before modifying any repo, show a preflight table:
- Very specific: line 50
Dirty policy (hard rule): if the working tree is not clean, or checkout to default would strand unpushed commits the user has not …
- Distinctive: line 61
Concurrency: run git fetch --all --prune across repos in parallel with a cap of ≤ 6 concurrent shell sessions.
- Very specific: line 63
If pull --ff-only fails (diverged local commits on default), mark the repo failed, capture stderr, and do not merge or rebase without …
- Distinctive: line 77
Never git reset --hard, git clean, or force-push unless the user explicitly requests it in the same turn with per-repo confirmation.
- Distinctive: line 78
Never checkout over a dirty working tree.
- Distinctive: line 79
Never discard stashes or delete branches without approval.
- Very specific: line 84
When no .code-workspace file is present, the host workspace may provide a repo list.
- Very specific: line 99
scoped-audit: read-only orchestration across a surface, not git checkout/pull. - Very specific: line 104
Use pull --ff-only and never git reset --hard or force-push without explicit per-repo approval.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 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.
Files
Git sync workspace
Role
You sync multiple git repositories in a Cursor workspace to the latest remote default branch (main or master). This is the safe "back to base state" routine: fetch, checkout default, fast-forward pull, not a destructive reset.
When to use
Use when the user wants every repo in a multi-root workspace updated after context-switching, before cross-repo assessments, or when starting fresh work from remote HEAD. For a single broken repo (merge conflict, detached HEAD), use fix-git-issues instead.
Workflow
Run phases in order. Preflight every repo before any write.
Phase 0: Discover repos
- Workspace file (preferred): find
*.code-workspaceunder the Cursor workspace root(s). Parsefolders[].pathand resolve relative paths against the workspace file location. - Host profile (fallback): if no workspace file, read optional
profiles/repos.yamlbeside this skill (see Host overlay). - Ask (last resort): if discovery yields nothing, ask the user which paths to include. Do not scan arbitrary
~/code/*without direction. - De-duplicate paths. Keep only directories that contain a
.gitdirectory. - If the user scopes the request (e.g. "only repo1 and repo2"), filter to matching paths only.
Phase 1: Preflight (read-only, every repo)
Before modifying any repo, show a preflight table:
| Path | Current branch | Default branch | Working tree | Ahead / behind |
Collect:
- Path: repository root (absolute or workspace-relative).
- Current branch:
git branch --show-current(note detached HEAD). - Default branch: from
git symbolic-ref refs/remotes/origin/HEAD(striprefs/remotes/origin/), elsemain, elsemaster. - Working tree:
git status --porcelain(empty = clean). - Ahead / behind:
git rev-list --left-right --count @{u}...HEADwhen upstream exists.
Also detect in-progress operations (merge, rebase, cherry-pick) via git status or .git/MERGE_HEAD / .git/rebase-merge. Treat these as unsafe; skip with reason skipped_unsafe.
Dirty policy (hard rule): if the working tree is not clean, or checkout to default would strand unpushed commits the user has not explicitly accepted losing, do not modify that repo. Record skipped_dirty or skipped_unsafe and continue other repos.
Phase 2: Sync (clean repos only)
For each repo that passed preflight:
- Record
old_sha:git rev-parse HEAD(when on default) or note branch switch. git checkout <default_branch>. If local branch missing, create tracking branch fromorigin/<default>.git fetch --all --prunegit pull --ff-only. If no upstream is set, usegit merge --ff-only origin/<default>instead.
Concurrency: run git fetch --all --prune across repos in parallel with a cap of ≤ 6 concurrent shell sessions. Serialize checkout and pull per repo (one repo at a time for those steps) to avoid races.
If pull --ff-only fails (diverged local commits on default), mark the repo failed, capture stderr, and do not merge or rebase without explicit user approval.
Phase 3: Report
Emit a workspace summary with three sections:
Synced: path, branch, old_sha → new_sha (short)
Skipped: path, status (skipped_dirty, skipped_unsafe, no_remote), reason
Failed: path, failing command, stderr excerpt
Safety
- Never
git reset --hard,git clean, or force-push unless the user explicitly requests it in the same turn with per-repo confirmation. - Never checkout over a dirty working tree.
- Never discard stashes or delete branches without approval.
- Redact credentials in
git remote -voutput if shown to the user.
Host overlay
When no .code-workspace file is present, the host workspace may provide a repo list. Copy the template from profiles/repos.yaml in this skill directory:
repos:
- path: ../repo1
- path: ../repo2Paths are relative to the file location or absolute. The agent reads this file only when workspace-file discovery fails.
Distinction from other commands
fix-git-issues: reactive troubleshooting (conflicts, detached HEAD), not bulk workspace sync.commit/commit-same-branch: start new work on a branch; this ends on default at remote HEAD.merge-open-prs: merges PRs then syncs one repo, not a workspace-wide default-branch sync.scoped-audit: read-only orchestration across a surface, not git checkout/pull.
Guardrails
- Preflight every repo and skip any dirty working tree (record
skipped_dirty); never checkout or pull over uncommitted changes. - Use
pull --ff-onlyand nevergit reset --hardor force-push without explicit per-repo approval. - Discover repos from the workspace file or user scope; do not guess paths outside discovery.
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
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.

