Skip to content

Feature: switch CC invocation from claude -p to claude --resume #42

@Rustam-Z

Description

@Rustam-Z

Summary

The harness currently invokes CC in single-shot print mode (claude -p "<prompt>") — a fresh process per turn that receives the entire context as input. Switch to claude --resume so each turn continues an existing CC session instead of starting a new one.

Why

  • Token cost. -p resends the full conversation history on every turn (system prompt, project prompt, prior <msg> envelopes, prior tool I/O). With --resume, CC maintains its own session, so each turn only sends the new inbound message + tool results. Especially significant for long-running chats and the daily self-reflection skill.
  • Latency. Less to send / parse on each turn → faster first-token.
  • Cache hit rate. --resume keeps the prompt cache warm across turns; -p rebuilds prompt-prefix every time. The Anthropic cache TTL is 5 minutes — --resume actually benefits from it, -p rarely does.
  • Natural memory model. Working context lives inside CC's session, not reassembled by the harness each turn.

Trade-offs / risks

Suggested implementation steps

  1. Start a CC session at harness boot with the system + project prompt. Persist the session ID to disk.
  2. Per turn: invoke claude --resume <session_id> with just the new inbound <msg> envelope(s). Stream tool calls + replies as usual.
  3. On wedge detection (Encoded prompt injections (base64, Morse) crash Claude Code sessions #39) or /pause+/resume (Feature: /pause and /resume slash commands #41), tear down the session and spin a new one.
  4. Add a CLI knob to opt back into -p mode for debugging.

Severity

Feature, but high leverage — touches cost, latency, and the foundation that #39 / #40 / #41 build on. Worth treating as a small redesign, not a one-line patch.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions