Repository navigation
Conversation
…pt-file
Windows limits command lines to ~8191 characters, so passing the
create-spec/expand-project skills as a --system-prompt argument fails
with "The command line is too long." and surfaces in the UI as
"Failed to initialize Claude: Command failed with exit code 1".
Spec, expand and assistant chat sessions now write their system prompt
to a unique, gitignored .autoforge/.system_prompt.<kind>.<uuid>.md file
and pass it as system_prompt={"type": "file", ...}, which the SDK
forwards as --system-prompt-file. The file is removed when the session
closes.
This also replaces the previous workaround of overwriting the project's
CLAUDE.md with the spec/assistant prompt, which clobbered any real
project CLAUDE.md the coding agent relies on.
Bumps claude-agent-sdk to >=0.1.51 (first release with SystemPromptFile).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
🔍 QA report: ✅ PassedTester: Ken (cubefarm agent, in a fresh session) · Round: 1 · Author: Barbara The PR fixes issue #8: spec, expand and assistant chat sessions now write their system prompt to a gitignored .autoforge/.system_prompt...md file and pass it with --system-prompt-file, and no longer overwrite the project's CLAUDE.md. I built the real SDK command for each session (no API calls). It contains --system-prompt-file, no long prompt argument, and is 545 to 1411 characters long (prompts up to 21 KB), well below Windows' 8191 limit. Each prompt file is deleted on close(), and a user's own CLAUDE.md is left unchanged. ruff, mypy (same 24 errors as master), pytest (only the 21 test_devserver_security failures master already has), UI lint and build, server boot, REST and WebSocket checks, and a browser smoke test all pass.
🧪 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 new project failed with
Failed to initialize Claude: Command failed with exit code 1. The console showedThe command line is too long.A plain-stringsystem_promptis passed to the Claude CLI as a--system-prompt <text>argument. Windows caps command lines at about 8191 characters, andcreate-spec.mdalone is about 20 KB.There was a partial workaround in master: spec and assistant chats wrote their prompt into the project's
CLAUDE.mdand loaded it viasetting_sources. That overwrote any real projectCLAUDE.mdthe coding agent relies on. The expand-project chat still passed its about 6.6 KB prompt on the command line, and the extra MCP, tools and settings arguments push it close to the limit.Fix
As the issue suggests, the prompt is now passed through a file:
write_system_prompt_file()/remove_system_prompt_file()inserver/services/chat_constants.py. They write the prompt to a unique.autoforge/.system_prompt.<kind>.<uuid>.mdfile. The path comes from the newautoforge_paths.get_system_prompt_path(), and the pattern is added to the generated.autoforge/.gitignore.system_prompt={"type": "file", "path": ...}. The SDK turns that into--system-prompt-file <path>, so the command line stays short no matter how long the prompt is. Each session deletes its file inclose().CLAUDE.md. They keepsetting_sources, so a real projectCLAUDE.mdis still loaded as extra context.claude-agent-sdkraised from0.1.39to0.1.51inrequirements.txtandrequirements-prod.txt. I checked the wheels: 0.1.51 is the first release withSystemPromptFileand--system-prompt-file; 0.1.50 does not have it.Verification
test_system_prompt_file.py(3 tests). It checks that the file is written to.autoforge/, is gitignored, is unique per session and is removed on close, and thatCLAUDE.mdis not touched. It also builds the real SDK CLI command with a 20 KB prompt: the command contains--system-prompt-file, does not contain the prompt text, and is shorter than 8191 characters.SpecChatSession.start()on a fresh project dir. Claude replied with the create-spec Phase 1 greeting, which shows it read the prompt from the file. NoCLAUDE.mdwas created, and the temp file was gone afterclose().--system-prompt-file; a missing file givesSystem prompt file not found.ruff check .passes.mypy .shows the same 25 errors as master, none new.test_security.pyandtest_security_integration.pypass.test_client.pypasses.test_devserver_security.pyhas 21 failures, and master has the same 21, so they are not caused by this change.Assumptions / notes
CLAUDE.mdwas already overwritten by the old workaround keep that file. I did not auto-delete it, because I can't reliably tell it apart from a file the user wrote.--system-prompt-fileas a full replacement prompt. Before, the spec prompt was loaded asCLAUDE.mdcontext on top of an empty system prompt, so the effective behaviour is the same.arkaccess/autoforgefork, because the bot account only has read access to upstream.🤖 Generated with Claude Code