kilocode icon indicating copy to clipboard operation
kilocode copied to clipboard

Bug: Some custom modes load external CLAUDE.md instructions and lose their mode identity

Open terry-webandwow opened this issue 8 months ago • 4 comments

Bug: Some custom modes load external CLAUDE.md instructions and lose their mode identity

Summary

We are seeing a mode-isolation problem in Kilo Code.

Two of our custom modes, Conrad and Anna, do not keep their own mode identity when started. Instead, they appear to load external instructions from C:\Users\terry\.claude\CLAUDE.md and then behave as a different agent/persona defined there.

Other custom modes in the same setup are not affected.

Environment

  • OS: Windows
  • Editor: VS Code
  • Product: Kilo Code extension
  • Global Kilo Code config: C:\Users\terry\.config\kilo\kilo.jsonc
  • External file present: C:\Users\terry\.claude\CLAUDE.md
  • CLAUDE.md is a symlink to: P:/core/AGENTS/bootstrap/CLAUDE.md

Affected / Not Affected

Affected custom modes:

  • Conrad
  • Anna

Not affected custom modes:

  • Archie
  • Wendy
  • Randy
  • Ernie

All of these are custom modes from the same Kilo Code setup.

Expected Behavior

When starting Conrad or Anna, Kilo Code should use only that selected custom mode's own instructions and identity.

For example:

  • Conrad should respond as Conrad
  • Anna should respond as Anna

The selected mode should not be replaced or overridden by unrelated external agent instructions.

Actual Behavior

When starting Conrad or Anna, the agent behaves as if instructions from C:\Users\terry\.claude\CLAUDE.md were loaded on top of or instead of the selected mode instructions.

Observed results:

  • the agent identifies as a different persona defined in CLAUDE.md
  • it references loading files/instructions that belong to that external persona
  • it follows the external persona workflow instead of the selected custom mode

This does not happen with our other tested custom modes.

Steps to Reproduce

  1. Configure multiple custom modes in Kilo Code
  2. Ensure C:\Users\terry\.claude\CLAUDE.md exists
  3. Start a new conversation in custom mode Conrad
  4. Ask a simple identity question such as: Who are you?
  5. Repeat the same test with custom mode Anna

Result

Conrad and Anna do not consistently act as themselves.
Instead, they appear to load and follow instructions from the external CLAUDE.md.

Control Test

Run the same test with other custom modes in the same setup, such as:

  • Archie
  • Wendy
  • Randy
  • Ernie

Those modes keep their own identity correctly and do not show the same problem.

What We Know

Confirmed:

  • The issue is reproducible with Conrad and Anna
  • The issue was not observed with the other tested custom modes listed above
  • The behavior strongly suggests that external CLAUDE.md instructions are being loaded for some custom modes

Not yet confirmed:

  • Why only some custom modes are affected
  • What exact condition triggers this behavior
  • Whether this is tied to load order, mode type, or another internal matching rule

Impact

  • Some custom modes are not isolated correctly
  • The selected mode can lose its identity and instructions
  • This makes custom mode behavior unreliable
  • It breaks trust in mode-specific workflows, because selecting a mode does not guarantee that mode will actually run as configured

Why This Seems Like a Bug

From a user perspective, selecting a custom mode should guarantee that this mode's own instructions remain authoritative.

External files such as CLAUDE.md should not silently override the selected custom mode, or there should at least be an explicit setting controlling that behavior.

Suggested Fix

Any of the following would solve the issue:

  1. Do not auto-load external CLAUDE.md instructions for Kilo Code custom modes
  2. Add an explicit opt-in / opt-out setting for external instruction loading
  3. Guarantee that the selected custom mode prompt has higher priority than external agent bootstrap files

Relevant Paths

  • Kilo Code config: C:\Users\terry\.config\kilo\kilo.jsonc
  • External file: C:\Users\terry\.claude\CLAUDE.md
  • Symlink target: P:/core/AGENTS/bootstrap/CLAUDE.md

Additional Note

We are not reporting a problem with the content of those files themselves.
The issue is that some custom modes appear to load unrelated external instructions and lose their own intended identity, while other custom modes in the same environment do not.

terry-webandwow avatar Apr 02 '26 04:04 terry-webandwow

temporary solution till commit 31019dd is not pushed :

https://github.com/Kilo-Org/kilocode/issues/8187#issuecomment-4177476415

bxw91 avatar Apr 02 '26 21:04 bxw91

We tested the suggested workaround, but it does not resolve the issue in our setup.

We added KILO_DISABLE_CLAUDE_CODE=true in VS Code user settings:

"terminal.integrated.env.windows": {
  "KILO_DISABLE_CLAUDE_CODE": "true"
}

After that we:

  • reloaded the VS Code window
  • started a fresh Kilo session
  • tested again

Result:

  • the issue still persists
  • the agent still picks up the external CLAUDE.md / Clark bootstrap behavior

So in this setup, either:

  1. the workaround is being applied in the wrong place/process, or
  2. the env var is currently not effective for the code path that triggers this bug

Environment:

  • Windows
  • VS Code
  • Kilo Code 7.1.20

terry-webandwow avatar Apr 03 '26 00:04 terry-webandwow

"terminal.integrated.env.windows": { "KILO_DISABLE_CLAUDE_CODE": "true" }

I am not sure that this will work because VS code loads extensions in background and not in terminal window that is shown in VS Code.

I don't use VS Code in Windows but maybe try SET command in command line, or set environment variable in Windows system settings and then start VS Code.

bxw91 avatar Apr 03 '26 01:04 bxw91

Confirmed from our side: this is now fixed.

We tested it again in the current version, and the bug no longer occurs in our setup. The affected custom modes now keep their intended identity instead of being overridden by the external CLAUDE.md bootstrap.

Thank you for fixing this so quickly. That was a pretty important issue for us because it directly affected trust in custom mode isolation.

terry-webandwow avatar Apr 06 '26 03:04 terry-webandwow