generate-custom-instructions-from-codebase
github/awesome-copilot
适用于 GitHub Copilot 的迁移和代码演进操作指南生成器。通过分析两个项目版本(分支、提交或发布版本)之间的差异,生成精准的操作指南,使 Copilot 能够在技术迁移、重大重构或框架版本升级过程中保持一致性。
...展开全部关于generate-custom-instructions-from-codebase
该技能通过分析项目两个版本(两个分支、提交或标签)之间的差异,为 GitHub Copilot 生成迁移和代码演化指令。 它解决了在技术迁移、重大重构或框架升级过程中保持一致性的问题:一旦捕获了“迁移前”和“迁移后”状态之间的转换模式,Copilot 便能在后续工作中自动应用相同的变更,而无需依赖开发者记住每条规则。
该技能由配置变量驱动(迁移类型、源和目标引用、分析范围、变更重点、自动化级别、是否生成示例以及是否需要验证)。 它定义了一种多阶段方法论:通过比较状态分析来检测结构变化、依赖关系变化以及针对迁移类型(框架版本、架构重构、技术迁移)量身定制的代码转换; 将重复的转换模式提取为“迁移前/迁移后”对应规则;以及生成 `.github/copilot-migration-instructions.md` 文件。 该输出文档记录了必选转换、需验证的转换、API 对应表、应采用的新模式、应避免的过时模式、特定文件类型的指导、验证和安全控制点、需人工干预的案例以及监控指标。可选阶段可添加具有上下文背景的转换前/后代码示例,并进行规则的迭代优化。
该工具面向开展系统化迁移的开发人员、架构师和团队,旨在让 Copilot 能够一致地重现其演进决策。 典型用例包括:升级框架版本、重构架构,或在保持规范一致并避免使用已弃用的模式的同时,用一种技术替换另一种技术。该技能会读取版本控制历史记录和项目文件,并生成一份操作指南文档;它会执行 Git 比较和文件分析,但不会执行任何破坏性操作或处理凭据,因此风险等级较低。
常见问题
该技能会生成什么?
一个名为 .github/copilot-migration-instructions.md 的文件,其中包含自动转换规则、API 对应表、应采用和应避免的模式、验证控制点以及监控指标,这些内容将指导 Copilot 进行未来的变更。
它需要哪些输入?
配置变量,包括迁移类型、源和目标引用(分支、提交或标签)、分析范围、变更重点、自动化级别,以及用于生成示例和要求验证的标志。
它支持哪些类型的迁移?
框架版本升级、架构重构、技术迁移、依赖项更新以及模式变更——分析内容将根据所选迁移类型进行定制。
自动化级别会影响输出结果吗?
是的。“保守”级别会省略强制性的自动转换规则,而“平衡”和“激进”级别则包含这些规则;“激进”级别还会添加迭代优化,以最大限度地提高自动化程度并减少误报。
它是如何识别转换规则的?
它会比较两个项目状态——文件夹结构、依赖关系和代码——提取重复的转换规则,并构建一个“转换前/后”对应矩阵,其中包含破坏性变更和过时模式。
Configuration Variables
${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 -->Generated Prompt
"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 GenerationCreate 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 EscalationSituations 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 ReportingHow 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 ResultMigration instructions that enable GitHub Copilot to:1. **Automatically apply** the same transformations during future modifications2. **Maintain consistency** with newly adopted conventions 3. **Avoid obsolete patterns** by automatically proposing alternatives4. **Accelerate future migrations** by capitalizing on acquired experience5. **Reduce errors** by automating repetitive transformationsThese instructions transform Copilot into an intelligent migration assistant, capable of reproducing your technology evolution decisions consistently and reliably."Typical Use Cases
Framework Version Migration
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.
Technology Stack Evolution
Essential when replacing a technology entirely: jQuery to React, REST to GraphQL, SQL to NoSQL. Creates a comprehensive migration guide with pattern mappings.
Architecture Refactoring
Ideal for large refactorings like Monolith to Microservices, MVC to Clean Architecture, or Component to Composable architecture. Preserves architectural knowledge for future similar transformations.
Design Pattern Modernization
Useful for adopting new patterns: Repository Pattern, Dependency Injection, Observer to Reactive Programming. Documents the rationale and implementation differences.
Unique Benefits
🧠 Artificial Intelligence Enhancement
Unlike traditional migration documentation, these instructions "train" GitHub Copilot to reproduce your technology evolution decisions automatically during future code modifications.
🔄 Knowledge Capitalization
Transforms specific project experience into reusable rules, avoiding the loss of migration expertise and accelerating future similar transformations.
🎯 Context-Aware Precision
Instead of generic advice, generates instructions tailored to your specific codebase, with real before/after examples from your project evolution.
⚡ Automated Consistency
Ensures that new code additions automatically follow the new conventions, preventing architectural regression and maintaining code evolution coherence.
所有文件
0 个文件安装 generate-custom-instructions-from-codebase
下载技能文件并将其解压到 .claude/skills/ 目录中。
下载ZIP克隆仓库并复制技能文件到您的项目中。
git clone https://github.com/github/awesome-copilot/blob/main/skills/generate-custom-instructions-from-codebase/SKILL.md # Copy SKILL.md to your .claude/skills/ directory
复制





首页
