Skip to content

Commit cc6a29c

Browse files
chore(docs): overhaul Instruction Architecture document for GitHub Copilot file management and synchronization
1 parent 493cb30 commit cc6a29c

1 file changed

Lines changed: 200 additions & 46 deletions

File tree

Lines changed: 200 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,194 @@
1-
# PSModule Instruction Architecture
1+
# GitHub Copilot File Manageme### Automation and Synchronization
22

3-
This document describes the Copilot instruction system used across PSModule repositories to provide consistent guidance to AI coding agents.
3+
All organization-tier Copilot files can be automatically synchron1. **Organization main instructions** (`instructions/organization/main.instructions.md`) - Organization-wide framework patterns
4+
2. **Organization language instructions** (`instructions/organization/{Language}/main.instructions.md`) - Organization-wide language-specific patterns
5+
3. **Organization context instructions** (`instructions/organization/{Language}/{context}.instructions.md`) - Organization-wide specialized patternsd from a central source to target repositories. The synchronization mechanism can be configured for different organizational contexts:
46

5-
## Overview
7+
**Standard Organization Setup:**
8+
- Source: Organization's `.github` repository
9+
- Target: Repositories with specific custom properties (e.g., `type: module`, `framework: standard`)
610

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.
11+
**Enterprise Setup:**
12+
- Source: Dedicated organization or repository within the enterprise
13+
- Target: All managed repositories or those matching specific criteria
814

9-
## Architecture
15+
**Community Framework Setup:**
16+
- Source: Framework organization's `.github` repository
17+
- Target: Repositories adopting the community framework
1018

11-
### Two-Tier Hierarchy
19+
The synchronization process applies to all Copilot configuration types:
20+
- **Updates**: All files under `organization/` folders are managed by automation and will be overwritten during sync
21+
- **Preserves**: All files under `repository/` folders are never modified by the sync mechanism
22+
- **Flexibility**: Organizations can choose their synchronization criteria and automation approachcture
1223

13-
The instruction system follows a two-tier hierarchy:
24+
This specification documents a scalable GitHub Copilot file management architecture designed to provide consistent guidance, prompts, and chat modes across multiple repositories in community organizations and enterprises.
25+
26+
## Purpose and Context
27+
28+
Modern software organizations require a structured system for managing GitHub Copilot configuration files that enables AI agents to make consistent changes across multiple repositories while allowing for project-specific customization.
29+
30+
Due to the absence of native organization-wide configuration support in GitHub that provides a single location for common Copilot configurations, this architecture implements a scalable two-tier approach for managing:
31+
32+
- **Instructions**: Guidance and patterns for AI agents
33+
- **Prompts**: Reusable prompt templates and patterns
34+
- **Chat modes**: Specialized conversation contexts and behaviors
35+
36+
This architecture serves multiple organizational contexts:
37+
- **Community Organizations**: Open source projects and community frameworks requiring consistent standards across repositories
38+
- **Enterprises**: Large organizations needing centralized AI assistance standards across teams and projects
39+
- **Enterprise Profiles**: Addresses the "enterprise profile" challenge by providing repository-level customization within organizational standardsEach Copilot configuration type follows a consistent two-tier management approach:
40+
41+
- **Organization tier**: Managed via automation from the organization level
42+
- **Repository tier**: Managed locally within each repository
43+
44+
This design allows organizations to maintain consistency across all managed repositories while preserving flexibility for repository-specific requirements.
45+
46+
## Architecture Specification
47+
48+
### Design Decision: Legacy File Elimination
49+
50+
The file `.github/copilot-instructions.md` is not supported in this architecture. This specification replaces the simplified single-file approach with a structured system that manages all GitHub Copilot configuration files through organization-managed and repository-managed tiers.
51+
52+
### Automation and Synchronization
53+
54+
All organization-tier Copilot files are automatically synchronized from the organization's `.github` repository to all repositories that have:
55+
- A custom property named `type`
56+
- With the value `module`
57+
58+
The synchronization process applies to all Copilot configuration types:
59+
- **Updates**: All files under `organization/` folders are managed by automation and will be overwritten during sync
60+
- **Preserves**: All files under `repository/` folders are never modified by the sync mechanism
61+
- **Source**: Organization files originate from the PSModule organization's `.github` repository### Folder Structure Specification
62+
63+
The `.github/` folder contains three Copilot configuration directories, each following the two-tier structure:
1464

