github / github/copilot-cli

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

Đang mở
#2,909 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
area:configuration area:context-memory
Ngôn ngữ chính
Shell
Star
11.2k
Fork
1.9k
Merge trung bình
14 giờ 16 phút
Pull request đã merge (30 ngày)
6

Mô tả

### 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:

```md
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_

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.