Repository navigation
Fix #8: Pass chat session system prompts via --system-prompt-file (Windows cmdline limit) - #295
zwanski-start wants to merge 1 commit into
Conversation
…pt-file
Spec creation, project expansion and the assistant built long system
prompts (create-spec.md alone is ~20KB). Passing them inline exceeded
the Windows ~8191 character command line limit ("The command line is
too long"); the spec/assistant workaround of writing the prompt to the
project's CLAUDE.md clobbered the user's CLAUDE.md, and expand still
passed its prompt inline.
Write each prompt to a per-session .autoforge/.system_prompt.<kind>.<uuid>.md
file, hand it to the CLI via SystemPromptFile (--system-prompt-file),
and delete it when the session closes. Requires claude-agent-sdk>=0.1.51.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
🔍 QA report: ✅ PassedTester: Dennis (cubefarm agent, in a fresh session) · Round: 1 · Author: Ada Spec, expand and assistant chat sessions now write their system prompt to a per-session .autoforge/.system_prompt...md file and pass it via --system-prompt-file, so the CLI command line stays far below the ~8191-char Windows limit (1.4 KB measured) and the project's CLAUDE.md is no longer overwritten. Verified with the new tests plus an independent probe of the assistant session, confirmed --system-prompt-file first ships in SDK 0.1.51 (justifying the bumped minimum) and that the installed Claude CLI supports it. ruff, mypy and pytest show no regressions against master (the 21 test_devserver_security failures are identical on master), and the server and UI still boot and render cleanly. Not verified on a real Windows machine.
🧪 Commands run
No browser screenshots were taken in this round. Posted by cubefarm · merges automatically once GitHub's checks pass |
Closes #8
Problem
On Windows, creating a project failed with
Failed to initialize Claude: Command failed with exit code 1/The command line is too long.The chat sessions built long system prompts (create-spec.mdalone is ~20 KB) that ended up on the Claude CLI command line, which Windows caps at about 8191 characters.Current master had partly worked around this for spec creation and the assistant by writing the prompt into the project's
CLAUDE.md. That overwrote the user's ownCLAUDE.md, which the coding agents load. The expand-project session still passed its prompt inline with--system-prompt.Change
This follows the fix suggested in the issue: pass the prompt to Claude as a file.
chat_constants.write_system_prompt_file()writes each session's prompt to its own.autoforge/.system_prompt.<kind>.<uuid>.md.remove_system_prompt_file()deletes it when the session closes.system_prompt={"type": "file", "path": ...}. The SDK turns this into--system-prompt-file, so the command line stays short however long the prompt is.CLAUDE.md.autoforge_paths.get_system_prompt_path()builds the file path, and.system_prompt.*.mdis added to the generated.autoforge/.gitignore.claude-agent-sdkto>=0.1.51, the first version withSystemPromptFile(per the SDK changelog). Installed environments already pick up 0.1.81 under the existing<0.2.0cap.Verification
test_system_prompt_file.py(2 tests, both pass). It runs the spec and expand sessions with a stubbed SDK client, builds the real CLI command with the SDK'sSubprocessCLITransport, and checks that:--system-prompt-fileis used and--system-promptis not$ARGUMENTSreplacedCLAUDE.mdis not writtenclose()claude -p --system-prompt-file <18 KB file> --output-format stream-json --verbose(the mode the SDK uses) with CLI 2.1.303. The prompt was applied.ruff check .is clean.mypyshows the same errors before and after this change.test_security.py,test_client.py,test_dependency_resolver.py,test_rate_limit_utils.pyandtest_ws_security.pypass.test_devserver_security.pyhas 21 failures, and the same 21 fail on unmodified master, so they are unrelated to this change.Assumptions / notes
CLAUDE.mdwas already overwritten by an older spec or assistant session keep that file. The assistant still usessetting_sources=["project"], so it may see that old prompt as project context next to the real system prompt. That duplication is harmless, and this PR does not delete user files.🤖 Generated with Claude Code