控制与模式
工作模式
交互模式 (Interactive Mode)
bash
# 启动交互模式
claude
# 特点
- 持续对话
- 上下文保持
- 会话管理单命令模式 (Single Command Mode)
bash
# 执行单个任务
claude "create a hello.js file"
# 特点
- 快速执行
- 独立任务
- 无状态Plan 模式 (Plan Mode)
bash
# 规划模式
You: 实现用户认证功能
Claude: Let me enter Plan Mode to design the implementation.
[Plan Mode]
1. Analyzing requirements...
2. Creating implementation plan...
3. Presenting plan for approval...
Proceed with implementation? (yes/no)权限控制
配置权限
json
{
"permissions": {
"fileOperations": {
"read": true,
"write": "prompt",
"delete": "deny"
},
"commandExecution": {
"bash": "prompt",
"system": "deny"
},
"networkAccess": {
"http": true,
"external": "prompt"
}
}
}权限级别:
true/allow: 自动允许prompt: 每次询问false/deny: 拒绝
会话控制
bash
# 暂停会话
Ctrl + Z
# 恢复会话
fg
# 中断操作
Ctrl + C
# 退出
Ctrl + D
exit
/quit小结
在本章中,我们学习了:
- ✅ 三种工作模式(交互、单命令、Plan)
- ✅ 权限控制配置
- ✅ 会话控制命令