Instructions
Instructions are persistent coding standards that Copilot applies automatically based on the files youβre editing. Unlike agents (which you invoke) or skills (which execute steps), instructions activate passively via applyTo glob patterns.
How Instructions Work
When you open a file in VS Code, Copilot checks all .instructions.md files to see if any applyTo pattern matches your file. Matching instructions are loaded into the conversation context, so Copilot follows those rules when generating or editing code.
You open `src/api.py`
β Copilot checks all .instructions.md files
β `applyTo: "**/*.py"` matches!
β Instruction rules are loaded into context
β Copilot generates code following those standardsFile Structure
Instructions live in instructions/ (or .github/instructions/ inside a play):
---
description: "Enforces Python best practices for Azure AI services β security, reliability, and cost optimization patterns."
applyTo: "**/*.py"
waf:
- "security"
- "reliability"
- "cost-optimization"
---
# Python Azure AI Coding Standards
## Security
- Use `DefaultAzureCredential` for all Azure authentication β never hardcode keys
- Load secrets from environment variables or Azure Key Vault, never from code
## Reliability
- Add retry with exponential backoff on all Azure SDK and HTTP calls
- Set explicit timeouts β never rely on client defaultsFrontmatter Schema
| Field | Required | Type | Validation |
|---|---|---|---|
description | β | string | Minimum 10 characters |
applyTo | β | string | Valid glob pattern |
waf | No | string[] | Valid WAF pillar names |
applyTo Glob Patterns
The applyTo pattern determines which files trigger the instruction:
| Pattern | Matches | Use Case |
|---|---|---|
**/*.py | All Python files | Python coding standards |
**/*.{ts,tsx} | TypeScript + TSX | React/TypeScript standards |
**/*.bicep | All Bicep files | IaC best practices |
**/*.{yaml,yml} | YAML files | Config/pipeline standards |
**/test_*.py | Python test files | Testing patterns |
solution-plays/01-*/** | Play 01 files only | Per-play targeting |
**/infra/**/*.bicep | Infra Bicep only | Infrastructure rules |
Glob rules:
*matches any characters except/**matches any characters including/(recursive){a,b}matches eitheraorb
WAF Instructions
FrootAI ships with instructions for each Well-Architected Framework pillar:
| Instruction | Pillar | Applies To |
|---|---|---|
waf-security.instructions.md | Security | **/*.{ts,js,py,bicep,json,yaml,yml} |
waf-reliability.instructions.md | Reliability | **/*.{ts,js,py,bicep,json,yaml,yml} |
waf-cost-optimization.instructions.md | Cost | **/*.{ts,js,py,bicep,json,yaml,yml} |
waf-operational-excellence.instructions.md | Ops Excellence | **/*.{ts,js,py,bicep,json,yaml,yml} |
waf-performance-efficiency.instructions.md | Performance | **/*.{ts,js,py,bicep,json,yaml,yml} |
waf-responsible-ai.instructions.md | Responsible AI | **/*.{ts,js,py,bicep,json,yaml,yml} |
WAF Security Example
The waf-security instruction enforces: never hardcode secrets, use Managed Identity, implement RBAC, enable private endpoints, rate-limit AI API calls, and pin dependency versions. These rules auto-apply to every code file.
Writing Effective Instructions
Copilot follows examples better than prose. Include concrete code patterns:
## Authentication β Always Use Managed Identity
β
Correct:
```python
from azure.identity import DefaultAzureCredential
credential = DefaultAzureCredential()β Wrong:
api_key = "sk-abc123..." # NEVER hardcode keys
<Callout type="info" emoji="π‘">
**Keep Under 200 Lines**
Instructions are loaded into the LLM context window. Shorter instructions use fewer tokens and get applied more reliably. One concern per instruction file.
</Callout>
## Multi-Scope Instructions
Target multiple file types with a single glob:
```yaml
---
description: "Full-stack WAF standards for TypeScript frontend and Python backend"
applyTo: "**/*.{ts,tsx,py}"
waf: ["security", "reliability", "performance-efficiency"]
---For play-specific instructions:
---
description: "Play 01 Enterprise RAG implementation standards"
applyTo: "solution-plays/01-enterprise-rag/**/*.{py,ts,bicep}"
---Validation
npm run validate:primitivesThis checks that every instruction has:
descriptionwith 10+ characters- Valid
applyToglob pattern - Correct lowercase-hyphen filename
See Also
- Create an Instruction Guide β step-by-step tutorial
- Well-Architected Framework β the 6 pillars
- Primitives Overview β all 6 primitive types