Skip to content

Copilot CLI does not consistently apply path-scoped .instructions.md files when editing matching files #2909

@joji-varghese

Description

@joji-varghese

Describe the bug

Summary

In Copilot CLI, repository-level copilot-instructions.md appears to load reliably at session start, but path-scoped instruction files such as csharp.instructions.md with applyTo: "**/*.cs" do not appear to be applied consistently when the agent edits matching files.

This looks like a functional gap or bug in the CLI’s instruction-loading behavior. We have been told that VS Code Copilot does load these instructions, so the issue may be CLI-specific.

What we expected

When the agent is about to work on a file that matches a scoped instruction file, for example a *.cs file matching:

applyTo: "**/*.cs"

we expect Copilot CLI to bring that instruction file into scope for that task, without requiring the agent to explicitly open and read the file itself.

In other words, path-scoped instructions should be applied on demand when relevant files are being edited, not only if the model independently decides to read them.

What actually happens
In practice, the agent often goes straight into editing .cs files without any indication that the scoped C# instructions were loaded or applied.

Observed behavior:

Top-level copilot-instructions.md appears to be loaded reliably at session start.
Scoped instruction files such as csharp.instructions.md do not appear to be loaded automatically when editing matching files.
Adding or refining rules in csharp.instructions.md does not materially change agent behavior, which suggests those files are usually not in context.
The only way those files seem to affect behavior is if the agent explicitly opens and reads them first.
This makes the scoped instruction mechanism unreliable in CLI for language- or path-specific guidance.

Why this matters

This significantly reduces the usefulness of scoped instruction files. Teams may believe they are enforcing language-specific guidance, but in practice the CLI agent may never see that guidance during edits.

For us, this means C#-specific rules are effectively bypassed unless the agent happens to read the instruction file manually.

Repro steps

Create a repository with:
a top-level copilot-instructions.md
a scoped instruction file such as csharp.instructions.md containing C#-specific rules and an applyTo pattern like **/*.cs
Open Copilot CLI in that repository.
Ask the agent to modify an existing .cs file.
Observe that the agent proceeds directly to editing the .cs file.
Check the environment / attached context for the turn and compare behavior with and without explicitly asking the agent to read the scoped instruction file first.
Expected result
Before or during edits to matching files, Copilot CLI should automatically apply the relevant scoped instruction file(s) based on applyTo.

Actual result

Copilot CLI appears to ignore or skip scoped instruction files unless the agent explicitly opens them.

Affected version

No response

Steps to reproduce the behavior

No response

Expected behavior

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:configurationConfig files, instruction files, settings, and environment variablesarea:context-memoryContext window, memory, compaction, checkpoints, and instruction loading

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions