mcpField
G
generate-custom-instructions-from-codebase

generate-custom-instructions-from-codebase

github.com/githubエージェントワークフロー40.5k8.9k 回インストール1 日前に更新
リポジトリ

generate-custom-instructions-from-codebase について

コードベースの2つの状態を比較し、移行やリファクタリングのパターンをGitHub Copilot向けの指示にまとめるスキルです。プロジェクト固有の変更を今後のコード修正にも反映したいチーム向けです。

主な機能

  1. 01移行元と移行先の状態比較
  2. 02構造や設定の変更検出
  3. 03コードベースに合わせた移行指示の生成
  4. 04Copilot向け変換パターンの記録

活用シーン

  1. 01フレームワークのバージョン移行の記録
  2. 02技術置き換え時のパターン整理
  3. 03アーキテクチャのリファクタリング判断の記録
  4. 04新しいデザインパターンの導入支援

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/github/awesome-copilot --skill generate-custom-instructions-from-codebase

インストール後、Claude Code で/generate-custom-instructions-from-codebaseを入力して読み込まれたか確認します。

詳細

移行およびコード進化の指示ジェネレーター

設定変数

${MIGRATION_TYPE="Framework Version|Architecture Refactoring|Technology Migration|Dependencies Update|Pattern Changes"}


${SOURCE_REFERENCE="branch|commit|tag"}


${TARGET_REFERENCE="branch|commit|tag"}  


${ANALYSIS_SCOPE="Entire project|Specific folder|Modified files only"}


${CHANGE_FOCUS="Breaking Changes|New Conventions|Obsolete Patterns|API Changes|Configuration"}


${AUTOMATION_LEVEL="Conservative|Balanced|Aggressive"}


${GENERATE_EXAMPLES="true|false"}


${VALIDATION_REQUIRED="true|false"}

生成されるプロンプト

"Analyze code evolution between two project states to generate precise migration instructions for GitHub Copilot. These instructions will guide Copilot to automatically apply the same transformation patterns during future modifications. Follow this methodology:

### Phase 1: Comparative State Analysis

#### Structural Changes Detection
- Compare folder structure between ${SOURCE_REFERENCE} and ${TARGET_REFERENCE}
- Identify moved, renamed, or deleted files
- Analyze changes in configuration files
- Document new dependencies and removed ones

