From 07c2010d32f90c357ae150a12db6362f888f9877 Mon Sep 17 00:00:00 2001 From: Auto Date: Mon, 12 Jan 2026 14:39:50 +0200 Subject: [PATCH] fix: write system prompts to file to avoid Windows command line limit Changes: - Write system prompts to CLAUDE.md file instead of passing inline - Use setting_sources=["project"] to load prompts from file - Affects spec_chat_session.py and assistant_chat_session.py Why: - Windows has ~8191 character command line limit - System prompts (e.g., create-spec.md at ~19KB) exceeded this limit - The SDK serializes system_prompt as a CLI argument - Writing to file and using setting_sources bypasses the limit This completes the fix for GitHub issue #33 (Windows "Command Line Too Long"). The previous commit removed **os.environ from MCP configs; this commit addresses the larger system prompt issue. Co-Authored-By: Claude Opus 4.5 --- server/services/assistant_chat_session.py | 11 ++++++++++- server/services/spec_chat_session.py | 11 ++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/server/services/assistant_chat_session.py b/server/services/assistant_chat_session.py index 73a17e6..b0051b8 100755 --- a/server/services/assistant_chat_session.py +++ b/server/services/assistant_chat_session.py @@ -242,6 +242,13 @@ class AssistantChatSession: # Get system prompt with project context system_prompt = get_system_prompt(self.project_name, self.project_dir) + # Write system prompt to CLAUDE.md file to avoid Windows command line length limit + # The SDK will read this via setting_sources=["project"] + claude_md_path = self.project_dir / "CLAUDE.md" + with open(claude_md_path, "w", encoding="utf-8") as f: + f.write(system_prompt) + logger.info(f"Wrote assistant system prompt to {claude_md_path}") + # Use system Claude CLI system_cli = shutil.which("claude") @@ -253,7 +260,9 @@ class AssistantChatSession: options=ClaudeAgentOptions( model="claude-opus-4-5-20251101", cli_path=system_cli, - system_prompt=system_prompt, + # System prompt loaded from CLAUDE.md via setting_sources + # This avoids Windows command line length limit (~8191 chars) + setting_sources=["project"], allowed_tools=[*READONLY_BUILTIN_TOOLS, *ASSISTANT_FEATURE_TOOLS], mcp_servers=mcp_servers, permission_mode="bypassPermissions", diff --git a/server/services/spec_chat_session.py b/server/services/spec_chat_session.py index e073a4e..1f0d8cc 100644 --- a/server/services/spec_chat_session.py +++ b/server/services/spec_chat_session.py @@ -154,6 +154,13 @@ class SpecChatSession: project_path = str(self.project_dir.resolve()) system_prompt = skill_content.replace("$ARGUMENTS", project_path) + # Write system prompt to CLAUDE.md file to avoid Windows command line length limit + # The SDK will read this via setting_sources=["project"] + claude_md_path = self.project_dir / "CLAUDE.md" + with open(claude_md_path, "w", encoding="utf-8") as f: + f.write(system_prompt) + logger.info(f"Wrote system prompt to {claude_md_path}") + # Create Claude SDK client with limited tools for spec creation # Use Opus for best quality spec generation # Use system Claude CLI to avoid bundled Bun runtime crash (exit code 3) on Windows @@ -167,7 +174,9 @@ class SpecChatSession: options=ClaudeAgentOptions( model="claude-opus-4-5-20251101", cli_path=system_cli, - system_prompt=system_prompt, + # System prompt loaded from CLAUDE.md via setting_sources + # This avoids Windows command line length limit (~8191 chars) + setting_sources=["project"], allowed_tools=[ "Read", "Write",