From 229c99bfe61532760fa7ba49089bcb9f6811441c Mon Sep 17 00:00:00 2001 From: Dan Wahlin Date: Mon, 18 May 2026 14:53:35 +0200 Subject: [PATCH] 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> --- 04-agents-custom-instructions/README.md | 26 +++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/04-agents-custom-instructions/README.md b/04-agents-custom-instructions/README.md index 8e4a7629..5321b172 100644 --- a/04-agents-custom-instructions/README.md +++ b/04-agents-custom-instructions/README.md @@ -446,6 +446,32 @@ For teams that want more granular control, split instructions into topic-specifi > 💡 **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. +#### Scoping Instructions with `applyTo` + +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): + +```markdown +--- +applyTo: "**/*.py" +--- +# Python Standards +Always follow PEP 8 style conventions. +Use type hints in all function signatures. +``` + +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. + +Here are some common patterns: + +| `applyTo` value | When it applies | +|---|---| +| `"**/*.py"` | Any Python file | +| `"**/*.{ts,tsx}"` | TypeScript and TSX files | +| `"tests/**"` | Any file inside a `tests/` folder | +| (no frontmatter) | Every conversation — the default | + +> 💡 **Tip**: Wrap the glob pattern in quotes (e.g., `"**/*.py"`) to ensure it is interpreted correctly across all operating systems and shells. + **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. ### Disabling Custom Instructions