Problem
When .github/ is not gitignored, Copilot CLI includes all files from .github/ in the initial context payload without selective filtering — treating them as general repository content rather than structured AI guidance artifacts. VS Code Copilot handles the same directory correctly by loading content selectively (only what's relevant to the current task).
This creates an impossible choice for teams that maintain AI guidance artifacts in .github/:
- Un-ignore
.github/ → CLI context explodes, leaving almost no room for actual work
- Keep
.github/ gitignored → CLI works, but instructions and skills that should be available are invisible
Root Cause
The CLI lacks selective loading logic for .github/ content. VS Code implements staged loading (instructions scoped by glob, skills loaded on demand); the CLI does not — it includes all non-ignored files as undifferentiated context.
Trigger (verified)
Two .gitignore lines that un-ignore .github/ expose the missing feature:
Adding only these two lines to a working repo's .gitignore reproduces the issue. Removing them resolves it. No other file changes are involved.
Evidence
Isolated via binary search on a large monorepo. The only variable is the .gitignore change above — no other file differences.
Representative magnitude (illustrative, based on observed behavior in a real monorepo):
| Configuration |
Context tokens |
.github/ gitignored (baseline) |
~60k |
.github/ un-ignored via !.github/ |
~220k |
Un-ignored, then !.github/ lines removed |
~60k |
Baseline + only !.github/ lines added |
~220k |
A .github/ directory with a few hundred files of AI guidance artifacts (instructions, skills, agents, prompts, standards, reference docs) can easily add 150k+ tokens to the CLI context. The structure follows documented conventions:
copilot-instructions.md (repo-wide instructions)
instructions/*.instructions.md (path-scoped, with applyTo globs)
skills/*/SKILL.md (on-demand skill files with references/ subdirectories)
agents/*.md, prompts/*.md, hooks/*.py, standards/*.md
VS Code Behavior (documented, correct)
VS Code Copilot loads .github/ content selectively, per official documentation:
Custom Instructions (VS Code Docs, GitHub Docs):
- Always loaded:
copilot-instructions.md (repo-wide)
- Loaded when editing matching files:
instructions/*.instructions.md based on applyTo metadata (a glob pattern specifying which file paths the instruction applies to)
Agent Skills (VS Code Docs, Microsoft Learn, Progressive Disclosure Pattern):
Skills use a staged loading model ("progressive disclosure" — load only what's needed, when it's needed):
3. Startup: Only metadata (name + description from YAML header) is scanned for discovery (~50-100 tokens per skill)
4. On match: Full SKILL.md body loaded only when the skill is invoked
5. On need: references/, scripts/ loaded only when the skill explicitly requests them
Never bulk-loaded: standards/, hooks/, and other supporting content
This staged loading keeps context usage proportional to the task at hand.
CLI Behavior (current)
CLI treats un-ignored .github/ files as general repository content and includes all of them in the initial context payload. There is no differentiation between:
- Instruction files that should be auto-loaded
- Skill files that should be loaded on demand
- Reference/standards docs that should only be loaded when a skill requests them
Requested Behavior
Copilot CLI should implement the same selective loading strategy as VS Code:
- Auto-load
copilot-instructions.md (already works when visible)
- Scope-load
instructions/*.instructions.md based on applyTo metadata and current working context (using the same glob syntax VS Code accepts)
- On-demand load
skills/*/SKILL.md only when a skill is invoked (CLI already has skill invocation support)
- Exclude from bulk context
references/, standards/, hooks/, and other supporting files unless explicitly requested
This would allow teams to un-ignore .github/ for git tracking without overwhelming the CLI context window.
Workarounds Considered (all insufficient)
| Workaround |
Why it fails |
.copilotignore to exclude .github/ subdirs |
Binary — hides content completely, prevents on-demand loading |
Keep .github/ gitignored |
Instruction files in instructions/ don't load (see #713) |
respectGitignore: false |
Opposite direction — would expose even more ignored files |
| Work from subdirectory |
Doesn't help — .github/ is at repo root |
Environment
- Copilot CLI version: 1.0.19
- OS: Windows 11
- Repo type: Large monorepo with extensive
.github/ AI guidance artifacts
Related Issues
Problem
When
.github/is not gitignored, Copilot CLI includes all files from.github/in the initial context payload without selective filtering — treating them as general repository content rather than structured AI guidance artifacts. VS Code Copilot handles the same directory correctly by loading content selectively (only what's relevant to the current task).This creates an impossible choice for teams that maintain AI guidance artifacts in
.github/:.github/→ CLI context explodes, leaving almost no room for actual work.github/gitignored → CLI works, but instructions and skills that should be available are invisibleRoot Cause
The CLI lacks selective loading logic for
.github/content. VS Code implements staged loading (instructions scoped by glob, skills loaded on demand); the CLI does not — it includes all non-ignored files as undifferentiated context.Trigger (verified)
Two
.gitignorelines that un-ignore.github/expose the missing feature:Adding only these two lines to a working repo's
.gitignorereproduces the issue. Removing them resolves it. No other file changes are involved.Evidence
Isolated via binary search on a large monorepo. The only variable is the
.gitignorechange above — no other file differences.Representative magnitude (illustrative, based on observed behavior in a real monorepo):
.github/gitignored (baseline).github/un-ignored via!.github/!.github/lines removed!.github/lines addedA
.github/directory with a few hundred files of AI guidance artifacts (instructions, skills, agents, prompts, standards, reference docs) can easily add 150k+ tokens to the CLI context. The structure follows documented conventions:copilot-instructions.md(repo-wide instructions)instructions/*.instructions.md(path-scoped, withapplyToglobs)skills/*/SKILL.md(on-demand skill files withreferences/subdirectories)agents/*.md,prompts/*.md,hooks/*.py,standards/*.mdVS Code Behavior (documented, correct)
VS Code Copilot loads
.github/content selectively, per official documentation:Custom Instructions (VS Code Docs, GitHub Docs):
copilot-instructions.md(repo-wide)instructions/*.instructions.mdbased onapplyTometadata (a glob pattern specifying which file paths the instruction applies to)Agent Skills (VS Code Docs, Microsoft Learn, Progressive Disclosure Pattern):
Skills use a staged loading model ("progressive disclosure" — load only what's needed, when it's needed):
3. Startup: Only metadata (name + description from YAML header) is scanned for discovery (~50-100 tokens per skill)
4. On match: Full
SKILL.mdbody loaded only when the skill is invoked5. On need:
references/,scripts/loaded only when the skill explicitly requests themNever bulk-loaded:
standards/,hooks/, and other supporting contentThis staged loading keeps context usage proportional to the task at hand.
CLI Behavior (current)
CLI treats un-ignored
.github/files as general repository content and includes all of them in the initial context payload. There is no differentiation between:Requested Behavior
Copilot CLI should implement the same selective loading strategy as VS Code:
copilot-instructions.md(already works when visible)instructions/*.instructions.mdbased onapplyTometadata and current working context (using the same glob syntax VS Code accepts)skills/*/SKILL.mdonly when a skill is invoked (CLI already has skill invocation support)references/,standards/,hooks/, and other supporting files unless explicitly requestedThis would allow teams to un-ignore
.github/for git tracking without overwhelming the CLI context window.Workarounds Considered (all insufficient)
.copilotignoreto exclude.github/subdirs.github/gitignoredinstructions/don't load (see #713)respectGitignore: false.github/is at repo rootEnvironment
.github/AI guidance artifactsRelated Issues
applyTo; our issue extends to skills, agents, prompts, and standards).github/is gitignored (same root tension, different symptom)