sync-skills

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Sync Skills

同步技能

Overview

概述

Automatically sync skills from multiple sources to all installed AI coding tool directories. Lists all existing target directories for user confirmation before syncing.
自动将来自多个来源的技能同步到所有已安装的AI编码工具目录。同步前会列出所有现有目标目录供用户确认。

When to Use

适用场景

dot
digraph when_sync {
    "Need to sync skill?" [shape=diamond];
    "Source type?" [shape=diamond];
    "Local folder" [shape=box];
    "GitHub URL" [shape=box];
    "skillsmp.com URL" [shape=box];

    "Need to sync skill?" -> "Source type?";
    "Source type?" -> "Local folder" [label="Local path"];
    "Source type?" -> "GitHub URL" [label="github.com"];
    "Source type?" -> "skillsmp.com URL" [label="skillsmp.com"];
}
Use when:
  • User provides local skill folder path
  • User provides GitHub repository URL
  • User provides skillsmp.com skill detail page URL
  • Need to distribute skill across multiple AI tools
How it works:
  1. Auto-detect source type from input
  2. Prepare skill content based on source
  3. Check all target directories (only existing ones)
  4. List existing targets for user confirmation
  5. Copy/clone to each confirmed target
dot
digraph when_sync {
    "Need to sync skill?" [shape=diamond];
    "Source type?" [shape=diamond];
    "Local folder" [shape=box];
    "GitHub URL" [shape=box];
    "skillsmp.com URL" [shape=box];

    "Need to sync skill?" -> "Source type?";
    "Source type?" -> "Local folder" [label="Local path"];
    "Source type?" -> "GitHub URL" [label="github.com"];
    "Source type?" -> "skillsmp.com URL" [label="skillsmp.com"];
}
适用场景:
  • 用户提供本地技能文件夹路径
  • 用户提供GitHub仓库URL
  • 用户提供skillsmp.com技能详情页URL
  • 需要将技能分发到多个AI工具中
工作原理:
  1. 根据输入自动检测来源类型
  2. 基于来源准备技能内容
  3. 检查所有目标目录(仅检测已存在的目录)
  4. 列出已存在的目标目录供用户确认
  5. 复制/克隆内容到每个用户确认的目标目录

Target Directories

目标目录

Checks these paths in order, only syncs if directory exists:
ToolProject LevelUser Level
Claude Code
.claude/skills
~/.claude/skills
GitHub Copilot
.github/skills
~/.copilot/skills
Google Antigravity
.agent/skills
~/.gemini/antigravity/skills
Cursor
.cursor/skills
~/.cursor/skills
OpenCode
.opencode/skill
~/.config/opencode/skill
OpenAI Codex
.codex/skills
~/.codex/skills
Gemini CLI
.gemini/skills
~/.gemini/skills
Windsurf
.windsurf/skills
~/.codeium/windsurf/skills
Qwen Code
.qwen/skills
~/.qwen/skills
Qoder
.qoder/skills
~/.qoder/skills
OpenClaw
.openclaw/skills
~/.openclaw/skills
按顺序检查以下路径,仅当目录存在时才会执行同步:
工具项目层级用户层级
Claude Code
.claude/skills
~/.claude/skills
GitHub Copilot
.github/skills
~/.copilot/skills
Google Antigravity
.agent/skills
~/.gemini/antigravity/skills
Cursor
.cursor/skills
~/.cursor/skills
OpenCode
.opencode/skill
~/.config/opencode/skill
OpenAI Codex
.codex/skills
~/.codex/skills
Gemini CLI
.gemini/skills
~/.gemini/skills
Windsurf
.windsurf/skills
~/.codeium/windsurf/skills
Qwen Code
.qwen/skills
~/.qwen/skills
Qoder
.qoder/skills
~/.qoder/skills
OpenClaw
.openclaw/skills
~/.openclaw/skills

Quick Reference

快速参考

Basic Usage:
bash
./sync-skill.sh <source>
Examples:
bash
undefined
基础用法:
bash
./sync-skill.sh <source>
示例:
bash
undefined

