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 <noreply@anthropic.com>
This commit is contained in:
Auto
2026-01-12 14:39:50 +02:00
parent 9816621e99
commit 07c2010d32
2 changed files with 20 additions and 2 deletions

View File

@@ -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",

View File

@@ -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",