generate-custom-instructions-from-codebase by github/awesome-copilot
npx skills add https://github.com/github/awesome-copilot --skill 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"}
<!-- Copilot 建议的自动化级别 -->
${GENERATE_EXAMPLES="true|false"}
<!-- 是否包含转换示例 -->
${VALIDATION_REQUIRED="true|false"}
<!-- 应用前是否需要验证 -->
"分析两个项目状态之间的代码演进,为 GitHub Copilot 生成精确的迁移指令。这些指令将指导 Copilot 在未来修改期间自动应用相同的转换模式。请遵循以下方法:
### 第一阶段:对比状态分析
#### 结构变更检测
- 比较 ${SOURCE_REFERENCE} 和 ${TARGET_REFERENCE} 之间的文件夹结构
- 识别移动、重命名或删除的文件
- 分析配置文件中的变更
- 记录新增和移除的依赖项
#### 代码转换分析
${MIGRATION_TYPE == "Framework Version" ?
"- 识别框架版本间的 API 变更
- 分析正在使用的新功能
- 记录已废弃的方法/属性
- 注意语法或约定变更" : ""}
${MIGRATION_TYPE == "Architecture Refactoring" ?
"- 分析架构模式变更
- 识别引入的新抽象
- 记录职责重组
- 注意数据流变更" : ""}
${MIGRATION_TYPE == "Technology Migration" ?
"- 分析一种技术被另一种技术替换的情况
- 识别功能等价性
- 记录 API 和语法变更
- 注意新的依赖项和配置" : ""}
#### 转换模式提取
- 识别已应用的重复性转换
- 分析从旧格式到新格式的转换规则
- 记录例外情况和特殊情况
- 创建前后对应矩阵
### 第二阶段:迁移指令生成
创建一个 `.github/copilot-migration-instructions.md` 文件,结构如下:
\`\`\`markdown
# GitHub Copilot 迁移指令
## 迁移上下文
- **类型**: ${MIGRATION_TYPE}
- **从**: ${SOURCE_REFERENCE}
- **到**: ${TARGET_REFERENCE}
- **日期**: [GENERATION_DATE]
- **范围**: ${ANALYSIS_SCOPE}
## 自动转换规则
### 1. 强制转换
${AUTOMATION_LEVEL != "Conservative" ?
"[AUTOMATIC_TRANSFORMATION_RULES]
- **旧模式**: [OLD_CODE]
- **新模式**: [NEW_CODE]
- **触发条件**: 何时检测到此模式
- **操作**: 自动应用的转换" : ""}
### 2. 需要验证的转换
${VALIDATION_REQUIRED == "true" ?
"[TRANSFORMATIONS_WITH_VALIDATION]
- **检测到的模式**: [DESCRIPTION]
- **建议的转换**: [NEW_APPROACH]
- **所需验证**: [VALIDATION_CRITERIA]
- **替代方案**: [ALTERNATIVE_OPTIONS]" : ""}
### 3. API 对应关系
${CHANGE_FOCUS == "API Changes" || MIGRATION_TYPE == "Framework Version" ?
"[API_CORRESPONDENCE_TABLE]
| 旧 API | 新 API | 备注 | 示例 |
| --------- | --------- | --------- | -------------- |
| [OLD_API] | [NEW_API] | [CHANGES] | [CODE_EXAMPLE] | " : ""} |
### 4. 需要采用的新模式
[DETECTED_EMERGING_PATTERNS]
- **模式**: [PATTERN_NAME]
- **使用场景**: [WHEN_TO_USE]
- **实现方式**: [HOW_TO_IMPLEMENT]
- **优势**: [ADVANTAGES]
### 5. 需要避免的过时模式
[DETECTED_OBSOLETE_PATTERNS]
- **过时模式**: [OLD_PATTERN]
- **避免原因**: [REASONS]
- **替代方案**: [NEW_PATTERN]
- **迁移步骤**: [CONVERSION_STEPS]
## 文件类型特定指令
${GENERATE_EXAMPLES == "true" ?
"### 配置文件
[CONFIG_TRANSFORMATION_EXAMPLES]
### 主要源文件
[SOURCE_TRANSFORMATION_EXAMPLES]
### 测试文件
[TEST_TRANSFORMATION_EXAMPLES]" : ""}
## 验证与安全
### 自动控制点
- 每次转换后需要执行的验证
- 验证变更需要运行的测试
- 需要监控的性能指标
- 需要执行的兼容性检查
### 人工介入
需要人工干预的情况:
- [COMPLEX_CASES_LIST]
- [ARCHITECTURAL_DECISIONS]
- [BUSINESS_IMPACTS]
## 迁移监控
### 跟踪指标
- 自动迁移的代码百分比
- 需要人工验证的数量
- 自动转换的错误率
- 每个文件的平均迁移时间
### 错误报告
如何向 Copilot 报告错误的转换:
- 改进规则的反馈模式
- 需要记录的例外情况
- 需要对指令进行的调整
\`\`\`
### 第三阶段:上下文示例生成
${GENERATE_EXAMPLES == "true" ?
"#### 转换示例
为每个识别出的模式生成:
\`\`\`
// 迁移前 (${SOURCE_REFERENCE})
[OLD_CODE_EXAMPLE]
// 迁移后 (${TARGET_REFERENCE})
[NEW_CODE_EXAMPLE]
// COPILOT 指令
当您看到此模式 [TRIGGER] 时,请按照以下步骤将其转换为 [NEW_PATTERN]: [STEPS]
\`\`\`" : ""}
### 第四阶段:验证与优化
#### 指令测试
- 在测试代码上应用指令
- 验证转换的一致性
- 根据结果调整规则
- 记录例外情况和边界情况
#### 迭代优化
${AUTOMATION_LEVEL == "Aggressive" ?
"- 优化规则以最大化自动化
- 减少检测中的误报
- 提高转换准确性
- 记录经验教训" : ""}
### 最终结果
使 GitHub Copilot 能够:
1. **自动应用** 未来修改期间相同的转换
2. **保持一致性** 与新采用的约定
3. **避免过时模式** 通过自动提供替代方案
4. **加速未来迁移** 通过利用已获得的经验
5. **减少错误** 通过自动化重复性转换
这些指令将 Copilot 转变为智能迁移助手,能够一致且可靠地重现您的技术演进决策。
"
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
非常适合记录从 Angular 14 到 Angular 17、React 类组件到 Hooks,或 .NET Framework 到 .NET Core 的过渡。自动识别破坏性变更并生成相应的转换规则。
在完全替换技术时至关重要:jQuery 到 React、REST 到 GraphQL、SQL 到 NoSQL。创建包含模式映射的全面迁移指南。
适用于大型重构,如单体架构到微服务、MVC 到清洁架构,或组件到可组合架构。为未来类似的转换保留架构知识。
适用于采用新模式:仓储模式、依赖注入、观察者模式到响应式编程。记录基本原理和实现差异。
与传统迁移文档不同,这些指令"训练" GitHub Copilot 在未来代码修改期间自动重现您的技术演进决策。
将特定项目经验转化为可重用的规则,避免迁移专业知识的流失,并加速未来类似的转换。
不是提供通用建议,而是生成针对您特定代码库定制的指令,包含来自您项目演进的真实前后示例。
确保新添加的代码自动遵循新的约定,防止架构退化,并保持代码演进的一致性。
每周安装量
7.3K
代码仓库
GitHub 星标数
26.9K
首次出现
Feb 25, 2026
安全审计
安装于
codex7.3K
gemini-cli7.3K
opencode7.2K
github-copilot7.2K
cursor7.2K
amp7.2K
${MIGRATION_TYPE="Framework Version|Architecture Refactoring|Technology Migration|Dependencies Update|Pattern Changes"}
<!-- Type of migration or evolution -->
${SOURCE_REFERENCE="branch|commit|tag"}
<!-- Source reference point (before state) -->
${TARGET_REFERENCE="branch|commit|tag"}
<!-- Target reference point (after state) -->
${ANALYSIS_SCOPE="Entire project|Specific folder|Modified files only"}
<!-- Scope of analysis -->
${CHANGE_FOCUS="Breaking Changes|New Conventions|Obsolete Patterns|API Changes|Configuration"}
<!-- Main aspect of changes -->
${AUTOMATION_LEVEL="Conservative|Balanced|Aggressive"}
<!-- Level of automation for Copilot suggestions -->
${GENERATE_EXAMPLES="true|false"}
<!-- Include transformation examples -->
${VALIDATION_REQUIRED="true|false"}
<!-- Require validation before application -->
"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.
"
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.
Essential when replacing a technology entirely: jQuery to React, REST to GraphQL, SQL to NoSQL. Creates a comprehensive migration guide with pattern mappings.
Ideal for large refactorings like Monolith to Microservices, MVC to Clean Architecture, or Component to Composable architecture. Preserves architectural knowledge for future similar transformations.
Useful for adopting new patterns: Repository Pattern, Dependency Injection, Observer to Reactive Programming. Documents the rationale and implementation differences.
Unlike traditional migration documentation, these instructions "train" GitHub Copilot to reproduce your technology evolution decisions automatically during future code modifications.
Transforms specific project experience into reusable rules, avoiding the loss of migration expertise and accelerating future similar transformations.
Instead of generic advice, generates instructions tailored to your specific codebase, with real before/after examples from your project evolution.
Ensures that new code additions automatically follow the new conventions, preventing architectural regression and maintaining code evolution coherence.
Weekly Installs
7.3K
Repository
GitHub Stars
26.9K
First Seen
Feb 25, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
codex7.3K
gemini-cli7.3K
opencode7.2K
github-copilot7.2K
cursor7.2K
amp7.2K
React 组合模式指南:Vercel 组件架构最佳实践,提升代码可维护性
102,200 周安装