Local folder

本地文件夹

./sync-skill.sh /Users/user/skills/my-skill
./sync-skill.sh /Users/user/skills/my-skill

GitHub repository

GitHub仓库

skillsmp.com page

skillsmp.com页面

undefined
undefined

Source Type Detection

来源类型检测

bash
undefined
bash
undefined

Local folder

本地文件夹

/Users/user/skills/my-skill ./skills/my-skill ~/skills/my-skill
/Users/user/skills/my-skill ./skills/my-skill ~/skills/my-skill

GitHub URL

GitHub URL

skillsmp.com URL

skillsmp.com URL

Sync Commands by Source Type

按来源类型划分的同步命令

Local folder:
bash
cp -r /path/to/skill-name ~/.claude/skills/
cp -r /path/to/skill-name ~/.qoder/skills/
本地文件夹:
bash
cp -r /path/to/skill-name ~/.claude/skills/
cp -r /path/to/skill-name ~/.qoder/skills/

... for each existing target

... 对每个已存在的目标目录执行复制


**GitHub:**
```bash

**GitHub:**
```bash

Clone to temp

克隆到临时目录

git clone https://github.com/user/skill-repo.git /tmp/skill-sync
git clone https://github.com/user/skill-repo.git /tmp/skill-sync

Copy skill folder (might be in subdirectory)

复制技能文件夹(可能在子目录中)

cp -r /tmp/skill-sync/skill-name ~/.claude/skills/
cp -r /tmp/skill-sync/skill-name ~/.claude/skills/

... for each existing target

... 对每个已存在的目标目录执行复制

Cleanup

清理临时文件

rm -rf /tmp/skill-sync

**skillsmp.com:**
```bash
rm -rf /tmp/skill-sync

**skillsmp.com:**
```bash

Fetch page content

获取页面内容

curl -s https://skillsmp.com/skills/skill-name > /tmp/skill-page.html
curl -s https://skillsmp.com/skills/skill-name > /tmp/skill-page.html

Parse and download skill files

解析并下载技能文件

Extract skill content from page

从页面中提取技能内容

Create skill directory structure

创建技能目录结构

Copy to each target

复制到每个目标目录

undefined
undefined

Implementation

实现方式

Executable script: See
sync-skill.sh
in this skill directory.
Features:
  • Auto-detects source type (local, GitHub, skillsmp.com)
  • Checks all target directories for existence
  • Lists existing targets and waits for user confirmation before syncing
  • Only syncs to user-confirmed directories
  • Overwrites existing skills without prompting
  • Cleans up temporary files after use
  • Provides clear output with emoji indicators
Exit codes:
  • 0: Success
  • 1: Error (missing source, clone failure, etc.)
Using from AI assistant: When user asks to sync a skill, invoke the script with appropriate source:
bash
undefined
可执行脚本: 参见本技能目录下的
sync-skill.sh
文件。
特性:
  • 自动检测来源类型(本地、GitHub、skillsmp.com)
  • 检查所有目标目录是否存在
  • 列出已存在的目标目录,同步前等待用户确认
  • 仅同步到用户确认的目录
  • 无需提示直接覆盖现有技能
  • 使用后自动清理临时文件
  • 提供带emoji标识的清晰输出
退出码:
  • 0: 同步成功
  • 1: 出现错误(缺少来源、克隆失败等)
从AI助手调用: 当用户要求同步技能时,使用对应来源调用脚本:
bash
undefined

User says: "Sync the skill at /path/to/my-skill"

用户说:"同步 /path/to/my-skill 路径下的技能"

./sync-skill.sh /path/to/my-skill
./sync-skill.sh /path/to/my-skill

User says: "Sync this GitHub repo: https://github.com/user/skill"

用户说:"同步这个GitHub仓库:https://github.com/user/skill"

undefined
undefined

Source Detection

来源检测