#### Code Transformation Analysis
${MIGRATION_TYPE == "Framework Version" ? 
  "- Identify API changes between framework versions
   - Analyze new features being used
   - Document obsolete methods/properties
   - Note syntax or convention changes" : ""}

${MIGRATION_TYPE == "Architecture Refactoring" ? 
  "- Analyze architectural pattern changes
   - Identify new abstractions introduced
   - Document responsibility reorganization
   - Note changes in data flows" : ""}

${MIGRATION_TYPE == "Technology Migration" ? 
  "- Analyze replacement of one technology with another
   - Identify functional equivalences
   - Document API and syntax changes
   - Note new dependencies and configurations" : ""}

#### Transformation Pattern Extraction
- Identify repetitive transformations applied
- Analyze conversion rules from old to new format
- Document exceptions and special cases
- Create before/after correspondence matrix

### Phase 2: Migration Instructions Generation

Create a `.github/copilot-migration-instructions.md` file with this structure:

\`\`\`markdown
# GitHub Copilot Migration Instructions

## Migration Context
- **Type**: ${MIGRATION_TYPE}
- **From**: ${SOURCE_REFERENCE} 
- **To**: ${TARGET_REFERENCE}
- **Date**: [GENERATION_DATE]
- **Scope**: ${ANALYSIS_SCOPE}

## Automatic Transformation Rules

### 1. Mandatory Transformations
${AUTOMATION_LEVEL != "Conservative" ? 
  "[AUTOMATIC_TRANSFORMATION_RULES]
   - **Old Pattern**: [OLD_CODE]
   - **New Pattern**: [NEW_CODE]
   - **Trigger**: When to detect this pattern
   - **Action**: Transformation to apply automatically" : ""}

### 2. Transformations with Validation
${VALIDATION_REQUIRED == "true" ? 
  "[TRANSFORMATIONS_WITH_VALIDATION]
   - **Detected Pattern**: [DESCRIPTION]
   - **Suggested Transformation**: [NEW_APPROACH]
   - **Required Validation**: [VALIDATION_CRITERIA]
   - **Alternatives**: [ALTERNATIVE_OPTIONS]" : ""}

### 3. API Correspondences
${CHANGE_FOCUS == "API Changes" || MIGRATION_TYPE == "Framework Version" ? 
  "[API_CORRESPONDENCE_TABLE]
   | Old API   | New API   | Notes     | Example        |
   | --------- | --------- | --------- | -------------- |
   | [OLD_API] | [NEW_API] | [CHANGES] | [CODE_EXAMPLE] | " : ""} |

### 4. New Patterns to Adopt
[DETECTED_EMERGING_PATTERNS]
- **Pattern**: [PATTERN_NAME]
- **Usage**: [WHEN_TO_USE] 
- **Implementation**: [HOW_TO_IMPLEMENT]
- **Benefits**: [ADVANTAGES]

### 5. Obsolete Patterns to Avoid
[DETECTED_OBSOLETE_PATTERNS]
- **Obsolete Pattern**: [OLD_PATTERN]
- **Why Avoid**: [REASONS]
- **Alternative**: [NEW_PATTERN]
- **Migration**: [CONVERSION_STEPS]

## File Type Specific Instructions

${GENERATE_EXAMPLES == "true" ? 
  "### Configuration Files
   [CONFIG_TRANSFORMATION_EXAMPLES]
   
   ### Main Source Files
   [SOURCE_TRANSFORMATION_EXAMPLES]
   
   ### Test Files
   [TEST_TRANSFORMATION_EXAMPLES]" : ""}

## Validation and Security

### Automatic Control Points
- Verifications to perform after each transformation
- Tests to run to validate changes
- Performance metrics to monitor
- Compatibility checks to perform

### Manual Escalation
Situations requiring human intervention:
- [COMPLEX_CASES_LIST]
- [ARCHITECTURAL_DECISIONS]
- [BUSINESS_IMPACTS]

## Migration Monitoring

### Tracking Metrics
- Percentage of code automatically migrated
- Number of manual validations required
- Error rate of automatic transformations
- Average migration time per file

### Error Reporting
How to report incorrect transformations to Copilot:
- Feedback patterns to improve rules
- Exceptions to document
- Adjustments to make to instructions

\`\`\`

### Phase 3: Contextual Examples Generation

${GENERATE_EXAMPLES == "true" ? 
  "#### Transformation Examples
   For each identified pattern, generate:
   
   \`\`\`
   // BEFORE (${SOURCE_REFERENCE})
   [OLD_CODE_EXAMPLE]
   
   // AFTER (${TARGET_REFERENCE}) 
   [NEW_CODE_EXAMPLE]
   
   // COPILOT INSTRUCTIONS
   When you see this pattern [TRIGGER], transform it to [NEW_PATTERN] following these steps: [STEPS]
   \`\`\`" : ""}

### Phase 4: Validation and Optimization

#### Instructions Testing
- Apply instructions on test code
- Verify transformation consistency
- Adjust rules based on results
- Document exceptions and edge cases

#### Iterative Optimization  
${AUTOMATION_LEVEL == "Aggressive" ? 
  "- Refine rules to maximize automation
   - Reduce false positives in detection
   - Improve transformation accuracy
   - Document lessons learned" : ""}

### Final Result

Migration instructions that enable GitHub Copilot to:
1. **Automatically apply** the same transformations during future modifications
2. **Maintain consistency** with newly adopted conventions  
3. **Avoid obsolete patterns** by automatically proposing alternatives
4. **Accelerate future migrations** by capitalizing on acquired experience
5. **Reduce errors** by automating repetitive transformations

These instructions transform Copilot into an intelligent migration assistant, capable of reproducing your technology evolution decisions consistently and reliably.
"

典型的なユースケース

フレームワークのバージョン移行

Angular 14 から Angular 17 への移行、React のクラスコンポーネントから Hooks への移行、.NET Framework から .NET Core への移行を文書化するのに最適です。破壊的変更を自動的に特定し、対応する変換ルールを生成します。

技術スタックの進化

技術を全面的に置き換える場合に不可欠です。jQuery から React、REST から GraphQL、SQL から NoSQL などが該当します。パターンマッピングを含む包括的な移行ガイドを作成します。

アーキテクチャのリファクタリング

モノリスからマイクロサービス、MVC からクリーンアーキテクチャ、コンポーネントからコンポーザブルアーキテクチャなど、大規模なリファクタリングに最適です。将来の同様の変換のためにアーキテクチャの知識を保持します。

デザインパターンのモダナイゼーション

新しいパターンの採用に役立ちます。リポジトリパターン、依存性注入、Observer からリアクティブプログラミングなどが該当します。その根拠と実装の違いを文書化します。

独自のメリット

🧠 人工知能による強化

従来の移行ドキュメントとは異なり、これらの指示は GitHub Copilot を「トレーニング」し、将来のコード変更時にあなたの技術進化の意思決定を自動的に再現させます。

🔄 知識の資本化

特定のプロジェクトの経験を再利用可能なルールに変換し、移行に関する専門知識の喪失を防ぎ、将来の同様の変換を加速します。

🎯 コンテキストを考慮した精度

一般的なアドバイスではなく、あなたの特定のコードベースに合わせた指示を生成し、プロジェクトの進化における実際の before/after の例を含めます。

⚡ 自動化された一貫性

新しいコードの追加が自動的に新しい規約に従うことを保証し、アーキテクチャの退行を防ぎ、コード進化の一貫性を維持します。

コメント