[Feature Request] Add option to disable automatic loading of .github/instructions/*.instructions.md files
[Bug] .github/instructions/*.instructions.md auto-loaded into context, no opt-out
Summary for the fixing agent
You're looking for the code path that discovers and loads .github/instructions/*.instructions.md files into the context window. This is the same internal instruction loading mechanism used for .claude/rules/*.md and child-directory CLAUDE.md files — NOT the Read tool. The loading produces "Loaded ../../.github/instructions/..." messages in terminal output (note the ../../ relative path prefix).
What to search for in the source
- The loader that matches
*.instructions.mdfiles in.github/instructions/ - It reads
applyTofrontmatter (YAML) from these files and matches glob patterns against the file being read - It's triggered on-demand when Claude reads a file whose path matches an
applyTopattern - The same system that loads
.claude/rules/*.mdwithpathsfrontmatter likely handles this — look for shared glob-matching logic betweenapplyToandpaths CLAUDE_CODE_SIMPLEmode disables this (along with everything else) — search for what that flag gates to find the instruction loading pipeline- The behavior only triggers in large repos (~11,000 files) but not small test repos (~74 files) with identical config — there may be a project indexing step, file count threshold, or caching layer that gates instruction discovery
What needs to change
Add a way to disable or filter .github/instructions/ loading. Options:
- Best: A setting like
"excludeInstructionPaths": [".github/instructions"]or"disableGithubInstructions": trueinsettings.json - Also good: Make
ignorePatternsapply to instruction file discovery (currently it only affects file picker/search) - Minimum: A CLI flag like
--no-instruction-files - Also check:
permissions.denywithRead(.github/instructions/**)does NOT block this loading — the deny system should probably apply to internal loads too, not just tool-invoked reads
The problem
In a production .NET monorepo (~11,000 files, ~1,900 .cs files), reading any service-layer file triggers loading of 12+ .github/instructions/*.instructions.md files into context, immediately exhausting the context window. These files exist for GitHub Copilot (they use Copilot's applyTo frontmatter format) and are not intended for Claude Code.
Reproduction output
> Can you read EmbeddedSqlService.cs
Read 1 file (ctrl+o to expand)
Loaded .github/instructions/demoulas.common.restful-api-guidelines.instructions.md
Loaded .github/instructions/demoulas.common.logging.instructions.md
Loaded .github/instructions/demoulas.common.contracts.instructions.md
Loaded .github/instructions/common.services.instructions.md
Loaded .github/instructions/demoulas.common.instructions.md
Loaded .github/instructions/svc.services.instructions.md
Loaded .github/instructions/demoulas.util.instructions.md
Loaded .github/instructions/demoulas.common.caching.instructions.md
Loaded .github/instructions/demoulas.common.pdf.instructions.md
Loaded .github/instructions/demoulas.common.messaging.instructions.md
Loaded .github/instructions/demoulas.common.data.instructions.md
Loaded .github/instructions/demoulas.common.security.instructions.md
Context limit reached
Example instruction file frontmatter that triggers the load:
---
applyTo: "src/services/src/**/*.*"
paths: "src/services/src/**/*.*"
---
The file read was: src/services/src/Demoulas.ProfitSharing.Services/Services/Reports/EmbeddedSqlService.cs
What does NOT work (don't waste time retesting these)
| Approach | Why it fails |
|---|---|
| ignorePatterns: [".github"] in settings.json | Only affects file picker/search, not instruction loading |
| permissions.deny: ["Read(.github/instructions/**)"] | Loading is internal, doesn't go through Read tool permission check |
| PreToolUse hooks blocking .github/instructions | Hooks intercept tool calls only, not internal instruction loading |
| --setting-sources user | Skips project settings/CLAUDE.md but instruction discovery still runs |
| ~/.claude/CLAUDE.md with "ignore .github/instructions" | Soft instruction in prompt, system already injected the files |
| Deleting ~/.claude/projects/<project>/ cache | Still triggers — not cached state |
Reproduction difficulty — large repo only
Created a minimal test repo copying all config from the affected repo. Loading never triggers. Eliminated:
- All 59
.github/instructions/*.instructions.mdfiles (copied identically) .github/copilot-instructions.md(present in both)- Target
.csfile at exact matching path structure .claude/settings.local.json,CLAUDE.md,AGENTS.md,.mcp.json(all identical)~/.claude/projects/cached state (renamed away — still triggers in real repo)
Only difference: real repo has 11,014 files (1,884 .cs) vs test repo with 74 files (3 .cs). The instruction discovery pipeline likely has a threshold, indexing step, or initialization path that only activates for repos above a certain size.
Environment
- Platform: darwin
- Terminal: iTerm.app
- Version: 2.1.59 (also reproduced on 2.1.50)
- Repo: .NET/C# monorepo with React frontend, Oracle database layer
4 Comments
Found 3 possible duplicate issues:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
It has nothing to do with claude.md. Claude code automatically loads files with .github/instructions without any other direction. It loads them on demand. If you say to look at a particular file, it seems to get triggered into accessing related .github/instructions.
It loads these files even if they're explicitly excluded from permissions
This was because a team member had create a symlink in the repo;
$ cd our-project
$ ln -s .gihub/instructions .claude/rules/shared
This was probably fine when we had a few instructions files, but became a problem as the instruction files bloated out.
Simply removing the link solved my problem.
Chow.
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.