javascript
function detectSource(input) {
  // Local folder
  if (input.startsWith('/') || input.startsWith('./') || input.startsWith('~')) {
    return { type: 'local', path: input };
  }

  // GitHub URL
  if (input.includes('github.com')) {
    const url = input.replace(/\.git$/, '');
    return { type: 'github', url };
  }

  // skillsmp.com URL
  if (input.includes('skillsmp.com')) {
    return { type: 'skillsmp', url: input };
  }

  throw new Error(`Unknown source type: ${input}`);
}
javascript
function detectSource(input) {
  // Local folder
  if (input.startsWith('/') || input.startsWith('./') || input.startsWith('~')) {
    return { type: 'local', path: input };
  }

  // GitHub URL
  if (input.includes('github.com')) {
    const url = input.replace(/\.git$/, '');
    return { type: 'github', url };
  }

  // skillsmp.com URL
  if (input.includes('skillsmp.com')) {
    return { type: 'skillsmp', url: input };
  }

  throw new Error(`Unknown source type: ${input}`);
}

Directory Existence Check and Confirmation

目录存在性检查与确认

bash
undefined
bash
undefined

Check if directory exists and collect for confirmation

Check if directory exists and collect for confirmation

check_and_sync() { local source=$1 local skill_name=$2

Array of all target directories

local targets=( "$HOME/.claude/skills" "$HOME/.qoder/skills" "$HOME/.copilot/skills" # ... all others )
local existing_targets=()

First pass: collect existing directories

for target in "${targets[@]}"; do if [ -d "$target" ]; then existing_targets+=("$target") fi done

List existing targets and ask for confirmation

if [ ${#existing_targets[@]} -eq 0 ]; then echo "❌ No target directories found. Please install at least one AI coding tool." exit 1 fi
echo "📋 Found ${#existing_targets[@]} existing target directory(s):" echo "" for i in "${!existing_targets[@]}"; do echo " $((i+1)). ${existing_targets[$i]}" done echo "" read -p "✅ Sync to these directories? (y/N): " confirm
if [[ ! "$confirm" =~ ^[Yy]$ ]]; then echo "❌ Sync cancelled by user." exit 1 fi
echo "" echo "🚀 Starting sync..."

Second pass: sync to confirmed targets

for target in "${existing_targets[@]}"; do echo " → Syncing to $target..." # Perform sync done }
undefined
check_and_sync() { local source=$1 local skill_name=$2

Array of all target directories

local targets=( "$HOME/.claude/skills" "$HOME/.qoder/skills" "$HOME/.copilot/skills" # ... all others )
local existing_targets=()

First pass: collect existing directories

for target in "${targets[@]}"; do if [ -d "$target" ]; then existing_targets+=("$target") fi done

List existing targets and ask for confirmation

if [ ${#existing_targets[@]} -eq 0 ]; then echo "❌ No target directories found. Please install at least one AI coding tool." exit 1 fi
echo "📋 Found ${#existing_targets[@]} existing target directory(s):" echo "" for i in "${!existing_targets[@]}"; do echo " $((i+1)). ${existing_targets[$i]}" done echo "" read -p "✅ Sync to these directories? (y/N): " confirm
if [[ ! "$confirm" =~ ^[Yy]$ ]]; then echo "❌ Sync cancelled by user." exit 1 fi
echo "" echo "🚀 Starting sync..."

Second pass: sync to confirmed targets

for target in "${existing_targets[@]}"; do echo " → Syncing to $target..." # Perform sync done }
undefined

GitHub Repository Handling

GitHub仓库处理

bash
undefined
bash
undefined

Clone to temp directory

Clone to temp directory

git clone https://github.com/user/repo.git /tmp/skill-sync-XXXXX
git clone https://github.com/user/repo.git /tmp/skill-sync-XXXXX

Find skill folder (might be root or subdirectory)

Find skill folder (might be root or subdirectory)

if [ -f /tmp/skill-sync-XXXXX/SKILL.md ]; then skill_folder="/tmp/skill-sync-XXXXX" elif [ -d /tmp/skill-sync-XXXXx/skills/* ]; then skill_folder="/tmp/skill-sync-XXXXx/skills/*" fi
if [ -f /tmp/skill-sync-XXXXX/SKILL.md ]; then skill_folder="/tmp/skill-sync-XXXXX" elif [ -d /tmp/skill-sync-XXXXx/skills/* ]; then skill_folder="/tmp/skill-sync-XXXXx/skills/*" fi

Copy to each existing target

Copy to each existing target

for target in "${existing_targets[@]}"; do cp -r "$skill_folder" "$target/" done
for target in "${existing_targets[@]}"; do cp -r "$skill_folder" "$target/" done

Cleanup

Cleanup

rm -rf /tmp/skill-sync-XXXXX
undefined
rm -rf /tmp/skill-sync-XXXXX
undefined

skillsmp.com Page Handling

skillsmp.com页面处理

bash
undefined
bash
undefined

Fetch page

Fetch page

url="https://skillsmp.com/skills/skill-name" curl -s "$url" > /tmp/skill-page.html
url="https://skillsmp.com/skills/skill-name" curl -s "$url" > /tmp/skill-page.html

Extract skill name and files

Extract skill name and files

skill_name=$(grep -o '<h1[^>]>.</h1>' /tmp/skill-page.html | sed 's/<[^>]*>//g')
skill_name=$(grep -o '<h1[^>]>.</h1>' /tmp/skill-page.html | sed 's/<[^>]*>//g')

Download or extract skill content

Download or extract skill content

This depends on skillsmp.com's structure

This depends on skillsmp.com's structure

Might need to parse JSON, download files, etc.

Might need to parse JSON, download files, etc.

Create skill directory

Create skill directory

mkdir -p "/tmp/$skill_name"
mkdir -p "/tmp/$skill_name"

Save content to SKILL.md

Save content to SKILL.md

... parsing logic ...

... parsing logic ...

Sync to targets

Sync to targets

for target in "${existing_targets[@]}"; do cp -r "/tmp/$skill_name" "$target/" done
undefined
for target in "${existing_targets[@]}"; do cp -r "/tmp/$skill_name" "$target/" done
undefined

Common Mistakes

常见错误

MistakeFix
Syncing without user confirmationAlways list targets and wait for
y/N
confirmation
Syncing to non-existent directoriesAlways check
-d
before copying
Leaving temp filesAlways cleanup
/tmp/skill-sync-*
after use
GitHub subdirectory confusionCheck for SKILL.md in root and subdirectories
Not handling .git suffixStrip
.git
from URLs before cloning
skillsmp.com parsing failuresInspect page structure first, adapt parsing
Forgetting to show skill nameAlways display skill name in confirmation prompt
错误修复方案
未经过用户确认就执行同步始终列出目标目录,等待用户输入
y/N
确认后再执行
同步到不存在的目录复制前始终使用
-d
参数检查目录是否存在
残留临时文件使用后始终清理
/tmp/skill-sync-*
目录
GitHub子目录识别错误同时检查根目录和子目录下是否存在SKILL.md文件
未处理.git后缀克隆前先去除URL末尾的
.git
后缀
skillsmp.com解析失败先检查页面结构,调整解析逻辑
未展示技能名称确认提示中始终显示当前同步的技能名称

Conflict Handling

冲突处理

Policy: Always overwrite existing skills
If a skill with the same name exists in a target directory:
  • Overwrite without prompting
  • Log what was overwritten:
    "Overwriting existing skill at $target/$skill_name"
  • No backup (user should use git if they need history)
Rationale: Sync operations are expected to update content. If user wants to preserve local changes, they should manage version control separately.
策略:始终覆盖现有技能
如果目标目录中已存在同名技能:
  • 无需提示直接覆盖
  • 记录覆盖操作:
    "Overwriting existing skill at $target/$skill_name"
  • 不提供备份(如果需要历史版本,用户应使用git自行管理)
设计逻辑: 同步操作的预期就是更新内容,如果用户需要保留本地修改,应该自行通过版本控制工具管理。