claude | 启动交互式会话 | claude |
claude "query" | 使用初始提示词启动交互式会话 | claude "explain this project" |
claude -p "query" | 通过 SDK 查询,然后退出 | claude -p "explain this function" |
cat file | claude -p "query" | 处理管道内容 | cat logs.txt | claude -p "explain" |
claude -c | 在当前目录中继续最近的对话 | claude -c |
claude -c -p "query" | 通过 SDK 继续 | claude -c -p "Check for type errors" |
claude -r "<session>" "query" | 按 ID 或名称恢复会话 | claude -r "auth-refactor" "Finish this PR" |
claude update | 更新到最新版本 | claude update |
claude gateway | 启动自托管 Claude apps gateway 服务器,供在 Amazon Bedrock、Google Cloud 的 Agent Platform 或 Microsoft Foundry 上部署 SSO 和策略在 Claude Code 前面的管理员使用。需要 --config 指向 gateway.yaml。 | claude gateway --config gateway.yaml |
claude install [version] | 安装或重新安装本机二进制文件。接受版本号如 2.1.118、stable 或 latest。请参阅 安装特定版本 | claude install stable |
claude auth login | 登录您的 Anthropic 账户。使用 --email 预填充您的电子邮件地址,使用 --sso 强制 SSO 身份验证,使用 --console 使用 Anthropic Console 登录以进行 API 使用计费而不是 Claude 订阅 | claude auth login --console |
claude auth logout | 从您的 Anthropic 账户登出 | claude auth logout |
claude auth status | 以 JSON 格式显示身份验证状态。使用 --text 获取人类可读的输出。如果已登录,则以代码 0 退出,如果未登录,则以代码 1 退出。JSON 包含一个 configDirectory 字段,命名 CLI 使用的 配置目录。该字段需要 Claude Code v2.1.268 或更高版本。JSON 的 authMethod 字段取值为 none、claude.ai、oauth_token、api_key、api_key_helper 或 third_party 之一 | claude auth status |
claude agents | 打开 agent view 以监控和分派并行后台会话。使用 --cwd <path> 仅显示在该目录下启动的会话,或使用 --json 将活动会话打印为 JSON 数组以供脚本使用(--json --all 也包括已完成的后台会话)。传递 --permission-mode、--model、--effort 或 --agent 以设置 分派会话的默认值。接受 --settings、--add-dir、--plugin-dir 和 --mcp-config,如顶级 claude 命令。打开 agent view 需要交互式终端 | claude agents --json |
claude attach <id|name> | 在此终端中附加到 后台会话。传递正在运行的会话名称的一部分来代替 ID 需要 Claude Code v2.1.290 或更高版本 |