← 返回
开发者工具

Code Sync

Use this skill to batch-sync all git repos across machines — pushing uncommitted changes at end of day or pulling latest at start of day. Invoke when the use...
使用此技能可批量同步所有 git 仓库在不同机器上——在一天结束时推送未提交的更改,或在一天开始时拉取最新代码。需要时调用。
niracler niracler 来源
开发者工具 clawhub v0.3.0 3 版本 99871.1 Key: 无需
★ 0
Stars
📥 775
下载
💾 4
安装
3
版本
#latest

概述

Code Sync

Batch sync all git repos under a base directory — push (end-of-day) or pull (start-of-day).

Default base directory: ~/code. Configurable via ~/.config/nini-skill/code-sync/config.md.

Prerequisites

ToolTypeRequiredInstall
-------------------------------
gitcliYesbrew install git or git-scm.com
git-workflowskillYesIncluded in npx skills add niracler/skillmust be invoked via Skill tool for all commits

> Do NOT proactively verify these tools on skill load. If a command fails due to a missing tool, directly guide the user through installation and configuration step by step.

First-Time Setup

On first use, check for config at ~/.config/nini-skill/code-sync/config.md.

If not found, ask the user:

  1. "Where do you keep your git repos?" (default: ~/code)
  2. "What's the directory structure?" — explain the expected pattern:

// for top-level repos and //repos/*/ for monorepo sub-repos

  1. Save to ~/.config/nini-skill/code-sync/config.md:
base_dir: ~/code

Mode Selection

User saysMode
-----------------
「下班同步」or "push"Push
「上班更新」or "pull"Pull
「同步代码」「code-sync」Ask user

Workflow (shared by both modes)

  1. Scan → 2. Categorize → 3. Batch action (auto, no confirmation) → 4. Handle exceptions (interactive) → 5. Summary

If all repos are up-to-date, report that and stop.

Scan

bash scripts/scan.sh                          # Push: local data only (default ~/code)
bash scripts/scan.sh --fetch                  # Pull: fetch remote first (10s timeout/repo)
bash scripts/scan.sh --base-dir /path/to/dir  # Custom base directory

Output: JSON array with fields path, name, branch, remote, remote_url, dirty_count, has_upstream, ahead, behind, and fetch_error (only on --fetch failure).

Categorize

Push mode:

CategoryConditionAction
-----------------------------
up-to-datedirty_count == 0 && ahead == 0Report
needs-pushdirty_count == 0 && ahead > 0Auto git push
dirtydirty_count > 0Interactive
no-upstreamhas_upstream == falseAsk user

Pull mode:

CategoryConditionAction
-----------------------------
up-to-datedirty_count == 0 && behind == 0Report
needs-pulldirty_count == 0 && behind > 0Auto git pull --ff-only
dirty+behinddirty_count > 0 && behind > 0Interactive
fetch-errorfetch_error == trueReport, skip

Exception Handling

SituationSteps
------------------
Dirty repo (push)git diff --stat + git status → describe to user → ask: commit, stash, or skip. If commit, MUST invoke git-workflow skill via Skill tool — never run git commit directly.
No upstream (push)Report → ask: set upstream and push (git push -u origin ), or skip
ff-only fails (pull)git log --oneline HEAD..@{u} + @{u}..HEAD → explain divergence → suggest: rebase, merge, or skip
Dirty + behind (pull)Report both issues → ask: stash and pull (stash, pull --ff-only, pop), or skip

Summary

Group repos by outcome after all operations complete:

## {Push|Pull} Summary

{Pushed|Updated} (N):
  - repo-name (branch, N commits)
Already up-to-date (N):
  - repo-a, repo-b, ...
Resolved (N):
  - repo-c: action taken
Skipped (N):
  - repo-d: reason

Common Issues

IssueFix
------------
scan.sh finds 0 reposCheck ~/code/*/ has git repos
fetch_errorCheck network, SSH keys
ff-only failsRebase or merge manually
Push rejectedPull first, then push

版本历史

共 3 个版本

  • v0.3.0 当前
    2026-05-03 03:43 安全 安全
  • v0.2.1
    2026-03-29 12:37 安全 安全
  • v0.1.2
    2026-03-26 21:41

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

dev-programming

CodeConductor.ai

larsonreever
AI驱动平台,提供快速全栈开发、智能体、工作流自动化及低代码AI集成的可扩展产品创建。
★ 71 📥 181,343
content-creation

Writing Proofreading

niracler
Use when user wants to review, polish, or proofread articles. Triggers include「帮我改文章」「检查一下」「润色」「帮我改改」「校对一下」「看看文章」.
★ 0 📥 1,417
dev-programming

Github

steipete
使用 `gh` CLI 与 GitHub 交互,通过 `gh issue`、`gh pr`、`gh run` 和 `gh api` 管理议题、PR、CI 运行及高级查询。
★ 676 📥 325,527