AgentSkillsCN

sync-copilot-assets

将 GitHub Copilot 的自定义资产(代理、指令、提示词、技能)从中央仓库同步至多个目标工作空间。当您需要在不同项目间分发或更新 Copilot 资产时,可使用此技能。关键词:同步、分发、复制、传播、资产、代理、指令、提示词、技能、仓库。

SKILL.md
--- frontmatter
name: sync-copilot-assets
description: 'Synchronize GitHub Copilot customization assets (agents, instructions, prompts, skills) from a central repository to multiple target workspaces. Use when you need to distribute or update Copilot assets across projects. Keywords: sync, distribute, copy, propagate, assets, agents, instructions, prompts, skills, repositories.'
license: Complete terms in LICENSE.txt

Sync Copilot Assets

Synchronize GitHub Copilot customization assets from this repository to multiple target repositories using a cross-platform Node.js script.

When to Use This Skill

  • You want to distribute Copilot assets to multiple projects
  • You need to update existing assets across workspaces
  • You're maintaining a central repository of Copilot customizations
  • Keywords: sync, distribute, copy, propagate, assets, agents, instructions, prompts, skills

⚠️ Critical Warning

This sync performs FULL OVERWRITE synchronization. Files in target repositories that don't exist in source WILL BE DELETED. Always run dry-run first.

Prerequisites

  • Node.js 18.x or later (check with node --version)
  • No additional dependencies or npm packages needed
  • Works on Windows, macOS, and Linux

Configuration

Before syncing, configure your target repositories in sync-targets.txt at the repository root:

txt
# One absolute path per line
/Users/username/projects/project-alpha
/Users/username/projects/project-beta

See sync-targets-example.txt for a complete example.

Step-by-Step Workflow

Step 1: Verify Configuration

Check that target repositories are configured:

bash
cat sync-targets.txt

If empty or only comments, add target paths first.

Step 2: Preview Changes (Dry-Run)

ALWAYS run dry-run first:

bash
node .github/skills/sync-copilot-assets/scripts/sync-copilot-assets.mjs --dry-run

Review the output to see what would be added, updated, or deleted.

Step 3: Execute Sync

After confirming the dry-run output, run the actual sync:

bash
node .github/skills/sync-copilot-assets/scripts/sync-copilot-assets.mjs

Step 4: Commit Changes in Targets

After syncing, commit changes in each target repository:

bash
cd /path/to/target-repo
git add .github/
git commit -m "chore: sync Copilot assets from copilot-resources"
git push

Script Options

FlagDescription
-n, --dry-runPreview changes without modifying any files
-q, --quietSuppress progress output (errors still shown)
-h, --helpDisplay detailed usage information
-v, --versionShow script version

Synced Asset Directories

DirectoryContents
.github/agents/Agent definition files (.agent.md)
.github/instructions/Instruction files (.instructions.md)
.github/prompts/Prompt files (.prompt.md)
.github/skills/Skill folders with resources

Output Indicators

SymbolMeaning
+File added (new)
File updated (overwritten)
-File deleted (removed from target)

Exit Codes

CodeMeaning
0All targets synced successfully
1Partial success (some targets failed/skipped)
2Critical failure (missing source, invalid config)

Troubleshooting

IssueCauseSolution
"Configuration file not found"sync-targets.txt missingCreate the file with target paths
"Target path does not exist"Repo not cloned or wrong pathVerify path exists; clone repo if needed
"Permission denied"No write access to targetCheck filesystem permissions
"Node.js X.x required"Node.js version too oldUpdate Node.js to 18.x or later
"Source directories not found"Running from wrong directoryRun from repository root

Recovering from Mistakes

If you accidentally synced unwanted changes:

bash
cd /path/to/target-repo
git checkout -- .github/

Or reset to previous commit:

bash
git reset --hard HEAD~1

Cross-Platform Notes

Works identically on Windows, macOS, and Linux.

Path formats in sync-targets.txt:

  • Windows: C:\Users\username\projects\repo or C:/Users/username/projects/repo
  • macOS: /Users/username/projects/repo
  • Linux: /home/username/projects/repo

References