Skip to content

[Feature Request] Add --plan-file and --plan-only flags for non-interactive planning mode #16571

@jgoerner

Description

@jgoerner

Bug Description
Feature Request: Non-Interactive Planning Mode Enhancements

Problem Statement

When running Claude Code in planning mode (--permission-mode plan) with the -p flag for non-interactive/headless execution, the CLI still prompts for user approval before proceeding. This blocks automation workflows and background job usage.

Additionally, plan files are written to ~/.claude/plan/.md with no way to specify a custom location, making it difficult to programmatically retrieve the generated plan.

Proposed Solution

Add the following CLI flags:

Flag Description
--plan-file Specify custom output path for the plan file
--plan-only Generate plan and exit without prompting for approval

Example Usage

Generate plan to specific file and exit

claude --permission-mode plan
-p "Create migration plan for OAuth"
--plan-file ./plans/oauth-migration.md
--plan-only

Use in CI/scripts

claude --permission-mode plan
-p "$(cat requirements.md)"
--plan-file /tmp/plan.md
--plan-only && cat /tmp/plan.md

Use Cases

  1. Background jobs - Generate plans overnight for review next morning
  2. CI pipelines - Auto-generate implementation plans from issue descriptions
  3. Batch processing - Queue multiple planning requests
  4. Documentation - Automatically save plans to project directories
  5. Review workflows - Generate plans for team review before execution

Current Workarounds

  • Watching ~/.claude/plan/ for new files (brittle, race conditions)
  • Using --max-turns to limit execution (doesn't guarantee clean exit)
  • Symlinking the plan directory (doesn't solve the approval prompt)

Additional Context

The -p flag successfully enables non-interactive mode for normal operations, so extending this to planning mode would be consistent with existing CLI behavior.

Environment Info

  • Platform: darwin
  • Terminal: tmux
  • Version: 2.0.76
  • Feedback ID: 4f337205-7261-400a-b442-5bb9158e479f

Errors

[]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions