Does delegating work to `claude -p` subprocesses reduce context accumulation in the parent session?

Resolved 💬 1 comment Opened May 28, 2026 by mg1986jp Closed Jun 29, 2026

I've been using a pattern where instead of having Claude Code do everything directly, I delegate heavy subtasks to claude -p subprocesses (either directly or via a Python orchestrator script).

Pattern A (direct):
  user → Claude Code → does all file reads, searches, analysis
  → context grows fast → auto compact kicks in → loses earlier instructions

Pattern B (delegated):
  user → Claude Code → claude -p subprocess (heavy research/analysis)
  → parent only receives final stdout → context stays lean

My hypothesis is that Pattern B delays auto compaction in the parent session because:

  • claude -p runs in its own isolated context window
  • All intermediate tool calls (file reads, searches, reasoning) stay inside the subprocess
  • The parent session only sees the final output, so its context accumulates much slower

Questions:

  1. Is this understanding correct — does claude -p run in a completely separate context window from the parent?
  2. If so, is this a recommended pattern for long-running or large tasks where context pressure is a concern?
  3. Are there any gotchas beyond "if the subprocess returns a huge output, the parent context still grows"?

For context, I'm considering this for a workflow that processes a large batch of customer support tickets — a Python script iterates through each ticket, calls claude -p to generate a draft response, then the script handles validation and posting. The parent Claude Code session would just monitor the script execution.

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