選項
首頁首頁 Skill Git 和版本控制 generate-custom-instructions-from-codebase

generate-custom-instructions-from-codebase

github/awesome-copilot github/awesome-copilot

適用於 GitHub Copilot 的遷移與程式碼演進指示生成器。透過分析兩個專案版本(分支、提交或發行版)之間的差異,生成精確的指示,使 Copilot 能在技術遷移、重大重構或框架版本升級過程中維持一致性。

...展開全部
13
更新時間 2026-08-26

關於generate-custom-instructions-from-codebase

此技能透過分析專案的兩個版本(兩個分支、提交或標籤)之間的差異,為 GitHub Copilot 生成遷移與程式碼演進的指示。 它解決了在技術遷移、重大重構或框架升級過程中維持一致性的問題:一旦擷取了「遷移前」與「遷移後」狀態之間的轉換模式,Copilot 便能在後續工作中自動套用相同的變更,而非仰賴開發人員記憶每項規則。

此技能由配置變數驅動(遷移類型、來源與目標參照、分析範圍、變更重點、自動化層級、是否產生範例,以及是否需要驗證)。 它定義了一種多階段方法論:透過狀態比較分析來偵測結構變更、依賴關係變更,並根據遷移類型(框架版本、架構重構、技術遷移)進行量身訂製的程式碼轉換; 將重複的轉換模式提取為「遷移前後對應規則」;以及生成 `.github/copilot-migration-instructions.md` 檔案。 該輸出文件記錄了必做的轉換、需驗證的轉換、API 對應表、應採用的新模式、應避免的過時模式、特定檔案類型的指引、驗證與安全性控制點、需人工介入的案例,以及監控指標。可選階段則會加入具情境背景的轉換前後程式碼範例,並進行規則的迭代優化。

此工具針對進行系統性遷移的開發人員、架構師及團隊,協助 Copilot 一致地重現其演進決策。 應用場景包括升級框架版本、重構架構,或以另一項技術取代原有技術,同時保持規範的一致性並避免使用已棄用的模式。此技能會讀取版本控制歷史紀錄與專案檔案,並產生一份操作說明文件;它會執行 Git 比較與檔案分析,但不會進行任何破壞性操作或處理憑證,因此風險評級較低。

常見問題

此技能會產生什麼?

一個名為 .github/copilot-migration-instructions.md 的檔案,其中包含自動轉換規則、API 對應表、應採用與應避免的模式、驗證控制點,以及用於引導 Copilot 進行未來變更的監控指標。

它需要哪些輸入?

配置變數,包括遷移類型、來源與目標參照(分支、提交或標籤)、分析範圍、變更重點、自動化層級,以及用於產生範例和要求驗證的標誌。

它能處理哪些類型的遷移?

框架版本升級、架構重構、技術遷移、依賴項更新以及模式變更——分析內容會根據所選的遷移類型進行客製化。

自動化層級會影響輸出結果嗎?

會。若設定為「保守」等級,將省略強制性的自動轉換規則;而「平衡」與「進取」等級則會包含這些規則;此外,「進取」等級還會加入迭代優化機制,以最大化自動化程度並減少誤報。

它是如何識別轉換規則的?

它會比較兩個專案狀態(包括資料夾結構、依賴項和程式碼),擷取重複的轉換規則,並建立「轉換前後」對應矩陣,其中包含破壞性變更與過時模式。

在 GitHub 上查看

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

複製 複製
快速設定: 將技能資料夾複製到 .claude/skills/,Claude 會自動偵測並使用該技能

相關技能

github-project-management
更新時間 2026-06-29
using-git-worktrees
更新時間 2026-06-29
readme-blueprint-generator
更新時間 2026-07-05
finishing-a-development-branch
更新時間 2026-06-29
OR