[Feature Request] Add option to disable automatic loading of .github/instructions/*.instructions.md files

Resolved 💬 4 comments Opened Feb 23, 2026 by bherrmann7 Closed Feb 26, 2026

[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.md files in .github/instructions/
  • It reads applyTo frontmatter (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 applyTo pattern
  • The same system that loads .claude/rules/*.md with paths frontmatter likely handles this — look for shared glob-matching logic between applyTo and paths
  • CLAUDE_CODE_SIMPLE mode 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:

  1. Best: A setting like "excludeInstructionPaths": [".github/instructions"] or "disableGithubInstructions": true in settings.json
  2. Also good: Make ignorePatterns apply to instruction file discovery (currently it only affects file picker/search)
  3. Minimum: A CLI flag like --no-instruction-files
  4. Also check: permissions.deny with Read(.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.md files (copied identically)
  • .github/copilot-instructions.md (present in both)
  • Target .cs file 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

View original on GitHub ↗

This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