1565
```
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
66+
.github/
67+
├── instructions/ # AI agent guidance and patterns
68+
│ ├── organization/ # Organization-managed instruction patterns (automated sync)
69+
│ │ ├── main.instructions.md # Core organizational framework guidelines
70+
│ │ └── {Language}/ # Language/technology-specific framework patterns
71+
│ │ ├── main.instructions.md # Style guide and core instructions
72+
│ │ └── {context}.instructions.md # Specialized context instructions
73+
│ └── repository/ # Repository-managed instruction overrides (manual)
74+
│ ├── main.instructions.md # Repository context and specific rules
75+
│ └── {Language}/ # Repository-specific language customizations
76+
│ ├── main.instructions.md # Repository language patterns
77+
│ └── {context}.instructions.md # Repository context overrides
78+
├── prompts/ # Reusable prompt templates
79+
│ ├── organization/ # Organization-managed prompts (automated sync)
80+
│ │ └── {prompt-files} # Standard organization prompt templates
81+
│ └── repository/ # Repository-managed prompts (manual)
82+
│ └── {prompt-files} # Project-specific prompt templates
83+
└── chatmodes/ # Specialized conversation contexts
84+
├── organization/ # Organization-managed chat modes (automated sync)
85+
│ └── {chatmode-files} # Standard organization chat modes
86+
└── repository/ # Repository-managed chat modes (manual)
87+
└── {chatmode-files} # Project-specific chat modes
2788
```
2889

29-
### Content Hierarchy and Precedence
90+
### File Structure Specification
91+
92+
#### Instructions (Structured Guidance)
93+
94+
**Organization Files (Organization-Managed)**
95+
- **`instructions/organization/main.instructions.md`**: Universal organizational framework guidelines and architectural principles
96+
- **`instructions/organization/{Language}/main.instructions.md`**: Core style guide and language-specific framework instructions
97+
- **`instructions/organization/{Language}/{context}.instructions.md`**: Specialized framework patterns for specific scenarios
98+
99+
**Repository Files (Repository-Managed)**
100+
- **`instructions/repository/main.instructions.md`**: Repository-specific context, technology stack information, and project-specific rules
101+
- **`instructions/repository/{Language}/main.instructions.md`**: Repository-specific language style and patterns that override or extend framework instructions
102+
- **`instructions/repository/{Language}/{context}.instructions.md`**: Project-specific overrides for specialized scenarios
103+
104+
#### Prompts (Reusable Templates)
105+
106+
**Organization Files (Organization-Managed)**
107+
- **`prompts/organization/{name}.prompt.md`**: Standard organization-wide prompt templates for common scenarios
108+
- Organization prompts provide consistent templates for frequent development tasks
30109

31-
Instructions are applied in precedence order, with more specific rules taking precedence:
110+
**Repository Files (Repository-Managed)**
111+
- **`prompts/repository/{name}.prompt.md`**: Project-specific prompt templates tailored to repository requirements
112+
- Repository prompts extend or override organization templates for specialized use cases
32113

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
114+
#### Chat Modes (Conversation Contexts)
37115

38-
## Usage
116+
**Organization Files (Organization-Managed)**
117+
- **`chatmodes/organization/{name}.chatmode.md`**: Standard conversation contexts and specialized AI behaviors
118+
- Organization chat modes provide consistent interaction patterns across repositories
119+
120+
**Repository Files (Repository-Managed)**
121+
- **`chatmodes/repository/{name}.chatmode.md`**: Project-specific conversation contexts and behaviors
122+
- Repository chat modes customize AI interactions for specific project needs
123+
124+
#### Context File Examples
125+
For instructions, context-specific files may include:
126+
- File extension patterns: `tests.instructions.md`, `classes.instructions.md`
127+
- Folder-specific patterns: `workflows.instructions.md`, `docs.instructions.md`
128+
- Functional patterns: `api.instructions.md`, `config.instructions.md`
129+
130+
### Precedence Specification
131+
132+
#### Instruction Precedence
133+
134+
Instructions are evaluated and applied in hierarchical order, with more specific instructions taking precedence:
135+
136+
1. **Organization main instructions** (`instructions/organization/main.instructions.md`) - Organization-wide PSModule patterns
137+
2. **Organization language instructions** (`instructions/organization/{Language}/main.instructions.md`) - Organization-wide language-specific patterns
138+
3. **Organization context instructions** (`instructions/organization/{Language}/{context}.instructions.md`) - Organization-wide specialized patterns
139+
4. **Repository main instructions** (`instructions/repository/main.instructions.md`) - Project-specific context and overrides
140+
5. **Repository language instructions** (`instructions/repository/{Language}/main.instructions.md`) - Project-specific language patterns
141+
6. **Repository context instructions** (`instructions/repository/{Language}/{context}.instructions.md`) - Most specific project-based overrides
142+
143+
#### Prompt and Chat Mode Precedence
144+
145+
For prompts and chat modes, repository-specific files take precedence over organization files when both exist:
146+
147+
- **Organization prompts/chat modes**: Provide default templates and behaviors
148+
- **Repository prompts/chat modes**: Override or extend organization defaults for project-specific needs
149+
150+
This precedence system ensures that repository-specific requirements can override organization-wide patterns while maintaining consistency where no overrides exist.### Migration from Legacy Implementation
151+
152+
Repositories transitioning from the legacy `.github/copilot-instructions.md` approach should:
153+
154+
1. **Remove** the `.github/copilot-instructions.md` file
155+
2. **Create** the new folder structure under `.github/` with `instructions/`, `prompts/`, and `chatmodes/` directories
156+
3. **Distribute** existing content appropriately:
157+
- Universal organizational patterns → Will be provided via organization sync to `instructions/organization/`
158+
- Repository-specific context → `instructions/repository/main.instructions.md`
159+
- Language-specific patterns → Appropriate `instructions/repository/{Language}/` folders
160+
- Prompt templates → `prompts/repository/` (if any existed)
161+
- Chat configurations → `chatmodes/repository/` (if any existed)
162+
163+
Note: Organization files for all Copilot configuration types will be automatically synchronized from the organization level, so manual creation is not necessary.
164+
165+
## Implementation Guidelines
39166

