Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Claude Code Interactive Mode

Claude Code Interactive Mode

Unlike the web version of Claude, Claude Code is not simply a chat tool, but rather adevelopment collaboration system with engineering context, permission control, and execution capabilities。
Therefore, when handling tasks, it introduces three coremodes of thinking:

Understanding the boundaries and responsibilities of these three modes is the key to using Claude Code efficiently and safely.

In terminal execution there is actually no need to switch manually; Claude switches automatically. In the VS Code extension you can switch modes manually:


The Three Interactive Modes in Detail

When using Claude Code in the terminal, youdo not need to manually switch the mode toggle; Claude automatically determines which mode to enter based on the content of your instructions.

However,As a user, you must clearly express your intent in the prompt; otherwise Claude is likely to behave inconsistently with your expectations.

1. Ask Mode: Look but Don't Touch (Read-Only Analysis)

Ask mode is Claude Code's default safe mode.

Use Cases

You should prefer Ask mode when you are in the following situations:

Mode characteristics

You can think of Ask mode as:

A senior engineer who is highly experienced but keeps their hands behind their back.

Example instructions

解释一下 src/auth.ts 里的 JWT 验证流程

在这个项目里,数据库连接是在哪里初始化的?



这段代码为什么在高并发下可能出问题?

Professional advice:


When unsure whether to change code, always use Ask first.


2. Plan Mode: Think Before You Act (Plan Only, Don't Execute)

Plan mode is the mode in Claude Code that most resembles an architect's mindset.

Use Cases

When you are faced withcomplex changes or changes with a broad impact, you should use Plan mode, for example:

Mode characteristics

The core value of Plan mode lies in:

turning "write code first" into "reach consensus first".

Example instructions

我想给现有的 API 增加一个 Redis 缓存层,请先给我一个实施方案



计划一下如何把这个项目的样式从 CSS 改为 Tailwind CSS



如果要拆分这个模块,合理的步骤应该是什么?

Practical advice:


The more you use Plan mode, the lower the probability of rework.

3. Edit Mode: Execute Directly (Can Write Code)

Edit mode is the phase where Claude Code actually gets hands-on.

Use Cases

When you already clearly know:

At this point you can directly enter Edit mode.

Mode characteristics

In Edit mode, your role is:

The final reviewer of the code, not a bystander.

Example instructions



把登录接口的响应码从 200 改为 201



修复 main.py 第 45 行的类型错误



在不改变现有行为的前提下,重构这个函数的可读性

Professional habit:


The more specific your description, the more safely Claude makes changes.


Core Slash Commands (/)

Slash commands are used tocontrol Claude Code's session state and behavior, rather than to write business code.

Type in the terminal / can trigger it.

Command Purpose Expert tips
/help View all commands Must-read for first-time users
/cost View current session consumption Prevent unintentional token burning
/compact Compress the context Use when conversations become long and slow
/reset Reset the session Important when switching tasks
/docs Index documents Let Claude reference specified documents
/review Code review Check Git staging area changes

Note:


/cost and /compact are high-frequency commands for long-term users.


An example of a typical interaction flow

In real development, the three modes are oftenused continuously。

Example flow

1、Ask

为什么我的注册接口一直返回 400 错误?

Claude analyzes the code and logs, pointing out that email validation is missing.

2、Plan

I want to add email format validation and normalize the error messages; how do you plan to do that?

Claude gives the steps: modify the validation logic → update the tests → adjust the return structure.

3、Edit



按计划执行吧

Claude modifies the files and shows the Diff for your confirmation.

Ask is for figuring out the problem, Plan is for avoiding detours, and Edit is for cautious execution.


The Permission Confirmation Mechanism in Interactions

Claude Code is very restrained with system operations; any risky action will request your confirmation.

Common permission confirmations


The code Diff is shown, and you need to confirm before it can be written.

-

Execute the command
For example npm test、pnpm build, it will explicitly ask whether to allow it.

Important reminder:


Never confirm directly without looking at the Diff.
Claude is powerful, but it can still make mistakes or hallucinate.