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 user wants to sync all repos (not just one), mentions 「下班同步」「上班更新」 「code-sync」, or describes end-of-day push / morning pull across ~/code. Triggers on: "sync all my repos", "end of day sync", "morning update", "push all dirty repos", "pull all projects", 「同步代码」「下班同步」「上班更新」. Do NOT trigger for: single-repo git operations, committing specific files (use git-workflow), general git push/pull questions, or workspace template updates.

Safety Notice

This listing is from the official public ClawHub registry. Review SKILL.md and referenced scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "code-sync" with this command: npx skills add niracler/skill

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: <base-dir>/*/ for top-level repos and <base-dir>/*/repos/*/ for monorepo sub-repos
  3. 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 <branch>), 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

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

Allergy

Take control of Allergy with this health & wellness toolkit. Clean interface, local storage, zero configuration.

Registry SourceRecently Updated
General

wps_office_auto_skill

本地办公自动化,支持文档生成与润色,合同审查,表格清洗与分析,PPT制作,PDF转换与批量处理。

Registry SourceRecently Updated
General

Encrypt

Encrypt - command-line tool for everyday use

Registry SourceRecently Updated
General

Succession Plan

继任计划。关键岗位识别、人才评估、发展路径、过渡方案、知识转移、紧急继任。Succession planning. 继任、人才管理。

Registry SourceRecently Updated