40167
### For AI Agents
41168

42-
When editing files, agents should:
169+
When processing files in repositories using this architecture, AI agents should:
43170

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
171+
1. **Verify architecture compliance**: Confirm the absence of `.github/copilot-instructions.md` and presence of the three-folder Copilot structure under `.github/`
172+
2. **Identify target file characteristics**: Note file extension, folder context, and repository segment
173+
3. **Load configurations in precedence order**:
174+
- Apply instruction hierarchy from organization main through repository context
175+
- Use repository-specific prompts and chat modes when available, falling back to organization defaults
176+
4. **Apply precedence rules**: Later-loaded configurations override earlier ones when conflicts exist
177+
5. **Document patterns**: Record new patterns in appropriate files for future enhancement
178+
6. **Validate changes**: Ensure modifications align with the architectural specification
49179

50-
### For Contributors
180+
### For Repository Contributors
51181

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
182+
Repository maintainers should understand:
55183

56-
## File Format
184+
- **Organization files**: These are automatically synchronized across all Copilot configuration types and should not be manually edited
185+
- **Repository files**: These are manually maintained and contain project-specific customizations for instructions, prompts, and chat modes
186+
- **Precedence hierarchy**: Repository files can override organization files for all configuration types
187+
- **Pattern documentation**: New patterns should be documented promptly in the appropriate scope (organization patterns should be proposed to the organization's central repository)
57188

189+
## File Format Specifications
190+
191+
### Instructions Format
58192
All instruction files must follow this format:
59193

60194
```yaml
@@ -66,17 +200,37 @@ description: "Brief, actionable description of the instruction's purpose"
66200

67201
Content structure: Context lead, Goal, Execution steps, Behavior rules, Output format, Error handling, Definitions
68202

69-
## Key Principles
203+
### Prompts Format
204+
Prompt files should follow established GitHub Copilot prompt conventions with clear context and expected outcomes.
205+
206+
### Chat Modes Format
207+
Chat mode files should define conversation contexts, specialized behaviors, and interaction patterns following GitHub Copilot chat mode specifications.
208+
209+
## Design Principles
210+
211+
This architecture is guided by the following principles:
70212

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
213+
- **Comprehensive Copilot management**: Unified approach to managing all GitHub Copilot configuration files (instructions, prompts, chat modes)
214+
- **Separation of concerns**: Organization-level configurations are managed centrally while repository-specific configurations remain under local control
215+
- **Automation-friendly**: The organization tier supports automated synchronization across all configuration types without affecting repository-managed content
216+
- **Hierarchical precedence**: More specific configurations override general ones, enabling customization while maintaining consistency
217+
- **Convention over configuration**: Established patterns and cross-platform compatibility are prioritized
218+
- **Enterprise integration**: Designed for GitHub enterprise environments with proper authentication, logging, and CI/CD integration
219+
- **Scalable governance**: Organization-wide consistency without sacrificing project-specific flexibility
75220

76-
## Definitions
221+
## Terminology
77222

78-
| Term | Description |
223+
| Term | Definition |
79224
| --- | --- |
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 |
225+
| **Organization instructions** | Organization-managed instruction files under `.github/instructions/organization/` that provide consistent patterns across all managed repositories |
226+
| **Repository instructions** | Repository-managed instruction files under `.github/instructions/repository/` that contain project-specific overrides and extensions |
227+
| **Organization prompts** | Organization-managed prompt templates under `.github/prompts/organization/` that provide standard reusable patterns |
228+
| **Repository prompts** | Repository-managed prompt templates under `.github/prompts/repository/` that contain project-specific prompt customizations |
229+
| **Organization chat modes** | Organization-managed conversation contexts under `.github/chatmodes/organization/` that define standard AI interaction patterns |
230+
| **Repository chat modes** | Repository-managed conversation contexts under `.github/chatmodes/repository/` that define project-specific AI behaviors |
231+
| **Main instructions** | The primary `main.instructions.md` file at the root of organization or repository instruction folders containing core guidelines for that scope |
232+
| **Language instructions** | Language or technology-specific instructions contained within `{Language}/` subfolders |
233+
| **Context instructions** | Specialized instructions for specific file types, folders, or scenarios (e.g., `tests.instructions.md`, `workflows.instructions.md`) |
234+
| **Precedence hierarchy** | The evaluation order where more specific configuration files override more general ones across all Copilot file types |
235+
| **Automatic synchronization** | The process by which organization files are updated from a central source to target repositories for all Copilot configuration types |
236+
| **Managed repository** | A repository that receives automated synchronization based on organizational criteria (custom properties, naming patterns, etc.) |

0 commit comments

Comments
 (0)