From a7632d6641246673d0b67ef67da32818ca0e15e7 Mon Sep 17 00:00:00 2001 From: serxa Date: Fri, 17 Jul 2026 19:16:14 +0000 Subject: [PATCH] Set setting_sources=[] so the CLI does not duplicate the prompt bundle MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Nerve builds the entire system prompt itself — the identity/memory bundle (SOUL/IDENTITY/USER/AGENTS/TOOLS/MEMORY) via system_prompt, plus permissions, MCP servers, hooks and env passed explicitly. Left at the default, the Claude Code CLI also auto-loads ~/.claude/CLAUDE.md (the bundle its own renderer writes for external claude-code use), duplicating tens of thousands of tokens on every turn. Passing setting_sources=[] disables all filesystem settings/memory loading. ["project"] alone is insufficient: the managed workspace lives under $HOME, so project-root detection climbs to $HOME and loads the user-level CLAUDE.md under both the "user" and "project" sources. Native skills/plugins are unaffected (loaded via plugins / --plugin-dir). Co-Authored-By: Claude Opus 4.8 --- nerve/agent/backends/claude.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/nerve/agent/backends/claude.py b/nerve/agent/backends/claude.py index 5223e53..7634555 100644 --- a/nerve/agent/backends/claude.py +++ b/nerve/agent/backends/claude.py @@ -476,6 +476,19 @@ def _cli_stderr(line: str) -> None: disallowed_tools=["CronCreate", "CronList", "CronDelete"], env=self._build_env(cache_ttl=spec.cache_ttl), cwd=spec.cwd, + # Load no filesystem settings/memory: Nerve owns the entire + # prompt. It injects the full identity/memory bundle + # (SOUL/IDENTITY/USER/AGENTS/TOOLS/MEMORY) via ``system_prompt`` + # and passes permissions (``can_use_tool``), MCP (``mcp_servers``), + # hooks and env explicitly. Left at the default, the CLI would also + # auto-load ~/.claude/CLAUDE.md — the same bundle the Claude Code + # renderer writes for external claude-code use — duplicating tens + # of thousands of tokens every turn. ["project"] is NOT enough: the + # workspace lives under $HOME, so project-root detection climbs to + # $HOME and loads the user-level CLAUDE.md under both the "user" and + # "project" sources. Native skills/plugins are unaffected — they + # load via ``plugins`` (--plugin-dir), independent of this setting. + setting_sources=[], mcp_servers=self._build_mcp_servers(spec.session_id), # Claude Code plugins — loaded via --plugin-dir so the CLI # handles OAuth, credentials, and plugin lifecycle natively.