Claude Code CLI
安装
bash
npm install -g @anthropic-ai/claude-code交互模式
bash
claude # 启动交互式 REPL
claude "修复 login 页面" # 带初始提示启动权限模式
| 模式 | 说明 |
|---|---|
default | 每次操作需确认 |
plan | 只规划不执行 |
auto | 自动执行(需信任) |
bypassPermissions | 跳过所有确认 |
管道模式
bash
cat error.log | claude "分析这个错误"
echo "refactor this" | claude --print常用斜杠命令
/help— 帮助信息/clear— 清除上下文/compact— 压缩对话历史/cost— 查看费用统计/model— 切换模型
会话管理
bash
claude --resume # 继续上次会话
claude --continue # 继续最近会话
claude --session-id ID # 指定会话