sync-skills
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSync 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:
- Auto-detect source type from input
- Prepare skill content based on source
- Check all target directories (only existing ones)
- List existing targets for user confirmation
- 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工具中
工作原理:
- 根据输入自动检测来源类型
- 基于来源准备技能内容
- 检查所有目标目录(仅检测已存在的目录)
- 列出已存在的目标目录供用户确认
- 复制/克隆内容到每个用户确认的目标目录
Target Directories
目标目录
Checks these paths in order, only syncs if directory exists:
| Tool | Project Level | User Level |
|---|---|---|
| Claude Code | | |
| GitHub Copilot | | |
| Google Antigravity | | |
| Cursor | | |
| OpenCode | | |
| OpenAI Codex | | |
| Gemini CLI | | |
| Windsurf | | |
| Qwen Code | | |
| Qoder | | |
| OpenClaw | | |
按顺序检查以下路径,仅当目录存在时才会执行同步:
| 工具 | 项目层级 | 用户层级 |
|---|---|---|
| Claude Code | | |
| GitHub Copilot | | |
| Google Antigravity | | |
| Cursor | | |
| OpenCode | | |
| OpenAI Codex | | |
| Gemini CLI | | |
| Windsurf | | |
| Qwen Code | | |
| Qoder | | |
| OpenClaw | | |
Quick Reference
快速参考
Basic Usage:
bash
./sync-skill.sh <source>Examples:
bash
undefined基础用法:
bash
./sync-skill.sh <source>示例:
bash
undefinedLocal folder
本地文件夹
./sync-skill.sh /Users/user/skills/my-skill
./sync-skill.sh /Users/user/skills/my-skill
GitHub repository
GitHub仓库
./sync-skill.sh https://github.com/user/skill-repo
./sync-skill.sh https://github.com/user/skill-repo
skillsmp.com page
skillsmp.com页面
./sync-skill.sh https://skillsmp.com/skills/skill-name
undefined./sync-skill.sh https://skillsmp.com/skills/skill-name
undefinedSource Type Detection
来源类型检测
bash
undefinedbash
undefinedLocal 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
https://github.com/user/skill-repo
https://github.com/user/skill-repo.git
git@github.com:user/skill-repo.git
https://github.com/user/skill-repo
https://github.com/user/skill-repo.git
git@github.com:user/skill-repo.git
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:**
```bashClone 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:**
```bashrm -rf /tmp/skill-sync
**skillsmp.com:**
```bashFetch 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
复制到每个目标目录
undefinedundefinedImplementation
实现方式
Executable script: See in this skill directory.
sync-skill.shFeatures:
- 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
undefinedUser 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"
./sync-skill.sh https://github.com/user/skill
undefined./sync-skill.sh https://github.com/user/skill
undefinedSource 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
undefinedbash
undefinedCheck 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
}
undefinedcheck_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
}
undefinedGitHub Repository Handling
GitHub仓库处理
bash
undefinedbash
undefinedClone 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
undefinedrm -rf /tmp/skill-sync-XXXXX
undefinedskillsmp.com Page Handling
skillsmp.com页面处理
bash
undefinedbash
undefinedFetch 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
undefinedfor target in "${existing_targets[@]}"; do
cp -r "/tmp/$skill_name" "$target/"
done
undefinedCommon Mistakes
常见错误
| Mistake | Fix |
|---|---|
| Syncing without user confirmation | Always list targets and wait for |
| Syncing to non-existent directories | Always check |
| Leaving temp files | Always cleanup |
| GitHub subdirectory confusion | Check for SKILL.md in root and subdirectories |
| Not handling .git suffix | Strip |
| skillsmp.com parsing failures | Inspect page structure first, adapt parsing |
| Forgetting to show skill name | Always display skill name in confirmation prompt |
| 错误 | 修复方案 |
|---|---|
| 未经过用户确认就执行同步 | 始终列出目标目录,等待用户输入 |
| 同步到不存在的目录 | 复制前始终使用 |
| 残留临时文件 | 使用后始终清理 |
| GitHub子目录识别错误 | 同时检查根目录和子目录下是否存在SKILL.md文件 |
| 未处理.git后缀 | 克隆前先去除URL末尾的 |
| 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自行管理)
设计逻辑: 同步操作的预期就是更新内容,如果用户需要保留本地修改,应该自行通过版本控制工具管理。