Determine when to use plan mode vs direct execution
Learning objectives
Choose a workflow based on uncertainty and consequences, produce an actionable plan for architectural changes, and transition to implementation with clear authority and validation. Use isolated exploration when its findings can be returned as a focused report.
Assess uncertainty before choosing the mode
Plan mode separates investigation and design from implementation. It is useful when the task has several credible approaches, dependencies across files, architectural trade-offs, or expensive reversal. A library migration, service-boundary redesign, or change to shared persistence behavior deserves investigation before edits.
File count is a useful clue, not a decision rule. A migration affecting 45 files may have mechanical edits but still require compatibility analysis. A one-line authorization change can have substantial consequences. Assess what is unknown, what can break, and what evidence would justify the proposed approach.
Direct execution suits a well-understood change with a clear target, an agreed behavior, and a proportionate check. It still includes reading the relevant code, making the change under effective permissions, and verifying the result. Skipping a separate planning phase does not mean skipping diagnosis or tests.
Make planning produce a decision
Begin by identifying the current design, affected interfaces, constraints, and acceptance criteria. Compare only the approaches that could satisfy those constraints. A useful plan explains the selected approach, dependency order, likely affected files, compatibility handling, validation, and recovery strategy.
For a service migration, clarify whether clients must remain compatible during rollout and whether old and new data representations must coexist. “Update the library and fix errors” is not enough: it leaves the main design risks unresolved until implementation.
Planning is complete when there is enough evidence to choose and execute the next steps. Endless repository exploration without a decision or bounded open question adds cost. Record unresolved matters with their owner or required evidence. If an unresolved contract could invalidate the design, resolve it before committing to that design.
Understand the execution boundary
The supplied materials describe plan mode as a permission state that limits implementation actions while allowing investigation. Inspect the active mode and permitted tools in the actual interface. Do not infer an operating-system sandbox from a mode name, or assume that every shell command is harmless because it appears exploratory.
The source discusses terminal defaults, editor startup settings, plan-entry and plan-exit tools, and approval options. These are surface-dependent controls. Use the configuration shape and field supported by the relevant installation; a terminal setting is not evidence that an editor or SDK session started in the same state. Use supported SDK constructors and permission-mode names; conceptual pseudocode is not automatically an executable API.
An approved plan records agreement on the approach. The selected execution permissions still govern actions. A direct workflow can legitimately encounter an approval boundary, and plan approval does not automatically authorize a production deployment or every subsequent side effect.
Use isolated exploration purposefully
An Explore-style subagent is suited to verbose, self-contained discovery that can return a concise answer: locate callers of a deprecated interface, map module dependencies, or identify the tests that cover a component. Specify the question, search scope, expected evidence, and stopping point.
For a targeted lookup, use a narrow investigation. For a migration whose risk depends on indirect callers, request a broader dependency map. The supplied materials describe quick, medium, and very thorough exploration levels; select depth according to the question rather than using the largest search by default.
The returned report should identify paths and relevant interfaces, distinguish examined areas from unchecked areas, and state unresolved dependencies. A summary saying “everything looks fine” is insufficient evidence for a migration plan. Separate context keeps intermediate output out of the parent conversation, but the worker still has a context and cost. Verify effective permissions; denying Write and Edit alone does not demonstrate that every remaining tool is read-only.
Keep a small task in the main conversation when handing it off would cost more than the discovery itself. If research tasks are independent, their findings may be collected concurrently, but synthesis must wait for the required results.
Worked example: a bounded direct fix
Assume parse_count must accept integer zero, reject negative integers, and reject a missing value. The diagnosed bug is that the existing condition rejects zero because it tests truthiness. The target function and caller contract are already known.
A direct workflow reads the current function and its callers, replaces the faulty condition with an explicit check appropriate to the actual type contract, and verifies zero, a positive integer, a negative integer, and a missing value. Do not invent handling for strings or booleans without inspecting that contract. The acceptance result is the promised behavior for those cases, supported by actual checks.
If inspection reveals that several callers rely on a different missing-value convention, the task is no longer the same bounded fix. Reassess the interface and affected callers before continuing.
Worked example: plan, then implement a migration
A team must replace Library A with Library B across an application. Two options are plausible: replace calls directly, or introduce an adapter that preserves the existing application interface. The application must support its current callers throughout a staged rollout.
Investigation maps callers and identifies a difference: A returns null when no item exists, while B raises a not-found error. The selected plan introduces an adapter that converts only that specific not-found condition to null; connection failures must remain failures. It migrates callers in dependency order and verifies existing behavior before removing A.
The plan includes these acceptance cases:
| Library B outcome | Adapter outcome |
|---|---|
| Item found | Return the mapped item |
| Item absent | Return null |
| Connection failure | Propagate a distinguishable failure |
Persist the chosen plan with the examined revision and the unresolved questions. After the approach is authorized, enter the appropriate execution mode, confirm the current checkout still matches the assumptions, implement the adapter and caller changes, and run the relevant tests. If the code has changed meanwhile, update the plan before applying stale steps.
The table states expected behavior; it is not a test-run report. Record actual results only after running checks against the implementation. If a check fails, preserve the failure and repair evidence rather than declaring the plan successful because the edits were made.
Handle interruption and noninteractive workflows
Stop early when the investigation is heading toward the wrong requirement. Preserve useful findings and correct the scope. Conversation checkpoints may help with local recovery, but do not assume they undo external actions or every background edit.
In an automated application, capture the plan explicitly and model the transition as application state: plan ready, decision pending, execution authorized, execution running, and validation complete or failed. An interactive exit tool or continuation flag is not a substitute for a recorded decision and effective permissions.
Source-scoped mode and interface details
The following details are attributed to the supplied snapshot; original anchor attachments were not available and no current-client, editor or SDK behavior was tested. Check supported options and actual state before use.
For that snapshot, plan-mode file edits prompt through canUseTool even when an allow rule matches. It attributes routing of modifying shell commands such as touch and rm through that callback to v2.1.212+. Other passages qualify blanket "all writes blocked" shorthand with available bypass-permission sessions and a shell classifier path. These are different controls, not evidence that any shell effect is allowed merely because the session is planning.
The source says that if auto mode is available and useAutoModeDuringPlan is enabled (described there as the default), the classifier reviews planning shell commands: approved commands may proceed under that path and rejected commands are blocked. If unavailable/disabled, commands outside the built-in read-only set follow the described approval prompts, even with sandbox auto-allow. Do not extrapolate this planning setting into universal direct-edit authorization. Check effective policy for the actual proposed command.
| Surface/state | Source-described entry or startup control |
|---|---|
| Interactive current session | /plan with an optional task, or Shift+Tab; inspect the displayed plan status |
| Terminal project startup | .claude/settings.json example {"defaultMode":"plan"} (or "default" for that intended startup) |
| VS Code startup | User setting claudeCode.initialPermissionMode; source says project startup setting is not read for this purpose |
| SDK | Interface-specific permission_mode="plan" concept and EnterPlanMode; verify the actual SDK signature |
The source describes mode-selector planning as current-session selection, not a persistent per-folder default. It separately reports "Accept edits" wording in cloud sessions and remote-control Manual/Accept edits/Plan choices without app selection of Auto/Bypass. A default setting is not proof the current session entered that mode.
For interactive plan review the source gives Ctrl+G to open the plan in an editor, then choices to accept using auto mode, accept while manually approving each edit, or decline and keep planning. The last keeps the proposal pending; manual choice continues edit-by-edit review. An ExitPlanMode request only proposes a transition. Actual acceptance and selected execution permissions remain separate, as do subsequent deployment or other side-effect authority.
In headless use, capture the exact plan and decision explicitly. The source's Agent/ClaudeAgent constructors, permission_mode="execute", incomplete f-string and unfinished execution call do not establish a supported runnable API. The following is application-state pseudocode only:
capture actual plan bytes and examined revision
record accepted / requested changes / rejected decision
if decision is not accepted: return pending planning state
if current inputs differ: return pending replanning with the changed inputs
if a required recovery/handoff identity or access reference is unverified: return blocked identity check
if effective execution permissions do not permit the next action: return pending action
otherwise: pass the accepted plan and evidence into the supported execution interface
run the declared checks and record actual pass/fail results
The snapshot mentions ~/.claude/plans/ and a "within five minutes" recent-plan recovery suggestion. These are not guaranteed creation, retention or identity rules. Recover only the actual matching plan within authorized scope and verify its bytes/revision/decision. Missing output stays missing. A continue_conversation=True example carries context; it cannot supply acceptance.
For recovery or handoff, retain the non-secret workspace/worktree and examined revision, the actual plan and recorded decision, and the execution or worker identity needed to match the intended task. Include account identity or an approved secret reference only when that access genuinely requires it. Keep actual keys, tokens and passwords out of prompts, logs and handoff artifacts. Knowing a path or reference, or sharing configuration, does not itself authorize access or the sharing or use of credentials. If any identity, approved reference or authorization required for this recovery or handoff is missing or unverified, retain a blocked state and seek the missing evidence or necessary approval rather than silently switching accounts.
For interruption, the source names Escape to stop and /rewind or double Escape for supported checkpoints. Verify the selected checkpoint and actual restored artifacts. None establishes reversal of external effects, arbitrary shell mutations or background edits.
Distinguish ordinary editing from arbitrary-code execution
The source also describes a separate client-side architecture: the application exposes functions to a code-execution tool, receives model-generated code and executes it where those functions exist. This is different from a bounded Claude Code file edit under its normal permission system. In the client-side path, inspect exposed functions, treat generated code as untrusted input and apply actual validation/isolation appropriate to the environment. Do not select an unsandboxed arbitrary-code mechanism where the application cannot safely execute it. That caution does not imply every ordinary direct edit lacks a sandbox.
Qualify Explore behavior and diagnoses
Explore is the source's code-discovery worker; Plan is its separate planning-research role. Reusable Skills can carry workflows in the main conversation. Already-known-context side questions may use the source's /btw surface where supported instead of paying a fresh worker's discovery cost. Choose the actual role and surface rather than treating these as interchangeable names.
The snapshot attributes Explore model inheritance to v2.1.198. It reports a Claude API-specific Opus cap, and direct inheritance without that cap on the listed Amazon Bedrock, Google Cloud Agent Platform, Microsoft Foundry and AWS Claude Platform paths. A user/project definition named Explore with a supported model field can override the described default, for example model: haiku. These labels and source hierarchy are not current availability, price rankings or measured total cost; inspect the actual provider/configuration and workload.
The source's /context diagnostic shows token-use categories; use actual measurements to adjust a bounded question, depth and requested evidence. Quick/medium/very thorough are not fixed token/time bounds or completeness guarantees. A short worker response can still miss required evidence and need focused follow-up.
The snapshot also reports Explore prompt contradictions between Bash and built-in tools and stuck find/grep/sed processes with repeated permission prompts. Those issue reports were not independently verified or reproduced here. Inspect actual tool status, active mode, logs and permission outcome before attributing a failure. Stop or narrow a deviating investigation; do not bypass controls because an issue report sounds similar.
Exact expected cases for the bounded fix
For the earlier parse_count example, declare the illustrative input domain as integers excluding booleans, plus a missing value represented by None. String coercion is outside this example. The old truthiness check rejects integer zero. A possible local condition under this stated contract is:
if value is None or type(value) is not int or value < 0:
raise ValueError("count must be a nonnegative integer")
return value
Expected checks: input 0 returns 0 (repairing the old rejection); 3 returns 3; -1 and None raise the specified error. Under the declared exclusion, True and "3" are rejected rather than coerced. This is an illustrative exact condition and expected result, not an implementation or test run. Read the actual function/caller contract before choosing this change; different coercion or missing-value requirements reopen scope and planning.
Compare the actual faulty and repaired predicates
These complete pure Python functions are teaching fixtures only. Their caller supplies integers excluding booleans, or None for missing; there is no upstream numeric validation in this fixture, and strings/booleans are intentionally rejected rather than coerced. The first function violates that declared caller contract; it is not an observed repository implementation:
def faulty_parse_count(value):
if not value:
raise ValueError("count must be a nonnegative integer")
return value
def repaired_parse_count(value):
if value is None or type(value) is not int or value < 0:
raise ValueError("count must be a nonnegative integer")
return value
| Supplied input | Faulty fixture outcome | Repaired expected outcome | Judgment under the declared contract |
|---|---|---|---|
| 0 | Raises ValueError | Returns integer 0 | The repair restores a valid boundary. |
| 3 | Returns integer 3 | Returns integer 3 | Valid behavior is retained. |
| -1 | Returns -1 | Raises ValueError | The old return accepts a prohibited negative. |
| None | Raises ValueError | Raises ValueError | Missing input remains rejected. |
| True | Returns True | Raises ValueError | The old truthy value violates the Boolean exclusion. |
| "3" | Returns string "3" | Raises ValueError | The old truthy string violates the no-coercion contract. |
All error rows use the displayed message. A valid implementation with an upstream guard could change the review finding; inspect real callers before applying this local repair. The table is an expected fixture comparison, not evidence of a model review, real repository fix or product run. The earlier application-state pseudocode now returns from unaccepted, stale-input or unauthorized states so none falls through into execution.
Named worker restrictions and default permissions
The supplied source describes the Plan research subagent as inheriting the main conversation's model while holding its intermediate exploration in a separate context, with Write and Edit explicitly denied. It separately describes built-in Explore as a read-only code-discovery worker that explicitly denies Write and Edit. These are attributed worker contracts, not an operating-system sandbox or proof that every remaining shell/custom tool cannot mutate data. Inspect actual effective capabilities. Main-session plan-mode edit callbacks are another control layer; a callback prompt is not the same mechanism as a worker having no Write/Edit capability.
The snapshot's default permission mode permits file reads and its built-in read-only shell operations without prompting, but requests approval for file edits and potentially dangerous shell commands under that described default policy. Actual supported allow/deny rules and other modes remain relevant. Being out of Plan mode does not grant every operation, and the planning-specific useAutoModeDuringPlan classifier must not be silently turned into universal direct-edit approval. These are source-scoped descriptions, not observed behavior of the current host.
Complete the research and implementation contracts
The source's planning discussion also names AskUserQuestion as a way to clarify infrastructure requirements before choosing an approach. That is an attributed tool/interface example, not a requirement that every environment exposes that exact tool or that a question supplies authorization. Its CLI acronym means Command Line Interface; terminal behavior is supported by the domain description, not by the acronym alone.
The source describes these qualitative exploration levels:
| Level | Appropriate question shape | What it does not establish |
|---|---|---|
| quick | A targeted lookup, such as locating a known function's callers. | A fixed duration, token budget or complete repository audit. |
| medium | Balanced research across the relevant area. | A guarantee that every indirect dependency was found. |
| very thorough | Deeper analysis for a complex dependency or design question. | Unlimited context, zero latency or guaranteed correctness. |
The snapshot's warning about an unrestricted investigation reading hundreds of files is an illustrative workload warning, not a measured count for this article or an upper bound. Use actual /context categories and the evidence needed for the decision; narrow or stop a drifting investigation rather than treat a short final message as proof that all required work was done.
A complete bounded discovery return
Here is a fictional two-file input fixture. These exact paths and line numbers are declared teaching data, not findings from a real repository:
File src/report.py:
from store import load_record
def make_report(key):
return load_record(key)
File src/audit.py:
from store import load_record
def make_audit(key):
return load_record(key)
The authorized discovery request is: "Within these two supplied files, locate calls to load_record; return paths, line references and unresolved dependency questions. Do not change files or run code. Use a targeted lookup and stop after accounting for both files." A complete expected return is:
{
"scope": ["src/report.py", "src/audit.py"],
"examined": ["src/report.py:1-4", "src/audit.py:1-4"],
"calls": [
{"path": "src/report.py", "line": 4, "caller": "make_report", "target": "load_record"},
{"path": "src/audit.py", "line": 4, "caller": "make_audit", "target": "load_record"}
],
"unchecked": ["store implementation", "other repository files", "runtime or generated calls"],
"open_questions": ["What missing-item and connection-failure outcomes does store.load_record expose?"],
"actions_performed": "Illustrative expected discovery report only; no worker or tool was run."
}
The parent can account for the two requested files from this report, but cannot infer that the whole application has only two callers or that the migration contract is known. The unresolved store behavior needs focused follow-up before a design that depends on it. A request to change the implementation would be a separate action under actual authority and tool permissions.
Exact expected adapter outcomes
For the Library A-to-B example, define these invented adapter events for teaching: found carries an object with id and name; not_found is B's specifically recognized missing-item condition; connection_failed is a distinct failure. The accepted adapter plan returns the found object, converts only recognized not_found to null, and preserves connection failure. No network library or public API is being specified by these application-owned labels.
[
{"input_event": {"kind": "found", "item": {"id": "ITEM-7", "name": "Quarterly report"}}, "expected_adapter_outcome": {"status": "ok", "value": {"id": "ITEM-7", "name": "Quarterly report"}}},
{"input_event": {"kind": "not_found"}, "expected_adapter_outcome": {"status": "ok", "value": null}},
{"input_event": {"kind": "connection_failed", "message": "Connection unavailable"}, "expected_adapter_outcome": {"status": "error", "kind": "connection_failed", "message": "Connection unavailable"}},
{"input_event": {"kind": "unknown_error"}, "expected_adapter_outcome": {"status": "unresolved", "reason": "No accepted mapping for this event; inspect the real library contract before changing it."}},
{"input_event": {"kind": "found"}, "expected_adapter_outcome": {"status": "unresolved", "reason": "Required item is missing; do not turn malformed success input into not_found or a valid null result."}}
]
These are complete expected input/output records under the declared fixture contract, not actual API responses or test results. The unknown and malformed cases remain unresolved rather than silently looking like a valid absent item. Before reporting the migration complete, an authorized implementation must be checked against the actual accepted contract and observed outputs; a saved plan or this static table cannot supply that evidence.
Summary
Choose planning for unresolved design choices and consequential dependencies, and direct execution for genuinely bounded work. Make exploration answer a question, preserve a reviewable plan, and distinguish expected acceptance behavior from actual implementation results.
