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