Skip to content

Commit 229c99b

Browse files
DanWahlinCopilot
andauthored
docs(ch04): add applyTo frontmatter docs for instruction files
Document the applyTo frontmatter option in .instructions.md files, which scopes an instruction file to specific file types using a glob pattern. Include a worked example, a table of common patterns, and a tip about quoting globs for cross-platform reliability. This feature was made reliably available in Copilot CLI v1.0.48 (2026-05-14), which fixed parsing of unquoted glob patterns in the applyTo field. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent eb7e358 commit 229c99b

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

04-agents-custom-instructions/README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,32 @@ For teams that want more granular control, split instructions into topic-specifi
446446

447447
> 💡 **Note**: Instruction files work with any language. This example uses Python to match our course project, but you can create similar files for TypeScript, Go, Rust, or any technology your team uses.
448448

449+
#### Scoping Instructions with `applyTo`
450+
451+
By default, an instruction file applies to every conversation. To limit it to specific file types, add an `applyTo` field in YAML frontmatter (the block between `---` markers at the very top of the file):
452+
453+
```markdown
454+
---
455+
applyTo: "**/*.py"
456+
---
457+
# Python Standards
458+
Always follow PEP 8 style conventions.
459+
Use type hints in all function signatures.
460+
```
461+
462+
With `applyTo: "**/*.py"`, Copilot only loads that instruction file when you are working with Python files. Instructions for Python style never clutter a conversation about, say, a Dockerfile or a SQL query.
463+
464+
Here are some common patterns:
465+
466+
| `applyTo` value | When it applies |
467+
|---|---|
468+
| `"**/*.py"` | Any Python file |
469+
| `"**/*.{ts,tsx}"` | TypeScript and TSX files |
470+
| `"tests/**"` | Any file inside a `tests/` folder |
471+
| (no frontmatter) | Every conversation — the default |
472+
473+
> 💡 **Tip**: Wrap the glob pattern in quotes (e.g., `"**/*.py"`) to ensure it is interpreted correctly across all operating systems and shells.
474+
449475
**Finding community instruction files**: Browse [github/awesome-copilot](https://github.com/github/awesome-copilot) for pre-made instruction files covering .NET, Angular, Azure, Python, Docker, and many more technologies.
450476

451477
### Disabling Custom Instructions

0 commit comments

Comments
 (0)