💡

Claude CodeとCopilot Custom Instructions併用するためのCustom Commands

に公開

Claude CodeとCopilot Custom Instructionsの併用をするため、Custom Commandsを作成した備忘録Quick Tipsです。

.claude/

参考ですが、以下の構成にしています。

.claude/README.md
/.claude/
├── CLAUDE.md                        # Claude Codeのmeta data
├── commands/                        # Custom commands: 後述
├── knowledge/                       # Project knowledge
└── temporary/                       # Claude output temporary
.gitignore
.claude/temporary/

Commands

/sync-instructions-workflow Command

チームではGitHub Copilotも併用しており、先に custom instructionsを利用していました。

そのため、CLAUDE.mdの内容と.github/instructions/の内容を同期するためのコマンドを作成しています。

全文を展開してもよいのですが、それよりも生成するPromptを共有したほうが活用できるかと思いますので、ご参考程度にどうぞ。

create_sync_command.md
.github/instructions/ ファイルとCLAUDE.mdを同期するClaude Code用カスタムコマンドを作成してください。

  **コマンド要件:**
  1. **名前**: `/sync-instructions-workflow`
  2. **配置場所**: `.claude/commands/sync-instructions-workflow.md`
  3. **機能**: GitHub Copilotのカスタム指示とCLAUDE.mdの内容を自動同期

  **コマンドが実行すべき処理:**
  - `.github/instructions/` ディレクトリを動的にスキャンし、全ての `.md`
  ファイルを検出
  - ファイルが見つからない場合は、ユーザーに対象ファイルパスを質問
  - 現在のCLAUDE.mdの内容と比較
  - 重複・競合する情報を特定
  - 重複を避けながらコンテンツをマージ
  - 役割分担の維持:
    - CLAUDE.md: Claude固有の詳細ガイダンス
    - .github/instructions/: チーム全体の開発標準
  - 変更前のバックアップ作成
  - `.claude/temporary/` に同期レポート生成

  **動的ファイル検出:**
  - `Glob` ツールで `.github/instructions/*.md` パターンを検索
  - 見つからない場合: "同期対象の指示ファイルパスを指定してください(例:
  .github/copilot-instructions.md)"
  - 複数見つかった場合:
  検出されたファイル一覧を表示し、除外するファイルがあるか確認

  **出力:**
  - 相互参照を含む更新されたCLAUDE.md
  - 必要に応じてCLAUDE.md参照を含む更新された.github/instructions
  - 競合・マージ内容を記録した同期レポート
  - `.claude/temporary/backup/` にバックアップファイル

参考になれば幸いです。


https://docs.anthropic.com/ja/docs/claude-code/settings
https://docs.anthropic.com/ja/docs/claude-code/slash-commands
https://docs.anthropic.com/ja/docs/claude-code/memory

株式会社フライヤー Tech Blog

Discussion