Skip to content

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    # 指定会话

基于 VitePress 构建