Instructions - Layer 2: Agent Primitives¶
Documentation views — these pages describe the instructions for the website. The normative, auto-applied sources live in
instructions/. If a page and its source ever diverge, the source wins.
Markdown Prompt Engineering implemented as modular .instructions.md files with Context Engineering via applyTo patterns. These files customize GitHub Copilot's behavior for AL development in Business Central.
📋 What Are Instructions?¶
Instructions are auto-applied coding guidelines that: - Load automatically based on applyTo patterns (e.g., **/*.al) - Provide persistent context to GitHub Copilot during code generation - Implement best practices through structured markdown rules - Use semantic markdown (headers, lists, examples) for AI reasoning
🎯 How to Use Instructions¶
Instructions work automatically - no activation needed. When you: - Open an AL file → Instructions with matching applyTo patterns load - Type code → Copilot applies these guidelines in real-time - Ask for help → Context from relevant instructions is available
📦 Available Instructions (10 contracts)¶
The current source inventory contains nine scoped .instructions.md files (eight general AL rules and the optional agent SDK rule), plus the Copilot entrypoint. Documentation indexes and README files are excluded.
Always Active (apply to **/*.al)¶
| File | Purpose | Key Rules |
|---|---|---|
| al-guidelines.instructions.md | Master hub and integration guide | References all other instructions, AL development philosophy |
| al-code-style.instructions.md | Code formatting & organization | Feature-based structure, PascalCase, 120 char lines |
| al-naming-conventions.instructions.md | Naming standards | PascalCase for all, 26-char table limits, Codeunit suffixes |
| al-security.instructions.md | Security review | Least privilege, SecretText, secure events and outbound calls |
Context-Triggered (specific patterns)¶
| File | Apply Pattern | Purpose |
|---|---|---|
| al-performance.instructions.md | **/*.Codeunit.al, **/*.Query.al | SetLoadFields, early filtering, temporary tables |
| al-error-handling.instructions.md | **/*.Codeunit.al | TryFunctions, error labels, telemetry only when requested |
| al-events.instructions.md | **/*.Codeunit.al | Event publishers/subscribers, standard publisher flow |
| al-testing.instructions.md | **/test/**/*.al | Tests when requested, test codeunits, scenarios |
| al-agent-toolkit.instructions.md (optional) | Factory, Metadata, TaskExecution and Setup codeunits | Agent SDK completeness and contracts |
Integration & Reference¶
| File | Purpose |
|---|---|
| copilot-instructions.md | Master integration guide for GitHub Copilot with all primitives |
🏗️ Architecture Patterns¶
Layer 1: Markdown Prompt Engineering¶
Each instruction uses structured markdown:
## Rule: Clear Title
### Intent
What this rule accomplishes
### Implementation
How to implement it
### Examples
✅ Good / ❌ Bad examples
Layer 3: Context Engineering¶
Instructions use applyTo patterns for modular loading:
💡 Best Practices¶
When Instructions Apply¶
- ✅ Active Coding - Instructions load during development
- ✅ Code Review - Context available for analysis
- ✅ Refactoring - Guidelines inform improvements
- ⚠️ Read-Only - May not apply when just viewing
Combining with Other Primitives¶
Instructions work alongside: - Agentic Workflows (/[workflow], for example /al-build) - For specific tasks - Agents (Use [mode-name]) - For strategic consultation - Both can reference instruction rules in their guidance
Creating Custom Instructions¶
- Create file in this directory:
al-[feature].instructions.md - Add frontmatter:
- Structure content using semantic markdown
- Update collection manifest in
collections/al-development.collection.yml - Test by opening matching files and observing Copilot behavior
🔗 Related Resources¶
- Collection Manifest:
collections/al-development.collection.yml - Framework Reference:
docs/framework/ai-native-instructions-architecture.md - User Guide:
al-development.md - Contributing:
CONTRIBUTING.md
📊 Validation¶
Run npm run validate to verify: - All instruction files exist - Frontmatter is properly formatted - File naming conventions are followed - applyTo patterns are valid
Framework Compliance: These instructions implement AI Native-Instructions Architecture - Layer 2 (Agent Primitives) using Layer 1 (Markdown Prompt Engineering) and Layer 3 (Context Engineering) principles.
Version: 5.3.0 Total Instruction Contracts: 10 (9 scoped rules plus the Copilot entrypoint; documentation excluded) Last Updated: 2026-11-10