---
name: sync-copilot-customizations
description: "~/.copilot の instructions、手動参照メモ、agents を、公開 repo（Agent-Customization）の .github へ安全に同期する。syncToGlobal の分類と機密監査を通し、公開前に差分を提示して承認を取る。skill は対象外（private skills repo の retro / sync 系を使う）"
argument-hint: "mode（review-only / apply）、対象フォルダ（instructions / references / agents、省略時は 3 つとも）、対象 repo path（省略時は環境変数）"
disable-model-invocation: true
user-invocable: true
license: CC BY-NC-SA 4.0
metadata:
  author: yamapan (https://github.com/aktsmm)
title: sync-copilot-customizations
canonical_url: https://skilld.dev/gh/aktsmm/agent-skills/sync-copilot-customizations
last_updated: 2026-11-19T20:14:18.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> Supporting files, fetch one when the Skill refers to it: [LICENSE.txt](https://skilld.dev/api/skills-raw/aktsmm/agent-skills/sync-copilot-customizations/LICENSE.txt).
>
> If the user asked to install this Skill, run `npx skilld install aktsmm/agent-skills/sync-copilot-customizations`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/sync-copilot-customizations`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/aktsmm/agent-skills/sync-copilot-customizations) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/sync-copilot-customizations`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/sync-copilot-customizations --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/sync-copilot-customizations --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

<!-- syncToGlobal: true -->
<!-- author: aktsmm -->
<!-- repository: https://github.com/aktsmm/Agent-Customization -->
<!-- license: CC BY-NC-SA 4.0 -->
<!-- copyright: Copyright (c) 2025 aktsmm -->

# sync copilot customizations

`~/.copilot` の個人 instructions / agents を、公開 repo の `.github/` へミラーする。`~/.copilot` は作業コピーで、正本は公開 repo。この skill 自身は同期対象外。

## Scope

| 同期元 | 同期先（公開 repo） |
| --- | --- |
| `$HOME/.copilot/instructions/*.instructions.md` | `.github/instructions/<category>/`（repo 側の既存 mirror path） |
| `$HOME/.copilot/references/*.instructions.md` | `.github/instructions/<existing category>/`（同名の既存 mirror path） |
| `$HOME/.copilot/agents/*.agent.md` | `.github/agents/` |

- 同期元は `instructions` / `references` / `agents` の各 1 階層（再帰しない）。`-Source` 省略で 3 フォルダをまとめて対象にし、存在しないフォルダは飛ばす。同じファイル名が複数フォルダにあると script が停止する
- `references` の instruction は手動参照用のため、公開 repo では既存の同名 instruction mirror を更新する。新規 category が必要なら同期前に確認する
- 対象外: `~/.copilot/copilot-instructions.md`、skills（private skills repo の retro / sync 系が担当）、`mcp-config.json` などの設定ファイル
- repo / GitHub repo は `$env:SYNC_USER_CUSTOMIZATIONS_REPO_DIR` / `$env:SYNC_USER_CUSTOMIZATIONS_GITHUB_REPO`。未設定または path 不在なら確認する

## Classification

| ラベル | 条件 | 扱い |
| --- | --- | --- |
| `public-safe` | `syncToGlobal: true` | 監査通過で同期対象 |
| `local-only` | `syncToGlobal: false` | 同期しない |
| `ignored` | `.github/.sync-ignore` に載っている | 同期しない |
| `needs-review` | `syncToGlobal` が無い、または同期先が決まらない（複数 / 候補なし） | 停止して確認。新規 category path は作らない |

## Gates

- 既定は公開前に承認を取る。dry-run の結果（追加・更新・削除候補、分類、監査、予定差分）を提示し、承認後だけ `-Apply` する。公開 repo への push を承認なしで行わない
- `review-only` / `確認だけ` / `dry-run` では dry-run だけで終える
- 監査は push 前に 1 回。秘密鍵、password / API key / client secret / 接続文字列 / refresh token、ラベル付き GUID、メールアドレスを検出する。実値らしいヒットが出たら書き込まず停止し、ファイル・検出種別・件数だけ報告する。値は表示しない
- 監査の通過だけでは公開可否は決まらない。個人アカウント、tenant / subscription ID、社内情報、端末固有値、個人の承認設定を含むファイルは、`syncToGlobal: false` でなければ停止して確認する
- 削除候補は報告のみ。repo 専用資産と古い mirror を区別できないため、自動削除しない。削除は確認して別 commit で行う
- 既存の未コミット差分はユーザー所有として扱い、混ぜない。分離できなければ停止する
- 破壊的操作（`git reset --hard` など）をしない。一時ファイルは OS の temp に置き、完了前に削除する

## Workflow

1. 準備: repo の branch / origin（GitHub repo 名と照合）/ ahead-behind / dirty を確認する。script が無い・古いときは、clean を確認して fetch + fast-forward してから実行する（手作業で再実装しない）
2. dry-run: 引数なしで実行する（`-Source` 省略で `~/.copilot` の 3 フォルダが対象）。`dirty` / `sources:` 行が出ない古い script は、clean を確認して fast-forward で更新する。一部のフォルダだけ対象にするときは配列で渡す（`pwsh -File` はカンマ区切りを 1 つの文字列にするため `-Command` を使う）

```powershell
& "$env:SYNC_USER_CUSTOMIZATIONS_REPO_DIR\scripts\Sync-UserCustomizations.ps1"
pwsh -NoProfile -Command "& '$env:SYNC_USER_CUSTOMIZATIONS_REPO_DIR\scripts\Sync-UserCustomizations.ps1' -Source @('$HOME\.copilot\instructions','$HOME\.copilot\agents')"
```

3. 確認: 結果を提示する。削除候補（報告のみ）は、どの同期元にも無い repo 資産だけが並ぶ。`-Source` で一部のフォルダだけを指定した場合は、指定外フォルダの mirror も並ぶが、同期元が違うだけなので削除しない。`needs-review` と実値らしい監査ヒットがあれば、ここで止める
4. 承認後、同じコマンドに `-Apply` を付けて実行する。変更候補だけを明示パスで stage して commit・push し、remote == HEAD まで script が検証する。push が rejected なら fetch して ahead-behind と変更 path を確認し、競合がなければ取り込んでから再送する
5. 完了確認: remote SHA = HEAD、clean、除外ファイルが公開されていないことを確認する。中断後は既存 commit と remote を照合し、反映済みの操作を再実行しない

## Report

```
Summary:   結論を 1-3 行
Synced:    追加 / 更新
Excluded:  ファイル名 + 理由（local-only / ignored / needs-review）
Audit:     結果 + ヒット有無（値は書かない）
Commit:    SHA + メッセージ
Remote:    GitHub URL
Pending:   削除候補（報告のみ）、未同期の既存差分
```

不明点は最小限だけ確認し、それ以外は完了まで進める。
