← 返回 Skills 市场
niracler

Code Sync

作者 Niracler · GitHub ↗ · v0.3.0 · MIT-0
cross-platform ✓ 安全检测通过
425
总下载
0
收藏
0
当前安装
6
版本数
在 OpenClaw 中安装
/install nini-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...
使用说明 (SKILL.md)

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

Tool Type Required Install
git cli Yes brew install git or git-scm.com
git-workflow skill Yes Included 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: \x3Cbase-dir>/*/ for top-level repos and \x3Cbase-dir>/*/repos/*/ for monorepo sub-repos
  3. Save to ~/.config/nini-skill/code-sync/config.md:
base_dir: ~/code

Mode Selection

User says Mode
「下班同步」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:

Category Condition Action
up-to-date dirty_count == 0 && ahead == 0 Report
needs-push dirty_count == 0 && ahead > 0 Auto git push
dirty dirty_count > 0 Interactive
no-upstream has_upstream == false Ask user

Pull mode:

Category Condition Action
up-to-date dirty_count == 0 && behind == 0 Report
needs-pull dirty_count == 0 && behind > 0 Auto git pull --ff-only
dirty+behind dirty_count > 0 && behind > 0 Interactive
fetch-error fetch_error == true Report, skip

Exception Handling

Situation Steps
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 \x3Cbranch>), 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

Issue Fix
scan.sh finds 0 repos Check ~/code/*/ has git repos
fetch_error Check network, SSH keys
ff-only fails Rebase or merge manually
Push rejected Pull first, then push
安全使用建议
This skill appears to do what it says: scan ~/code (or a configured base dir) and push/pull repositories. Before installing: 1) Be aware it can automatically push or pull repos — that can expose or change work in bulk; consider running a dry run or review mode first. 2) Inspect or audit the referenced 'git-workflow' skill before allowing it to perform commits (SKILL.md requires invoking it for commits via the Skill tool). 3) Note it writes config to ~/.config/nini-skill/code-sync/config.md and outputs remote URLs in scan results; if you store any sensitive tokens in remote URLs (unusual but possible), treat those outputs as sensitive. 4) If you want an extra safety layer, run the included scripts locally yourself to observe behavior before granting the skill autonomous use.
功能分析
Type: OpenClaw Skill Name: nini-code-sync Version: 0.3.0 The skill is a legitimate utility for batch-synchronizing git repositories in a specified directory (defaulting to ~/code). The included shell script (scripts/scan.sh) safely gathers git metadata such as branch names, remote URLs, and commit counts using standard git commands, and the SKILL.md provides clear instructions for the agent to handle push/pull workflows. No evidence of data exfiltration, malicious execution, or harmful prompt injection was found.
能力评估
Purpose & Capability
The skill claims to batch-sync git repos and only requires the git binary; that aligns with the included scan script and the described workflow. One minor inconsistency: SKILL.md says a separate 'git-workflow' skill is required for commits (installed via an npx command), but that external skill is not declared in the registry metadata. This is likely an implementation detail rather than a sign of malice, but you should verify the referenced 'git-workflow' skill before allowing commits.
Instruction Scope
Instructions and the script stay within the stated scope: scanning a base directory (~/.config path for configuration), enumerating repos, optionally running git fetch, and returning JSON status. A functional caveat: the workflow performs automated push/pull actions ('auto, no confirmation' for certain categories) which can modify remote state without an explicit per-repo prompt. The skill also collects remote URLs (remote_url) in its scan output, which is expected for this purpose but is data you may not want transmitted elsewhere.
Install Mechanism
No install spec — instruction-only plus an included shell script. Nothing is downloaded or extracted; the script is local and runs git commands. This is the lowest-risk install pattern.
Credentials
The skill requests no environment variables or credentials. It does read $HOME and writes/reads a config at ~/.config/nini-skill/code-sync/config.md. It also exposes remote URLs from git remotes in its JSON output — reasonable for a sync tool but consider whether those URLs (which might contain embedded credentials in unusual setups) should be handled or stored.
Persistence & Privilege
The skill does not request always:true and has no system-wide modifications. It will create a config file under the user's home config directory on first run, which is normal for user-level tools.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install nini-code-sync
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /nini-code-sync 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v0.3.0
Release v0.3.0 — see https://github.com/niracler/skill/releases/tag/v0.3.0
v0.2.1
Release v0.2.1 — see https://github.com/niracler/skill/releases/tag/v0.2.1
v0.2.0
Release v0.2.0 — see https://github.com/niracler/skill/releases/tag/v0.2.0
v0.1.2
Release v0.1.2 — see https://github.com/niracler/skill/releases/tag/v0.1.2
v0.1.1
Release v0.1.1 — see https://github.com/niracler/skill/releases/tag/v0.1.1
v0.1.0
Initial release: Batch sync git repos across machines (push/pull)
元数据
Slug nini-code-sync
版本 0.3.0
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 6
常见问题

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... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 425 次。

如何安装 Code Sync?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install nini-code-sync」即可一键安装,无需额外配置。

Code Sync 是免费的吗?

是的,Code Sync 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

Code Sync 支持哪些平台?

Code Sync 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 Code Sync?

由 Niracler(@niracler)开发并维护,当前版本 v0.3.0。

💬 留言讨论