Skip to content

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Aug 1, 2025

Fixes #6534

Problem

Users were experiencing "Command failed with exit code 1: claude -p --system-prompt" errors when using the Claude Code provider. The issue was that the Claude CLI was failing when the --system-prompt flag was passed as a command-line argument on non-Windows systems.

Solution

  • Removed the --system-prompt command line argument for all platforms
  • Now passing both system prompt and messages together via stdin (unified behavior across all platforms)
  • This approach was already being used for Windows to avoid command line length limits
  • Updated tests to reflect the unified stdin behavior

Testing

  • All existing tests pass
  • Modified test to verify that system prompt is passed via stdin for all platforms
  • No breaking changes to the API

Impact

This fix resolves the error that was preventing users from using the Claude Code provider when it would try to pass the system prompt as a command line flag.


Important

Fixes Claude CLI error by passing system prompt via stdin instead of command line argument, ensuring consistent behavior across platforms.

  • Behavior:
    • Removed --system-prompt command line argument in run.ts.
    • Pass system prompt and messages via stdin for all platforms in runProcess().
    • Unified behavior across platforms, previously only used for Windows.
  • Testing:
    • Updated test in run.spec.ts to verify stdin behavior for all platforms.
    • Ensures --system-prompt is not in args and stdin receives correct data.
  • Error Handling:
    • Handles ENOENT errors with enhanced messages in run.ts.
    • Logs errors when writing to stdin fails and kills the process.

This description was created by Ellipsis for 5ed7692. You can customize this summary. It will automatically update as commits are pushed.

- Remove --system-prompt command line argument for all platforms
- Pass system prompt and messages together via stdin (like Windows)
- Update tests to reflect unified stdin behavior across platforms
- Fixes #6534 where Claude CLI was failing with exit code 1
@roomote roomote bot requested review from cte, jr and mrubens as code owners August 1, 2025 03:29
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. bug Something isn't working labels Aug 1, 2025
@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Aug 1, 2025
Copy link
Contributor Author

@roomote roomote bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewing my own code is like debugging in production - technically possible but morally questionable. I've reviewed the changes and left some suggestions inline to improve clarity and maintainability.

const isWindows = os.platform() === "win32"

// Build args based on platform
// Build args - no longer passing system prompt as command line argument
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment could be more descriptive about why we're making this change. Consider:

This would help future maintainers understand the reasoning behind this architectural decision.

} else {
stdinData = JSON.stringify(messages)
}
// Pass both system prompt and messages via stdin for all platforms
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two comment lines could be consolidated for brevity:

}

// On Windows, should NOT have --system-prompt in args
// Should NOT have --system-prompt in args
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment references Windows-specific behavior that no longer exists. Could we update it to reflect the unified behavior?

}

// On non-Windows, should have --system-prompt in args
// Should NOT have --system-prompt in args (same behavior for all platforms now)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here - this comment still mentions platform differences that we've eliminated. Consider:

@daniel-lxs
Copy link
Member

Not a proper fix, issue is not scoped

@daniel-lxs daniel-lxs closed this Aug 2, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Aug 2, 2025
@github-project-automation github-project-automation bot moved this from Triage to Done in Roo Code Roadmap Aug 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. size:M This PR changes 30-99 lines, ignoring generated files.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Command failed with exit code 1: claude -p --system-prompt

4 participants