|
| 1 | +--- |
| 2 | +description: 'Migration and code evolution instructions generator for GitHub Copilot. Analyzes differences between two project versions (branches, commits, or releases) to create precise instructions allowing Copilot to maintain consistency during technology migrations, major refactoring, or framework version upgrades.' |
| 3 | +--- |
| 4 | + |
| 5 | +# Migration and Code Evolution Instructions Generator |
| 6 | + |
| 7 | +## Configuration Variables |
| 8 | + |
| 9 | +``` |
| 10 | +${MIGRATION_TYPE="Framework Version|Architecture Refactoring|Technology Migration|Dependencies Update|Pattern Changes"} |
| 11 | +<!-- Type of migration or evolution --> |
| 12 | +
|
| 13 | +${SOURCE_REFERENCE="branch|commit|tag"} |
| 14 | +<!-- Source reference point (before state) --> |
| 15 | +
|
| 16 | +${TARGET_REFERENCE="branch|commit|tag"} |
| 17 | +<!-- Target reference point (after state) --> |
| 18 | +
|
| 19 | +${ANALYSIS_SCOPE="Entire project|Specific folder|Modified files only"} |
| 20 | +<!-- Scope of analysis --> |
| 21 | +
|
| 22 | +${CHANGE_FOCUS="Breaking Changes|New Conventions|Obsolete Patterns|API Changes|Configuration"} |
| 23 | +<!-- Main aspect of changes --> |
| 24 | +
|
| 25 | +${AUTOMATION_LEVEL="Conservative|Balanced|Aggressive"} |
| 26 | +<!-- Level of automation for Copilot suggestions --> |
| 27 | +
|
| 28 | +${GENERATE_EXAMPLES="true|false"} |
| 29 | +<!-- Include transformation examples --> |
| 30 | +
|
| 31 | +${VALIDATION_REQUIRED="true|false"} |
| 32 | +<!-- Require validation before application --> |
| 33 | +``` |
| 34 | + |
| 35 | +## Generated Prompt |
| 36 | + |
| 37 | +``` |
| 38 | +"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: |
| 39 | +
|
| 40 | +### Phase 1: Comparative State Analysis |
| 41 | +
|
| 42 | +#### Structural Changes Detection |
| 43 | +- Compare folder structure between ${SOURCE_REFERENCE} and ${TARGET_REFERENCE} |
| 44 | +- Identify moved, renamed, or deleted files |
| 45 | +- Analyze changes in configuration files |
| 46 | +- Document new dependencies and removed ones |
| 47 | +
|
| 48 | +#### Code Transformation Analysis |
| 49 | +${MIGRATION_TYPE == "Framework Version" ? |
| 50 | + "- Identify API changes between framework versions |
| 51 | + - Analyze new features being used |
| 52 | + - Document obsolete methods/properties |
| 53 | + - Note syntax or convention changes" : ""} |
| 54 | +
|
| 55 | +${MIGRATION_TYPE == "Architecture Refactoring" ? |
| 56 | + "- Analyze architectural pattern changes |
| 57 | + - Identify new abstractions introduced |
| 58 | + - Document responsibility reorganization |
| 59 | + - Note changes in data flows" : ""} |
| 60 | +
|
| 61 | +${MIGRATION_TYPE == "Technology Migration" ? |
| 62 | + "- Analyze replacement of one technology with another |
| 63 | + - Identify functional equivalences |
| 64 | + - Document API and syntax changes |
| 65 | + - Note new dependencies and configurations" : ""} |
| 66 | +
|
| 67 | +#### Transformation Pattern Extraction |
| 68 | +- Identify repetitive transformations applied |
| 69 | +- Analyze conversion rules from old to new format |
| 70 | +- Document exceptions and special cases |
| 71 | +- Create before/after correspondence matrix |
| 72 | +
|
| 73 | +### Phase 2: Migration Instructions Generation |
| 74 | +
|
| 75 | +Create a `.github/copilot-migration-instructions.md` file with this structure: |
| 76 | +
|
| 77 | +\`\`\`markdown |
| 78 | +# GitHub Copilot Migration Instructions |
| 79 | +
|
| 80 | +## Migration Context |
| 81 | +- **Type**: ${MIGRATION_TYPE} |
| 82 | +- **From**: ${SOURCE_REFERENCE} |
| 83 | +- **To**: ${TARGET_REFERENCE} |
| 84 | +- **Date**: [GENERATION_DATE] |
| 85 | +- **Scope**: ${ANALYSIS_SCOPE} |
| 86 | +
|
| 87 | +## Automatic Transformation Rules |
| 88 | +
|
| 89 | +### 1. Mandatory Transformations |
| 90 | +${AUTOMATION_LEVEL != "Conservative" ? |
| 91 | + "[AUTOMATIC_TRANSFORMATION_RULES] |
| 92 | + - **Old Pattern**: [OLD_CODE] |
| 93 | + - **New Pattern**: [NEW_CODE] |
| 94 | + - **Trigger**: When to detect this pattern |
| 95 | + - **Action**: Transformation to apply automatically" : ""} |
| 96 | +
|
| 97 | +### 2. Transformations with Validation |
| 98 | +${VALIDATION_REQUIRED == "true" ? |
| 99 | + "[TRANSFORMATIONS_WITH_VALIDATION] |
| 100 | + - **Detected Pattern**: [DESCRIPTION] |
| 101 | + - **Suggested Transformation**: [NEW_APPROACH] |
| 102 | + - **Required Validation**: [VALIDATION_CRITERIA] |
| 103 | + - **Alternatives**: [ALTERNATIVE_OPTIONS]" : ""} |
| 104 | +
|
| 105 | +### 3. API Correspondences |
| 106 | +${CHANGE_FOCUS == "API Changes" || MIGRATION_TYPE == "Framework Version" ? |
| 107 | + "[API_CORRESPONDENCE_TABLE] |
| 108 | + | Old API | New API | Notes | Example | |
| 109 | + | --------- | --------- | --------- | -------------- | |
| 110 | + | [OLD_API] | [NEW_API] | [CHANGES] | [CODE_EXAMPLE] | " : ""} | |
| 111 | +
|
| 112 | +### 4. New Patterns to Adopt |
| 113 | +[DETECTED_EMERGING_PATTERNS] |
| 114 | +- **Pattern**: [PATTERN_NAME] |
| 115 | +- **Usage**: [WHEN_TO_USE] |
| 116 | +- **Implementation**: [HOW_TO_IMPLEMENT] |
| 117 | +- **Benefits**: [ADVANTAGES] |
| 118 | +
|
| 119 | +### 5. Obsolete Patterns to Avoid |
| 120 | +[DETECTED_OBSOLETE_PATTERNS] |
| 121 | +- **Obsolete Pattern**: [OLD_PATTERN] |
| 122 | +- **Why Avoid**: [REASONS] |
| 123 | +- **Alternative**: [NEW_PATTERN] |
| 124 | +- **Migration**: [CONVERSION_STEPS] |
| 125 | +
|
| 126 | +## File Type Specific Instructions |
| 127 | +
|
| 128 | +${GENERATE_EXAMPLES == "true" ? |
| 129 | + "### Configuration Files |
| 130 | + [CONFIG_TRANSFORMATION_EXAMPLES] |
| 131 | + |
| 132 | + ### Main Source Files |
| 133 | + [SOURCE_TRANSFORMATION_EXAMPLES] |
| 134 | + |
| 135 | + ### Test Files |
| 136 | + [TEST_TRANSFORMATION_EXAMPLES]" : ""} |
| 137 | +
|
| 138 | +## Validation and Security |
| 139 | +
|
| 140 | +### Automatic Control Points |
| 141 | +- Verifications to perform after each transformation |
| 142 | +- Tests to run to validate changes |
| 143 | +- Performance metrics to monitor |
| 144 | +- Compatibility checks to perform |
| 145 | +
|
| 146 | +### Manual Escalation |
| 147 | +Situations requiring human intervention: |
| 148 | +- [COMPLEX_CASES_LIST] |
| 149 | +- [ARCHITECTURAL_DECISIONS] |
| 150 | +- [BUSINESS_IMPACTS] |
| 151 | +
|
| 152 | +## Migration Monitoring |
| 153 | +
|
| 154 | +### Tracking Metrics |
| 155 | +- Percentage of code automatically migrated |
| 156 | +- Number of manual validations required |
| 157 | +- Error rate of automatic transformations |
| 158 | +- Average migration time per file |
| 159 | +
|
| 160 | +### Error Reporting |
| 161 | +How to report incorrect transformations to Copilot: |
| 162 | +- Feedback patterns to improve rules |
| 163 | +- Exceptions to document |
| 164 | +- Adjustments to make to instructions |
| 165 | +
|
| 166 | +\`\`\` |
| 167 | +
|
| 168 | +### Phase 3: Contextual Examples Generation |
| 169 | +
|
| 170 | +${GENERATE_EXAMPLES == "true" ? |
| 171 | + "#### Transformation Examples |
| 172 | + For each identified pattern, generate: |
| 173 | + |
| 174 | + \`\`\` |
| 175 | + // BEFORE (${SOURCE_REFERENCE}) |
| 176 | + [OLD_CODE_EXAMPLE] |
| 177 | + |
| 178 | + // AFTER (${TARGET_REFERENCE}) |
| 179 | + [NEW_CODE_EXAMPLE] |
| 180 | + |
| 181 | + // COPILOT INSTRUCTIONS |
| 182 | + When you see this pattern [TRIGGER], transform it to [NEW_PATTERN] following these steps: [STEPS] |
| 183 | + \`\`\`" : ""} |
| 184 | +
|
| 185 | +### Phase 4: Validation and Optimization |
| 186 | +
|
| 187 | +#### Instructions Testing |
| 188 | +- Apply instructions on test code |
| 189 | +- Verify transformation consistency |
| 190 | +- Adjust rules based on results |
| 191 | +- Document exceptions and edge cases |
| 192 | +
|
| 193 | +#### Iterative Optimization |
| 194 | +${AUTOMATION_LEVEL == "Aggressive" ? |
| 195 | + "- Refine rules to maximize automation |
| 196 | + - Reduce false positives in detection |
| 197 | + - Improve transformation accuracy |
| 198 | + - Document lessons learned" : ""} |
| 199 | +
|
| 200 | +### Final Result |
| 201 | +
|
| 202 | +Migration instructions that enable GitHub Copilot to: |
| 203 | +1. **Automatically apply** the same transformations during future modifications |
| 204 | +2. **Maintain consistency** with newly adopted conventions |
| 205 | +3. **Avoid obsolete patterns** by automatically proposing alternatives |
| 206 | +4. **Accelerate future migrations** by capitalizing on acquired experience |
| 207 | +5. **Reduce errors** by automating repetitive transformations |
| 208 | +
|
| 209 | +These instructions transform Copilot into an intelligent migration assistant, capable of reproducing your technology evolution decisions consistently and reliably. |
| 210 | +" |
| 211 | +``` |
| 212 | + |
| 213 | +## Typical Use Cases |
| 214 | + |
| 215 | +### Framework Version Migration |
| 216 | +Perfect for documenting the transition from Angular 14 to Angular 17, React Class Components to Hooks, or .NET Framework to .NET Core. Automatically identifies breaking changes and generates corresponding transformation rules. |
| 217 | + |
| 218 | +### Technology Stack Evolution |
| 219 | +Essential when replacing a technology entirely: jQuery to React, REST to GraphQL, SQL to NoSQL. Creates a comprehensive migration guide with pattern mappings. |
| 220 | + |
| 221 | +### Architecture Refactoring |
| 222 | +Ideal for large refactorings like Monolith to Microservices, MVC to Clean Architecture, or Component to Composable architecture. Preserves architectural knowledge for future similar transformations. |
| 223 | + |
| 224 | +### Design Pattern Modernization |
| 225 | +Useful for adopting new patterns: Repository Pattern, Dependency Injection, Observer to Reactive Programming. Documents the rationale and implementation differences. |
| 226 | + |
| 227 | +## Unique Benefits |
| 228 | + |
| 229 | +### 🧠 **Artificial Intelligence Enhancement** |
| 230 | +Unlike traditional migration documentation, these instructions "train" GitHub Copilot to reproduce your technology evolution decisions automatically during future code modifications. |
| 231 | + |
| 232 | +### 🔄 **Knowledge Capitalization** |
| 233 | +Transforms specific project experience into reusable rules, avoiding the loss of migration expertise and accelerating future similar transformations. |
| 234 | + |
| 235 | +### 🎯 **Context-Aware Precision** |
| 236 | +Instead of generic advice, generates instructions tailored to your specific codebase, with real before/after examples from your project evolution. |
| 237 | + |
| 238 | +### ⚡ **Automated Consistency** |
| 239 | +Ensures that new code additions automatically follow the new conventions, preventing architectural regression and maintaining code evolution coherence. |
0 commit comments