Generate custom instructions from codebase
Extract deterministic before/after rules from real repository history and write a scoped .instructions.md file.
When to invoke
- Preserve conventions established by an upgrade or refactor.
- Generate API correspondence guidance from a migration diff.
- Prevent reintroduction of obsolete patterns.
- Encode repeatable dependency or configuration transformations.
Inputs
Parse $ARGUMENTS and require MIGRATION_TYPE, SOURCE_REFERENCE, and TARGET_REFERENCE.
| Input |
Allowed values or purpose |
MIGRATION_TYPE |
Framework Version, Architecture Refactoring, Technology Migration, Dependencies Update, Pattern Changes |
SOURCE_REFERENCE |
Before branch, commit, tag, or release |
TARGET_REFERENCE |
After branch, commit, tag, or release |
ANALYSIS_SCOPE |
Entire project, specific folder, or modified files only |
CHANGE_FOCUS |
Breaking changes, conventions, obsolete patterns, APIs, configuration |
AUTOMATION_LEVEL |
Conservative, Balanced, or Aggressive |
GENERATE_EXAMPLES |
true or false |
VALIDATION_REQUIRED |
true or false |
Procedure
- Resolve source and target references to immutable commits and record them.
- Compare structure, moved/deleted files, configuration, dependencies, source, and tests in scope.
- Group repeated transformations by migration type and focus.
- Create an automatic rule only when the old pattern has a reliable trigger and the replacement is deterministic.
- Put ambiguous transformations under validation with concrete tests or compatibility checks.
- Build API correspondences from actual old/new symbols and examples.
- Escalate complex cases, architecture decisions, security changes, and business impact for human review.
- Write
.github/instructions/<migration-slug>.instructions.md with a narrow applyTo glob.
- Test the instructions against representative source and target examples.
Transformation shape:
BEFORE (<SOURCE_REFERENCE>)
<old code from repository>
AFTER (<TARGET_REFERENCE>)
<new code from repository>
RULE
When <reliable trigger> appears under <applyTo>, use <new pattern> and run <validation>.
Output template
## Copilot migration instructions result
**Status:** GENERATED | VALIDATION-REQUIRED | BLOCKED
**References:** <source SHA> -> <target SHA>
**Output:** `.github/instructions/<slug>.instructions.md`
| Rule | Evidence | Automation | Validation |
| --- | --- | --- | --- |
### Escalations
- <complex case, architecture decision, security/business impact, or none>
Limits
- Do not generate rules from generic migration advice or memory.
- Do not automate a transformation without a reliable trigger and deterministic replacement.
- Do not hide exceptions or force architecture/business decisions into mechanical rules.
- Do not write the unsupported
.github/copilot-migration-instructions.md path.
Related primitives
| Name |
Type |
Use it when |
brownfield-engineering |
skill |
The migration rules guide implementation in existing code. |
context-map |
skill |
The changed surface and dependencies need mapping first. |
validation-scripts |
skill |
Generated instructions need repository-level validation. |
Quality gate
1---2name: github-copilot-generate-custom-instructions3description: Generates path-scoped GitHub Copilot migration instructions from actual branch, commit, tag, or release diffs. Use when handling framework upgrades, architecture refactors, technology migrations, dependency updates, API changes, and obsolete-pattern prevention.4---56<!-- Generated from harness/github-copilot/plugins/open-horizons-platform/skills/github-copilot-generate-custom-instructions/SKILL.md by harness/claude-code/scripts/convert_from_copilot.py. Edit the source, not this file. -->78# Generate custom instructions from codebase910Extract deterministic before/after rules from real repository history and write a scoped `.instructions.md` file.1112## When to invoke1314- Preserve conventions established by an upgrade or refactor.15- Generate API correspondence guidance from a migration diff.16- Prevent reintroduction of obsolete patterns.17- Encode repeatable dependency or configuration transformations.1819## Inputs2021Parse `$ARGUMENTS` and require `MIGRATION_TYPE`, `SOURCE_REFERENCE`, and `TARGET_REFERENCE`.2223| Input | Allowed values or purpose |24| --- | --- |25| `MIGRATION_TYPE` | Framework Version, Architecture Refactoring, Technology Migration, Dependencies Update, Pattern Changes |26| `SOURCE_REFERENCE` | Before branch, commit, tag, or release |27| `TARGET_REFERENCE` | After branch, commit, tag, or release |28| `ANALYSIS_SCOPE` | Entire project, specific folder, or modified files only |29| `CHANGE_FOCUS` | Breaking changes, conventions, obsolete patterns, APIs, configuration |30| `AUTOMATION_LEVEL` | Conservative, Balanced, or Aggressive |31| `GENERATE_EXAMPLES` | true or false |32| `VALIDATION_REQUIRED` | true or false |3334## Procedure35361. Resolve source and target references to immutable commits and record them.372. Compare structure, moved/deleted files, configuration, dependencies, source, and tests in scope.383. Group repeated transformations by migration type and focus.394. Create an automatic rule only when the old pattern has a reliable trigger and the replacement is deterministic.405. Put ambiguous transformations under validation with concrete tests or compatibility checks.416. Build API correspondences from actual old/new symbols and examples.427. Escalate complex cases, architecture decisions, security changes, and business impact for human review.438. Write `.github/instructions/<migration-slug>.instructions.md` with a narrow `applyTo` glob.449. Test the instructions against representative source and target examples.4546Transformation shape:4748```text49BEFORE (<SOURCE_REFERENCE>)50<old code from repository>5152AFTER (<TARGET_REFERENCE>)53<new code from repository>5455RULE56When <reliable trigger> appears under <applyTo>, use <new pattern> and run <validation>.57```5859## Output template6061```markdown62## Copilot migration instructions result6364**Status:** GENERATED | VALIDATION-REQUIRED | BLOCKED65**References:** <source SHA> -> <target SHA>66**Output:** `.github/instructions/<slug>.instructions.md`6768| Rule | Evidence | Automation | Validation |69| --- | --- | --- | --- |7071### Escalations72- <complex case, architecture decision, security/business impact, or none>73```7475## Limits7677- Do not generate rules from generic migration advice or memory.78- Do not automate a transformation without a reliable trigger and deterministic replacement.79- Do not hide exceptions or force architecture/business decisions into mechanical rules.80- Do not write the unsupported `.github/copilot-migration-instructions.md` path.8182## Related primitives8384| Name | Type | Use it when |85| --- | --- | --- |86| `brownfield-engineering` | `skill` | The migration rules guide implementation in existing code. |87| `context-map` | `skill` | The changed surface and dependencies need mapping first. |88| `validation-scripts` | `skill` | Generated instructions need repository-level validation. |8990## Quality gate9192- [ ] Source and target resolve to immutable commits.93- [ ] Every rule cites actual before/after evidence.94- [ ] Automatic replacements are deterministic and scoped.95- [ ] Validation-required changes name concrete checks.96- [ ] Architecture, security, and business-impact decisions are escalated.97- [ ] The generated instruction has a narrow `applyTo` and passes primitive validation.