A\
Lessons/Domain 3
3.412 min

Determine when to use plan mode vs direct execution

Choosing plan mode versus direct execution is a routing decision that protects production codebases from costly rework. Plan mode gives Claude Code a read-only exploration-and-design phase with an approval gate before any change lands, while direct execution moves straight to editing for changes whose scope is already understood. Picking the wrong mode either wastes turns on trivial fixes or lets large architectural work make premature, hard-to-unwind edits.

Plan mode vs direct executionNew task arrivesArchitectural choices,many files, or multiplevalid approaches?YESNOPlan mode (read-only)Shift+Tab or --permission-mode planExplore, design, then ExitPlanModeApprove, then execute the plane.g. monolith to microservices,45+ file library migrationDirect executionScope known and localizedEdit and run in one flowe.g. single-file bug fix from aclear stack trace, add a validationTip: during plan-mode exploration, dispatch Explore subagents to isolate verbose discovery and return summaries.
Decision flow for routing a task to plan mode or direct execution, with the Explore subagent shown as a context-preservation aid during exploration.

What plan mode actually does

Plan mode is a Claude Code operating mode that restricts the agent to read-only actions, reading files, searching with Grep and Glob, and reasoning, while it explores the codebase and drafts an implementation plan. It cannot edit files or run state-changing commands until you approve.

You enter it interactively by pressing Shift+Tab to cycle permission modes (normal, auto-accept edits, plan mode), or non-interactively with claude --permission-mode plan. When Claude has a plan, it calls the ExitPlanMode tool to present it, and execution only begins after you approve. This approval gate is the entire point: exploration and design happen with zero risk of premature changes.

Contrast this with direct execution, the default mode, where Claude reads, edits, and runs commands in one continuous flow. Direct execution is faster for work you already understand but offers no design checkpoint before changes land.

When to choose plan mode

Plan mode is designed for complex tasks: large-scale changes, multiple valid approaches, architectural decisions, and multi-file modifications. The strongest signals are architectural implications (service boundaries, module dependencies), migrations that touch many files (a library migration affecting 45+ files), or choosing between integration approaches that carry different infrastructure requirements.

The core benefit is safe codebase exploration and design before committing to changes, which prevents costly rework when a dependency or constraint is discovered late. If you cannot yet describe the exact edits, or several reasonable designs exist, that uncertainty is itself the trigger for plan mode.

When direct execution wins

Direct execution is appropriate for simple, well-scoped changes where the path is already clear: a single-file bug fix with a clear stack trace, or adding a date-validation conditional to one function. Forcing plan mode onto work like this only adds round trips and latency with no design benefit.

A useful rule of thumb: if you can state the exact change and it lives in one place, execute directly. The cost of plan mode is real, an extra approval cycle and more turns, so reserve it for tasks where the design is genuinely in question.

Combine plan mode and direct execution

The two modes are not mutually exclusive across a single task. A common and recommended pattern is to use plan mode for the investigation and design phase, get the plan approved, then switch to direct execution to implement it.

For example, plan a library migration first (compatibility shims, call-site updates, rollout order), then execute the planned approach directly. The planning phase absorbs the uncertainty, and the execution phase runs fast because the scope and approach are now settled.

The Explore subagent for context preservation

The Explore subagent is a read-only discovery subagent invoked via the Task tool. It runs verbose exploration in an isolated context and returns only a summary to the main conversation, which prevents context window exhaustion during multi-phase tasks.

Distinguish it from plan mode. Plan mode is an approval gate on the main agent, whereas the Explore subagent is a context-isolation technique. They compose well: during a plan-mode investigation you can dispatch Explore subagents so that raw file dumps and dependency traces never pollute the main context, keeping the main agent focused on high-level design.

A decision framework and common traps

Ask two questions. Is the scope known and localized to one place? If yes, execute directly. Does the task involve architectural decisions, many files, or competing valid approaches? If yes, use plan mode.

Do not defer the mode decision. Complexity that is already stated in the requirements is enough to justify plan mode upfront. The trap of beginning in direct execution and switching to plan mode only if complexity emerges fails because, by the time complexity surfaces, you may already have made edits that need reverting.

Anti-patterns to avoid

avoid
Diving straight into direct execution for a monolith-to-microservices restructuring or a 45+ file library migration.

Why it fails: Dependencies and service boundaries surface late, forcing costly rework and leaving half-finished edits scattered across the tree.

instead Enter plan mode first to explore dependencies and design the approach, get the plan approved, then switch to direct execution to implement it.

avoid
Using plan mode for a trivial, well-scoped change like adding one validation conditional.

Why it fails: The approval gate adds latency and extra turns with no design value when the change is obvious and confined to one file.

instead Use direct execution for single-file, clearly scoped fixes such as a bug with a clear stack trace.

avoid
Beginning in direct execution and planning to switch to plan mode only if unexpected complexity appears.

Why it fails: When architectural implications are already stated in the requirements, the complexity is not hypothetical, and by the time it emerges you may have already made changes that must be reverted.

instead Select plan mode upfront whenever the task description itself signals architectural or multi-file scope.

avoid
Reading every file into the main conversation during a large exploration to build understanding.

Why it fails: Verbose tool output accumulates and exhausts the context window, degrading the model's answers later in the session.

instead Dispatch Explore subagents that perform the verbose discovery in isolation and return concise summaries to the main agent.

Worked example: Restructuring a monolith into microservices with Claude Code

You are on the team from the Code Generation with Claude Code scenario and get assigned to break a monolithic application into microservices. The change spans dozens of files and hinges on decisions about service boundaries and module dependencies. This is a textbook plan-mode task: architectural implications, multiple valid decompositions, and broad multi-file impact.

Step 1, enter plan mode. Press Shift+Tab until the mode indicator shows plan mode, or launch claude --permission-mode plan. Claude is now read-only: it can Grep for imports, Read modules, and map the dependency graph, but it cannot edit anything yet.

Step 2, explore without flooding context. The dependency mapping is verbose. Dispatch Explore subagents for the noisy parts, for example "trace every import of the billing module" and "list all files that touch the shared User model". Each returns a concise summary, so raw file dumps never fill the main window.

Step 3, review the plan. Claude proposes service boundaries, a migration order, and the interfaces between services, then calls ExitPlanMode. You inspect it. If the boundaries look wrong, you refine while still in plan mode. No code has changed, so iterating is essentially free.

Step 4, approve, then switch to direct execution. Once the plan is sound, approve it. Now direct execution is correct: the scope is understood and the approach is decided, so Claude edits files and runs commands to implement the approved plan.

The same pattern fits a library migration affecting 45+ files: plan the migration first, then execute it directly. Contrast this with a one-line date-validation fix from a clear stack trace, where you skip planning entirely and execute immediately.

Exam tips

  • Plan mode is read-only exploration plus design behind an approval gate. Enter it with Shift+Tab or `claude --permission-mode plan`, and Claude presents its plan via the ExitPlanMode tool before any change is made.
  • Choose plan mode for architectural decisions, multiple valid approaches, and multi-file or large-scale changes (monolith-to-microservices, a 45+ file library migration).
  • Choose direct execution for simple, well-scoped changes: a single-file bug fix with a clear stack trace, or adding a date validation conditional.
  • Combine the modes: use plan mode for investigation and design, then direct execution to implement the approved plan.
  • The Explore subagent isolates verbose discovery and returns summaries to preserve main context. It is a context technique, not a substitute for plan mode's approval gate.
  • Distractor watch: 'start in direct execution and switch to plan mode only if complexity emerges' is wrong when the requirements already state architectural or multi-file scope.
Official exam objectives for 3.4
Knowledge of
  • Plan mode is designed for complex tasks involving large-scale changes, multiple valid approaches, architectural decisions, and multi-file modifications
  • Direct execution is appropriate for simple, well-scoped changes (e.g., adding a single validation check to one function)
  • Plan mode enables safe codebase exploration and design before committing to changes, preventing costly rework
  • The Explore subagent for isolating verbose discovery output and returning summaries to preserve main conversation context
Skills in
  • Selecting plan mode for tasks with architectural implications (e.g., microservice restructuring, library migrations affecting 45+ files, choosing between integration approaches with different infrastructure requirements)
  • Selecting direct execution for well-understood changes with clear scope (e.g., a single-file bug fix with a clear stack trace, adding a date validation conditional)
  • Using the Explore subagent for verbose discovery phases to prevent context window exhaustion during multi-phase tasks
  • Combining plan mode for investigation with direct execution for implementation (e.g., planning a library migration, then executing the planned approach)

Flashcards from this lesson

How do you enter plan mode in Claude Code?

Press Shift+Tab to cycle permission modes, or start with claude --permission-mode plan. Claude presents its plan via the ExitPlanMode tool and waits for approval before making any change.

What kinds of tasks call for plan mode?

Complex ones: large-scale or multi-file changes, multiple valid approaches, and architectural decisions, such as monolith-to-microservices restructuring or a 45+ file library migration.

Can plan mode and direct execution be combined?

Yes. Use plan mode to investigate and design, get the plan approved, then switch to direct execution to implement it.

Why is 'start direct, switch to plan mode if complexity emerges' a trap?

If the requirements already state architectural or multi-file scope, the complexity is known now. Deferring risks premature changes and costly rework.

What does the Explore subagent do?

It runs verbose, read-only discovery in an isolated context and returns only a summary, preventing context window exhaustion during multi-phase tasks.

When is direct execution the right call?

For simple, well-scoped changes with a clear path, like a single-file bug fix from a clear stack trace or adding one validation conditional.

Study all flashcards with spaced repetition