Skip to content

feat(claude): forward --system-prompt / --append-system-prompt via ACP _meta [AI-assisted]#229

Open
Vercantez wants to merge 1 commit intoopenclaw:mainfrom
Vercantez:feat/claude-system-prompt-meta
Open

feat(claude): forward --system-prompt / --append-system-prompt via ACP _meta [AI-assisted]#229
Vercantez wants to merge 1 commit intoopenclaw:mainfrom
Vercantez:feat/claude-system-prompt-meta

Conversation

@Vercantez
Copy link
Copy Markdown

@Vercantez Vercantez commented Apr 7, 2026

Summary

Adds two global CLI flags that forward through to claude-agent-acp via the ACP _meta.systemPrompt field that landed in agentclientprotocol/claude-agent-acp#91:

  • --system-prompt <text> — replace the Claude Code system prompt entirely
  • --append-system-prompt <text> — append to the default Claude Code system prompt

Both are mutually exclusive and validated at flag-resolve time. The option is persisted in session_options.system_prompt so acpx claude sessions ensure / reuse flows keep the override across turns, and is emitted alongside the existing claudeCode.options in _meta on session/new:

// --system-prompt "..."
{ "_meta": { "systemPrompt": "you are an obsidian assistant" } }

// --append-system-prompt "..." --model sonnet
{
  "_meta": {
    "claudeCode": { "options": { "model": "sonnet" } },
    "systemPrompt": { "append": "always speak in spanish" }
  }
}

Codex and other adapters ignore the field, so this is safe to keep as a global flag rather than a claude-specific one, matching how --model / --allowed-tools are already handled.

Why

Today there is no way to pass a system prompt override through acpx into Claude Code: acpx drives claude-agent-acp over ACP rather than forwarding unknown args to the claude binary, so --system-prompt / --append-system-prompt on the underlying CLI are unreachable. claude-agent-acp has supported _meta.systemPrompt (string = replace, {append} = append) since PR #91, so this is purely an acpx-side plumbing gap.

Changes

  • SessionAgentOptions / AcpClientOptions.sessionOptions gain a systemPrompt?: string | { append: string } field; the persisted shape is session_options.system_prompt (snake_case, passes lint:persisted-key-casing).
  • buildClaudeCodeOptionsMeta lifts systemPrompt to the top level of _meta (not nested under claudeCode.options), matching the claude-agent-acp parser.
  • New resolveSystemPromptFlag helper enforces mutual exclusion and returns the correct union shape.
  • Persistence round-trips the field through conversation-model, persistence/parse, session-management, and mode-preference.
  • All three sessionOptions construction sites in command-handlers.ts (runOnce, sessions new, sessions ensure) now forward the flag.

Tests

  • pnpm check passes locally (format, typecheck, oxlint, build, viewer typecheck/build, test:coverage): 528 / 528 tests pass.
  • New unit tests:
    • test/client.test.tsAcpClient createSession emits _meta.systemPrompt as a string, and emits { append } alongside claudeCode.options.
    • test/cli-flags.test.tsresolveSystemPromptFlag string/append/none/mutual-exclusion cases.
    • test/session-persistence.test.tslistSessions round-trips both the string and the { append } shapes through session_options.system_prompt.
  • Live end-to-end against @anthropic-ai/claude-code@2.1.92 + @agentclientprotocol/claude-agent-acp:
    • acpx --system-prompt "...respond with EXACTLY SP_OVERRIDE_TOKEN_42..." claude exec "say hi" → returns exactly SP_OVERRIDE_TOKEN_42, confirming the replace path.
    • acpx --append-system-prompt "...always include APPEND_TOKEN_99..." claude exec "What is 2+2?" → returns 4 followed by APPEND_TOKEN_99, confirming the append path.
    • Passing both flags errors with Use only one of --system-prompt or --append-system-prompt.

Test plan

  • pnpm check
  • Live verification against claude-agent-acp for both replace and append
  • Mutual exclusion guard exercised
  • Reviewer sanity check that top-level _meta.systemPrompt is the shape they want vs. nesting under claudeCode

AI-assisted PR

Per CONTRIBUTING.md:

  • Marked AI-assisted in the title
  • Fully tested (unit tests + live e2e against real claude-agent-acp)
  • I understand what the code does and will own any review follow-through

…P _meta

Adds global flags --system-prompt <text> and --append-system-prompt <text>
that forward through ACP session/new _meta.systemPrompt, using the shape
landed in agentclientprotocol/claude-agent-acp#91:

  _meta.systemPrompt = "..."                 # replace
  _meta.systemPrompt = { append: "..." }     # append

The value is persisted in session_options.system_prompt so
acpx claude sessions ensure / reuse flows keep the override, and rides
alongside the existing claudeCode options in _meta. Codex and other
agents ignore the field.

Mutual exclusion between the two flags is enforced at resolve time.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant