Skip to content

Creating a new Project in Windows under DOS results in Failed to intialize Claude Error #8

Description

@freewarefocus

When creating a new project under Windows you will get a "Failed to initialize Claude: Command failed with exit code 1 (exit code: 1) Error output: Check stderr output for details" error message. In the command line you get a "The command line is too long." message, which is accurate. Windows cannot accept the long prompt being passed to Claude on the command line (the DOS command line limit is like 8k characters).

A suggested possible long term fix is to modify server/services/spec_chat_session.py to pass the prompt to Claude via the file parameter so it can be of any length.

Activity

  1. crocware commented on Jan 8, 2026

    @crocware

    I have the same error on Windows. I was unable to do anything meaningful after the exit code 1 error.

  2. AMSumo9 commented on Jan 8, 2026

    @AMSumo9

    I can't code AT ALL but Claude Code helped me fix this as follows. It got me into the spec chat......

    Fix: Spec creation fails on Windows with "command line is too long" error

    Problem:
    On Windows, creating a new project with Claude spec creation fails immediately with:

    The command line is too long.
    Fatal error in message reader: Command failed with exit code 1
    Failed to initialize Claude: ProcessError
    Cause:
    Windows has a ~8191 character limit for command-line arguments. The ClaudeSDKClient passes system_prompt via CLI args. In spec_chat_session.py, the entire create-spec.md skill file (~10KB+) was being passed as system_prompt, exceeding this limit.

    Linux/macOS aren't affected (they have ~2MB limits).

    Fix:

    Use a minimal system_prompt for client initialisation (stays under Windows limit)
    Send the full skill instructions as the first message via query() (stdin has no size limit)
    Files changed:

    server/services/spec_chat_session.py - Main fix
    client.py - Added documentation about the pattern for future reference

    Here's the detailed code changes:

    File 1: server/services/spec_chat_session.py
    Before (lines 141-167):

    project_path = str(self.project_dir.resolve())
    system_prompt = skill_content.replace("$ARGUMENTS", project_path)

    Create Claude SDK client...

    self.client = ClaudeSDKClient(
    options=ClaudeAgentOptions(
    model="claude-opus-4-5-20251101",
    cli_path=system_cli,
    system_prompt=system_prompt, # <-- PROBLEM: full skill file here
    ...
    )
    )

    Start the conversation

    async for chunk in self._query_claude("Begin the spec creation process."):
    yield chunk
    After:

    project_path = str(self.project_dir.resolve())

    Windows has ~8191 char limit for command-line arguments. The full skill content

    passed as system_prompt exceeds this. Solution: use minimal system prompt for

    initialization, then send full instructions as first message via stdin (no limit).

    minimal_system_prompt = "You are an expert software architect helping create application specifications."
    full_skill_instructions = skill_content.replace("$ARGUMENTS", project_path)

    Create Claude SDK client...

    self.client = ClaudeSDKClient(
    options=ClaudeAgentOptions(
    model="claude-opus-4-5-20251101",
    cli_path=system_cli,
    system_prompt=minimal_system_prompt, # <-- FIX: minimal prompt
    ...
    )
    )

    Start the conversation:

    1. Send full skill instructions as first message (via stdin - no size limit)

    2. Then begin the spec creation process

    async for _ in self._query_claude(full_skill_instructions):
    pass # Consume but don't forward - this is just context setting

    async for chunk in self._query_claude("Begin the spec creation process."):
    yield chunk
    File 2: client.py (documentation only)
    Added this header comment:

    """
    IMPORTANT - Windows Command-Line Limit:

    Windows has ~8191 character limit for command-line arguments. The ClaudeSDKClient
    passes system_prompt via CLI args, so keep system_prompt SHORT (<2000 chars).

    If you need to pass large instructions (e.g., skill files), use this pattern:

    1. Use a minimal system_prompt for initialization
    2. Send full instructions as the first message via query() (stdin has no limit)

    See spec_chat_session.py for an example of this pattern.
    """

  3. CoreAspectStu commented on Jan 12, 2026

    @CoreAspectStu

    before i saw this i also resolved in a similar way, here is my resolution in the community: https://www.skool.com/agentic-labs/autocoder-issue-with-windows?p=bd572de3

    You are fixing:

    • A Windows-only process spawn limitation
    • That the upstream SDK currently does not fully handle

    Find this file: subprocess_cli.py
    structure \autocoder\venv\Lib\site-packages\claude_agent_sdk_internal\transport

    autocoder/
    ├─ vendor/
    │  └─ claude_agent_sdk/
    │     └─ _internal/
    │        └─ transport/
    │           └─ subprocess_cli.py   ← patched
    

    replace with the attached file and try again to run the start_ui.bat file.

    subprocess_cli.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions