[FEATURE] Add --ephemeral flag to prevent saving conversation history in programmatic mode

Resolved 💬 6 comments Opened Nov 17, 2025 by PaulRBerg Closed Jan 19, 2026

Preflight Checklist

  • [x] I have searched existing requests and this feature hasn't been requested yet
  • [x] This is a single feature request (not multiple features)

Problem Statement

When running Claude Code programmatically with claude -p "Something", a conversation history is always created as a .jsonl file. This conversation then appears when running claude --resume, cluttering the conversation history with automated/scripted runs.

For CI/CD pipelines, automated scripts, and one-off programmatic queries, these ephemeral conversations should not persist in the resume history. Currently, there's no way to prevent this behavior.

Proposed Solution

Add an --ephemeral flag that prevents conversation history from being saved to disk.

Example usage:

# One-off programmatic query - no history saved
claude -p --ephemeral "Analyze this log file" < logs.txt

# CI/CD pipeline - don't clutter history
claude -p --ephemeral "Run linting and fix issues" --output-format json

The flag should:

  1. Skip creating the .jsonl conversation file
  2. Prevent the session from appearing in claude --resume
  3. Skip background conversation summarization jobs
[!NOTE] This flag should only work with --print mode since interactive sessions inherently expect persistence.

<details>
<summary><strong>Alternative Solutions</strong></summary>

Current workarounds:

  1. Post-execution cleanup: Parse session_id from JSON output and manually delete the .jsonl file
  • Brittle and requires knowing the file location
  • May conflict with background summarization jobs

Alternatives considered:

  1. Environment variable: CLAUDE_EPHEMERAL=1 - less discoverable than a CLI flag
  2. Auto-cleanup after N days - doesn't solve the immediate clutter problem

</details>

Priority

High - Significant impact on productivity

Feature Category

CLI commands and flags

Use Case Example

CI/CD Pipeline:

# In GitHub Actions workflow
claude -p --ephemeral "Review PR for security issues" \
  --output-format json --allowedTools Read,Grep > review.json

Automated Monitoring:

# Runs every hour via cron - would create 24+ conversations/day
echo "$logs" | claude -p --ephemeral "Detect anomalies" --output-format json

Quick Development Queries:

claude -p --ephemeral "Explain this error" < error.log

<details>
<summary><strong>Additional Context</strong></summary>

Related documentation:

Similar features in other tools:

  • Docker: docker run --rm (ephemeral containers)
  • Git: git commit --no-verify (skip hooks)

Implementation considerations:

  • Should be mutually exclusive with --continue and --resume
  • Should work with all output formats (text, json, stream-json)

</details>

View original on GitHub ↗

This issue has 6 comments on GitHub. Read the full discussion on GitHub ↗