Repository navigation
Fix #44: Pass chat system prompts via --system-prompt-file (Windows command line too long) - #316
zwanski-start wants to merge 1 commit into
Conversation
The expand-project session passed its ~6.6KB system prompt inline as a
CLI argument, pushing the command line past the Windows ~8191 char
limit ("The command line is too long."). The assistant and spec
sessions avoided this by overwriting the project's CLAUDE.md, which
clobbered user content and leaked chat-only instructions (e.g. the
assistant's "never implement code") into the coding agents, which load
CLAUDE.md via setting_sources=["project"].
All three chat sessions now write their prompt to a per-session file
in .autoforge/ (gitignored) and pass it with the SDK's file system
prompt option (--system-prompt-file), deleting it on close. Requires
claude-agent-sdk >= 0.1.51.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
🔍 QA report: ✅ PassedTester: Ken (cubefarm agent, in a fresh session) · Round: 1 · Author: Guido Assistant, spec and expand chat sessions now hand their system prompt to the Claude CLI via
🧪 Commands run
No browser screenshots were taken in this round. Posted by cubefarm · merges automatically once GitHub's checks pass |
… (Windows command line too long) Adaptations: port remove_legacy_claude_md and its prompt-prefix list from AutoForgeAI#307 and call it from write_system_prompt_file, so a CLAUDE.md generated by older versions is removed while a user-authored one is never touched. Keep my-features' requirements pins (claude-agent-sdk>=0.1.81, mcp<2). New test_chat_claude_md.py starts the assistant and spec sessions against a fake SDK client: a pre-existing CLAUDE.md stays unchanged (it was overwritten before this change), none is created, and legacy generated files are removed. Integrates AutoForgeAI#316 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AeH26pcsqoxPb3CDs8g1VN
…l the model why Adaptations: with AutoForgeAI#316 in place the spec and expand prompts reach the CLI through the session's ephemeral --system-prompt-file, so the 'no Bash/shell tool' note stays scoped to that conversation and never lands in a CLAUDE.md the coding agents read. The PR's tests now read the note from the system prompt file and assert that no CLAUDE.md is created (they asserted claude_md.endswith(NO_SHELL_PROMPT_NOTE)). Integrates AutoForgeAI#298 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AeH26pcsqoxPb3CDs8g1VN
…ct (AutoForgeAI#133) Adaptation: kept my-features' _system_prompt_file (system prompt via --system-prompt-file, AutoForgeAI#316) next to the new query lock in AssistantChatSession. Integrates AutoForgeAI#332 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AeH26pcsqoxPb3CDs8g1VN
…features Adaptations (plan Change 4.9, combined with my-features import): onboard mode and its spec-only write hook taken; 'passes': true is accepted by feature_create_bulk only when the feature MCP server runs with AUTOFORGE_ONBOARD_SESSION=1, which only the onboarding session sets (user decision 1A; initializer, assistant and expand sessions get an error). Onboarding refuses a symlinked app_spec.txt and the hook compares against the symlink-free path at write time. Kept my-features' features_created parsing (Phase 1) instead of the PR's second counter, the system-prompt file (AutoForgeAI#316) and web tools; onboard mode gets its own tools note. Not taken: NewProjectModal changes and the mcp requirement pin. Our import wizard offers 'Analyze with AI' for plain codebases: it registers the folder and opens the onboarding chat. Integrates AutoForgeAI#303 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AeH26pcsqoxPb3CDs8g1VN
Closes #44
Problem
On Windows,
claudeis a.cmdshim, so the whole command goes through cmd.exe and its ~8191 character limit. Two separate problems came from how the chat sessions passed their system prompts:expand-project.md, about 6.6KB, plus the project path) inline as--system-prompt. With the other arguments (--mcp-configJSON, tool lists, settings path), that goes over the limit and fails with "The command line is too long."CLAUDE.mdwith the chat prompt. That deletes whatever the user had inCLAUDE.md. It also leaks the chat-only instructions into the coding agents, which loadCLAUDE.mdviasetting_sources=["project"](for example, the assistant's "You must NEVER implement code").Fix
server/services/chat_constants.py:write_system_prompt_file()writes the prompt to a per-session file,.autoforge/.system_prompt.<kind>.<uuid>.md.remove_system_prompt_file()deletes it.system_prompt={"type": "file", "path": ...}, which the SDK sends as--system-prompt-file <path>. Each session deletes its file inclose().CLAUDE.mdany more. The assistant and spec sessions still usesetting_sources, so the project's realCLAUDE.mdis now read as context instead of being overwritten.get_system_prompt_path()toautoforge_paths.py, and added.system_prompt.*.mdto the.autoforge/.gitignoretemplate.claude-agent-sdkto0.1.51, the first release that supports the file system prompt option. I checked this by comparing the 0.1.50 and 0.1.51 wheels.Verification
CLAUDE.mdis left untouched.claudeCLI: started anAssistantChatSessionand asked "what is your role / which project". It answered "I'm the project assistant and backlog manager for the "demo" project…", so the CLI reads the prompt from the file.test_chat_system_prompt.py(4 tests) passes.ruff check .,test_security.py,test_client.pyandtest_ws_security.pyalso pass.mypy .shows no new errors. The diff against master is only line-number shifts of the existingunused-ignorewarnings.Assumptions / notes
CLAUDE.mdfiles older versions already overwrote, so this PR doesn't try to restore them. Users who see an assistant or create-spec prompt in their project'sCLAUDE.mdshould delete it or restore it from git.🤖 Generated with Claude Code