|
| 1 | +# PSModule Instruction Architecture |
| 2 | + |
| 3 | +This document describes the Copilot instruction system used across PSModule repositories to provide consistent guidance to AI coding agents. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +The PSModule ecosystem uses a structured instruction system that guides AI agents in making consistent changes across multiple repositories while allowing for project-specific customization. |
| 8 | + |
| 9 | +## Architecture |
| 10 | + |
| 11 | +### Two-Tier Hierarchy |
| 12 | + |
| 13 | +The instruction system follows a two-tier hierarchy: |
| 14 | + |
| 15 | +``` |
| 16 | +.github/instructions/ |
| 17 | +├── framework/ # Generic, reusable patterns (automation-managed) |
| 18 | +│ ├── main.instructions.md # Universal cross-language guidelines |
| 19 | +│ └── {Language}/ # Language-specific framework patterns |
| 20 | +│ ├── main.instructions.md |
| 21 | +│ ├── tests.instructions.md |
| 22 | +│ └── classes.instructions.md |
| 23 | +└── repo/ # Project-specific patterns (manually curated) |
| 24 | + ├── main.instructions.md # Repository context and rules |
| 25 | + └── {Language}/ # Project-specific language patterns |
| 26 | + └── main.instructions.md |
| 27 | +``` |
| 28 | + |
| 29 | +### Content Hierarchy and Precedence |
| 30 | + |
| 31 | +Instructions are applied in precedence order, with more specific rules taking precedence: |
| 32 | + |
| 33 | +1. **Framework instructions** provide foundation and universal patterns |
| 34 | +2. **Repository instructions** override and extend framework instructions |
| 35 | +3. **Language-specific instructions** inherit from their main instruction files |
| 36 | +4. **Repository language instructions** take precedence over framework language instructions |
| 37 | + |
| 38 | +## Usage |
| 39 | + |
| 40 | +### For AI Agents |
| 41 | + |
| 42 | +When editing files, agents should: |
| 43 | + |
| 44 | +1. Locate the file you intend to edit and note its extension and repository segment (code, docs, workflows, etc.) |
| 45 | +2. Load all matching framework instructions under `/.github/instructions/framework/`, then load the corresponding repository overrides under `/.github/instructions/repo/` |
| 46 | +3. Respect the precedence order: framework → framework language → repository → repository language, applying the most specific rule last |
| 47 | +4. If gaps appear, record them as enhancements and avoid unverified assumptions |
| 48 | +5. After completing work, confirm that updates continue to fit the documented architecture and that any new patterns are captured in the appropriate instruction file |
| 49 | + |
| 50 | +### For Contributors |
| 51 | + |
| 52 | +- Always consult both framework and repo instructions before editing |
| 53 | +- Follow the `applyTo` glob when determining relevancy; do not assume coverage |
| 54 | +- Document new patterns promptly so they can be promoted to framework guidance when reusable |
| 55 | + |
| 56 | +## File Format |
| 57 | + |
| 58 | +All instruction files must follow this format: |
| 59 | + |
| 60 | +```yaml |
| 61 | +--- |
| 62 | +applyTo: "<glob pattern targeting specific file types>" |
| 63 | +description: "Brief, actionable description of the instruction's purpose" |
| 64 | +--- |
| 65 | +``` |
| 66 | + |
| 67 | +Content structure: Context lead, Goal, Execution steps, Behavior rules, Output format, Error handling, Definitions |
| 68 | + |
| 69 | +## Key Principles |
| 70 | + |
| 71 | +- Honor convention over configuration, context awareness, pipeline friendliness, and cross-platform compatibility |
| 72 | +- Maintain strong typing, clear documentation, robust authentication abstractions, and enterprise GitHub support throughout the ecosystem |
| 73 | +- Expect tight coupling with GitHub Actions, PSModule authentication helpers, structured logging (`LogGroup`), and cross-repo dependencies |
| 74 | +- Validate changes against both local tooling and CI automation |
| 75 | + |
| 76 | +## Definitions |
| 77 | + |
| 78 | +| Term | Description | |
| 79 | +| --- | --- | |
| 80 | +| **Framework instructions** | Canonical, reusable rules under `/.github/instructions/framework/` that apply across PSModule repositories | |
| 81 | +| **Repository instructions** | Overrides located under `/.github/instructions/repo/` describing project-specific expectations | |
| 82 | +| **Precedence order** | Evaluation order where the most specific applicable instruction file governs the final decision | |
0 commit comments