AgentSkillsCN

copilot-sync

从 github-copilot-base 模板中,将 GitHub Copilot 的配置文件(代理、提示词、技能、指令)同步至现有代码库。在覆盖原有配置前先创建备份。当您需要更新 Copilot 配置、同步 Copilot 文件,或使项目保持最新状态时,可使用此功能。可通过“同步 Copilot”“更新 Copilot”“Copilot 同步”“同步配置”等关键词触发。

SKILL.md
--- frontmatter
name: copilot-sync
description: Synchronize GitHub Copilot configuration files (agents, prompts, skills, instructions) from github-copilot-base template to existing codebases. Creates backups before overwriting. Use when updating Copilot configuration, syncing Copilot files, or bringing a project up to date. Triggers on sync copilot, update copilot, copilot sync, sync configuration.

Copilot Sync Skill

Synchronize GitHub Copilot configuration files from the base template to existing codebases.


Triggers

Activate this skill when user mentions:

  • "sync copilot", "copilot sync"
  • "update copilot files", "update copilot configuration"
  • "sync copilot config", "sync configuration"
  • "bring project up to date with copilot"
  • "#copilot-sync"

Description

The Copilot Sync skill synchronizes all Copilot-related files from the github-copilot-base template to an existing codebase:

  1. Agents - All .github/agents/*.md files
  2. Prompts - All .github/prompts/*.prompt.md files
  3. Skills - All .github/skills/*/ directories
  4. Instructions - .github/copilot-instructions.md
  5. PRP Framework - PRPs/ templates
  6. Supporting Docs - Background workflow, style guides

Key Features:

  • 💾 Automatic backups before overwriting
  • 👁️ Dry-run mode for previewing changes
  • ✅ Validation of target repository
  • 📊 Detailed sync statistics

Workflow Steps

1. Gather Information

Collect the following using ask_user:

QuestionPurposeValidation
Target pathCodebase to sync toMust exist, must be Git repo
Dry run?Preview changes firstYes/No

2. Validate Target

powershell
# Check path exists
if (-not (Test-Path $TargetPath -PathType Container)) {
    Write-Error "Path does not exist"
}

# Check it's a Git repository
if (-not (Test-Path (Join-Path $TargetPath ".git"))) {
    Write-Error "Not a Git repository"
}

3. Execute Sync

Dry Run (Preview):

powershell
$TemplateRepo = "E:\Repos\HouseGarofalo\github-copilot-base"
& "$TemplateRepo\scripts\sync-copilot.ps1" -TargetPath $TargetPath -DryRun

Apply Changes:

powershell
$TemplateRepo = "E:\Repos\HouseGarofalo\github-copilot-base"
& "$TemplateRepo\scripts\sync-copilot.ps1" -TargetPath $TargetPath

Force (No Prompts):

powershell
& "$TemplateRepo\scripts\sync-copilot.ps1" -TargetPath $TargetPath -Force

4. Post-Sync Guidance

After sync, guide user to:

  1. Review copilot-instructions.md - Add project-specific context
  2. Check backups - In .copilot-backup/ folder
  3. Commit changes:
    powershell
    git add .github PRPs docs
    git commit -m "chore: sync Copilot configuration from github-copilot-base"
    

5. Output Summary

Provide completion summary with:

  • Files synced count
  • New files count
  • Backups created
  • Next steps

What Gets Synced

CategoryPathDescription
Agents.github/agents/44+ custom agents
Prompts.github/prompts/50+ prompt files
Skills.github/skills/80+ skill definitions
Chat Modes.github/chatmodes/Chat mode configs
Instructions.github/copilot-instructions.mdMain instructions
Background Workflow.github/BACKGROUND_WORKFLOW.mdMulti-agent docs
Copilot Config.github/copilot/Copilot settings
VS Code Settings.vscode/Settings, extensions, MCP config
Copilot Ignore.copilotignoreFiles excluded from Copilot
Git Attributes.gitattributesLine endings and file handling
Pre-commit Config.pre-commit-config.yamlSecret detection (gitleaks)
Worktree Helperscripts/worktree-helper.ps1Git worktree utilities
PRP FrameworkPRPs/Templates & docs
Style Guidedocs/STYLE_GUIDE.mdDoc standards

Options

OptionDescriptionDefault
-TargetPathPath to target codebaseRequired
-DryRunPreview only, no changesFalse
-NoBackupSkip creating backupsFalse
-ForceSkip confirmation promptsFalse

Backup & Recovery

Backup Location:

code
<target>\.copilot-backup\
├── .github\
│   ├── copilot-instructions.md.<timestamp>.backup
│   └── agents\*.backup
└── PRPs\*.backup

Restore a File:

powershell
Copy-Item "<backup_file>" "<original_path>" -Force

Error Handling

ErrorResolution
Path doesn't existProvide valid path
Not a Git repoInitialize with git init
Permission deniedCheck write access
Backup failedUse -NoBackup or check disk space

Prerequisites

  • Git installed
  • Target must be an existing Git repository
  • Write access to target directory

Example

code
User: #copilot-sync E:\Repos\MyOrg\my-project

Copilot: 🔄 Copilot Sync

Validating target... ✅
Target is a Git repository... ✅

Would you like to preview changes first?
> Yes

📋 Dry Run:
   Would sync: 150 files
   New: 45 | Updated: 105

Apply changes?
> Yes

Syncing... ✅
Backing up existing files... ✅

🎉 Sync Complete!
   Files synced: 150
   Backups: .copilot-backup/

Next steps:
1. Review .github/copilot-instructions.md
2. Commit changes

Related