Skip to content

fix(install): stop folding sub-agent context into CLAUDE.md / copilot-instructions.md#121

Merged
Minitour merged 1 commit into
mainfrom
fix/no-subagent-fold-when-dedicated-dir
Jun 18, 2026
Merged

fix(install): stop folding sub-agent context into CLAUDE.md / copilot-instructions.md#121
Minitour merged 1 commit into
mainfrom
fix/no-subagent-fold-when-dedicated-dir

Conversation

@Minitour

Copy link
Copy Markdown
Contributor

Summary

  • Sub-agent context was being duplicated into the provider's primary instructions file (CLAUDE.md, .github/copilot-instructions.md) on top of the dedicated .claude/agents/{id}.md / .github/agents/{id}.md file. This bloated the main agent's context window on every turn.
  • The fallback branch in writesSubAgentInstructionsContext (src/cli/utils/agents-file.ts:441) fired whenever the provider had a subagents integration AND an instructions filename that wasn't the universal AGENTS.md. That caught claude-code (the explicit foldSubAgentsIntoInstructions: false was silently overridden) and github-copilot. Providers writing to AGENTS.md (cursor, codex, …) were unaffected because the equality short-circuited the branch.
  • After this change, a dedicated subagents integration is the single source of truth — no fold into the primary instructions file. Folding is only performed when a provider has no sub-agent integration AND explicitly opts in via foldSubAgentsIntoInstructions: true.

Behavioural diff

Provider Before After
claude-code .claude/agents/{id}.md + CLAUDE.md snippet .claude/agents/{id}.md only
github-copilot .github/agents/{id}.md + .github/copilot-instructions.md snippet .github/agents/{id}.md only
cursor / codex / gemini / … (AGENTS.md) .{provider}/agents/{id}.md only unchanged

capa clean continues to remove any stale sub-agent blocks from CLAUDE.md / AGENTS.md for users upgrading from a pre-fix install (the cleanup path is purely text-based and doesn't care how the blocks got there).

Test plan

  • bun test src/cli/utils/__tests__/sub-agent-instructions.test.ts — flipped three assertions, added regression tests for claude-code and github-copilot
  • bun test src/cli/utils/__tests__/agents-file.test.ts
  • bun test src/cli/commands/__tests__/clean.test.ts
  • Full suite: bun test (1096 pass, 0 fail)
  • tsc --noEmit clean

🤖 Generated with Claude Code

…-instructions.md

Sub-agent context was being duplicated into the provider's primary
instructions file (CLAUDE.md, .github/copilot-instructions.md) on top of
the dedicated `.claude/agents/{id}.md` / `.github/agents/{id}.md` file,
bloating the main agent's context window. The `writesSubAgentInstructionsContext`
fallback fired whenever the provider had a `subagents` integration and an
instructions filename that wasn't the universal `AGENTS.md` — covering
both claude-code (`foldSubAgentsIntoInstructions: false` notwithstanding)
and github-copilot. Treat a dedicated `subagents` integration as the
single source of truth and only fold when `foldSubAgentsIntoInstructions: true`
is explicitly set on a provider without its own sub-agent dir.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@Minitour Minitour merged commit 0908b20 into main Jun 18, 2026
8 checks passed
@Minitour Minitour deleted the fix/no-subagent-fold-when-dedicated-dir branch June 18, 2026 09:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant