VWD AI Guide v3.9
⌨️

Claude Code

终端 CLI 工具 — 让 Claude 直接操作你的代码库和文件系统,实现真正的开发自动化

A terminal CLI tool — Claude operates your codebase and file system directly for true development automation

什么是 Claude Code?What is Claude Code?

Claude Code 是 Anthropic 推出的命令行 AI 编程助手,安装后在终端里通过 claude 命令调用。它不只是"聊天生成代码"——它可以直接读写项目文件、执行 Shell 命令、自主完成多步骤开发任务,相当于一个在你电脑上工作的 AI 开发助理。

Claude Code is Anthropic's command-line AI coding assistant. After installation, invoke it with the claude command in your terminal. It doesn't just chat about code — it reads/writes project files, executes shell commands, and autonomously completes multi-step dev tasks: a true AI developer working inside your machine.

🆕 最新功能(2026 年 7–9 月)What's new (July–September 2026)
  • auto 模式成为默认(8/14 起,Pro / Max / Team)——不再逐条弹窗要你确认,一个分类器在后台判断:安全的动作直接跑,危险的直接拦。允许/禁止规则现在可以用大白话一句话写,不用记语法。本页下方的「权限模式」仍然适用,auto 相当于在"每步确认"和"全部放行"之间的中间档。Auto mode is the default from Aug 14 (Pro / Max / Team) — instead of a prompt per step, a classifier decides in the background: safe actions run, risky ones are blocked. Allow and deny rules can be written as plain sentences. The Permission Modes section below still applies; auto is the middle ground between approving everything and skipping all checks.
  • 默认模型换代——/model claude-opus-5(7/24 起 Opus 档默认)、/model claude-fable-5-1(9/1 起 Fable 档默认)。也可以用环境变量 ANTHROPIC_DEFAULT_MODEL 固定新会话的起始模型;maxEffortLevel 可以给所有 provider 的努力档设上限,防止无意中烧钱。New default models — /model claude-opus-5 (the Opus default since 7/24) and /model claude-fable-5-1 (the Fable default since 9/1). ANTHROPIC_DEFAULT_MODEL pins which model new sessions start on, and maxEffortLevel caps effort across every provider so a long run can't quietly get expensive.
  • /design(研究预览)——给一句话或一张截图,Claude 生成可编辑的界面草图(artboard),你挑一个,它去实现。做内部小工具界面时省掉"来回描述"的环节。/design (research preview) — hand it a sentence or a screenshot and Claude drafts editable artboards; pick one and it implements that. Cuts out the back-and-forth when building an internal tool's UI.
  • 会话之间能互相传话——输入 @ 点名另一个 Claude 会话,把一个会话里查到的结论直接递过去,不用你复述;/fork 把当前对话复制到后台会话继续跑;子 agent 默认在后台运行。Sessions can message each other — type @ to mention another Claude session and hand it a finding instead of re-explaining; /fork copies the conversation into a background session; subagents run in the background by default.
  • 其他实用改动:内置浏览器(桌面端,Claude 自己查文档、调试页面);/doctor 全套体检并能直接修;Concise 输出风格(先给结论);用量超限后自动续跑;全屏 diff 面板查看未提交改动;支持 GitLab 合并请求;自托管环境(Team/企业版 beta,云端会话跑在公司自己的机器上)。Other useful changes: a built-in browser on desktop (Claude looks up docs and debugs pages itself); /doctor as a full checkup that can fix what it finds; the Concise output style (result first); auto-continue after a usage limit resets; a fullscreen diff panel for uncommitted changes; GitLab merge request support; and self-hosted environments (Team/Enterprise beta) that run cloud sessions on infrastructure you operate.

→ 官方逐周更新:code.claude.com/docs/en/whats-new→ Official weekly digest: code.claude.com/docs/en/whats-new

适合哪些人?Who Should Use It?

💻 IT 工程师 🐍 Python / JS 开发者 🗄️ 数据工程师 🔗 系统集成 / API 开发 🤖 自动化脚本工程师

非技术员工无需使用 Claude Code,Claude Chat 已能满足日常 90% 以上的需求。

Non-technical employees don't need Claude Code — Claude Chat already covers 90%+ of daily needs.

安装与启动Installation & Launch

# 需要 Node.js 18+,在终端执行以下命令安装 # Requires Node.js 18+. Run these commands in your terminal npm install -g @anthropic-ai/claude-code # 进入你的项目目录后启动 # Navigate to your project directory, then launch cd /path/to/your/project claude

首次运行会引导你完成 Anthropic 账号授权,之后直接进入交互界面。Windows 用户建议在 WSL 或 PowerShell 中运行。

First run guides you through Anthropic account authorization. Windows users: run in WSL or PowerShell.

📢 计费变化(2026/6/15 起)Billing change (from June 15, 2026) Anthropic 把订阅计划(Pro / Max 等)的程序化用量(Claude Code、Agent SDK、API 调用)拆分到一个独立的每月 credit 额度池,与网页端 Chat 的用量分开计算。也就是说,用 Claude Code 跑大任务会消耗这部分专属额度——如果团队重度使用,留意额度用尽提示,必要时升级套餐或转用按量计费的 API key。 Anthropic has split programmatic usage (Claude Code, Agent SDK, API calls) on subscription plans (Pro / Max, etc.) into a separate monthly credit pool, counted apart from web Chat usage. Heavy Claude Code runs draw down this dedicated pool — if your team uses it heavily, watch for credit-exhaustion prompts and consider upgrading the plan or switching to a usage-based API key.

核心命令速查Key Commands Cheat Sheet

命令 / 操作Command / Action 说明Description
claude 在当前目录启动交互式对话Start interactive session in current directory
claude "修复登录页的 bug" 直接传入任务描述,无需进入交互模式Pass task directly without entering interactive mode
claude -p "解释这段代码" 管道模式,结合 stdin 使用Pipe mode, combine with stdin input
交互中输入 /helpType /help in session 查看所有斜杠命令View all slash commands
/clear 清空当前对话上下文Clear the current conversation context
/compact 压缩对话历史,节省 tokenCompress conversation history to save tokens
/init 为项目生成 CLAUDE.md 说明文件,让 Claude 理解项目结构Generate CLAUDE.md project documentation so Claude understands your codebase
Shift+Tab 切换自动接受模式(Claude 直接执行操作,不逐步确认)Toggle auto-accept mode — Claude executes actions without step-by-step confirmation
/model 切换模型(如 Sonnet ↔ Opus),Opus 适合复杂架构决策Switch model (e.g. Sonnet ↔ Opus). Opus for complex architectural decisions
/rewind 或双按or double Esc 打开回退菜单,恢复对话或代码到之前任意检查点Open rewind menu — restore conversation and/or code to any previous checkpoint
/btw "问题" 侧边提问,答案以悬浮窗显示,不进入对话历史(不消耗上下文)Ask a side question — answer appears in overlay without entering conversation history (zero context cost)
claude --continue 在终端恢复上一次的对话 Session,不需要重新说明背景Resume the most recent session in terminal — no need to re-explain context
claude -p "任务" --output-format json 非交互模式:适合 CI/CD 流水线或脚本批量调用,输出结构化 JSONNon-interactive mode: ideal for CI/CD pipelines or batch scripts — outputs structured JSON

Claude Code 能做什么?What Can Claude Code Do?

📂

自主读写文件Autonomous File R/W

直接读取、创建、修改项目中的任意文件,无需复制粘贴。

Read, create, and modify any project file directly — no copy-paste needed.

🐚

执行 Shell 命令Execute Shell Commands

运行 npm、pip、git、curl 等命令,并根据结果决定下一步。

Run npm, pip, git, curl, and act on the output to determine next steps.

🔗

MCP 工具集成MCP Tool Integration

通过 MCP 协议接入 Notion、Slack、数据库、内部 API 等外部系统。

Connect to Notion, Slack, databases, and internal APIs via the MCP protocol.

🔍

全代码库理解Full Codebase Understanding

自动索引项目结构,跨文件定位 bug,理解模块间的依赖关系。

Auto-indexes project structure, locates bugs across files, and understands module dependencies.

🧪

自动写测试 / 运行测试Write & Run Tests

生成单元测试、运行测试套件、根据失败结果自动修复代码。

Generate unit tests, run test suites, and auto-fix code based on failures.

🔄

Git 操作Git Operations

创建分支、生成 commit message、管理 PR,全程在终端完成。

Create branches, generate commit messages, and manage PRs — all from the terminal.

Claude Code 的工作原理:代理循环How Claude Code Works: The Agentic Loop

Claude Code 不是普通聊天机器人——它通过"代理循环"自主工作:每完成一步操作,就把结果反馈给自己,决定下一步该做什么,直到任务完成。

Claude Code isn't a chatbot — it works through an "agentic loop": after each action, it feeds the result back to itself to decide the next step, repeating until the task is complete.

🔍
收集上下文Gather Context
读文件/搜索Read/Search
→
⚡
执行操作Take Action
写/改/运行Write/Edit/Run
→
✅
验证结果Verify Results
测试/对比Test/Compare
→
🔁
循环直到完成Loop Until Done
你可随时打断You can interrupt

你说"修复失败的测试"→ Claude 运行测试、读错误日志、找到相关源文件、修改代码、再次运行测试验证——每一步都是自主决策,不需要你逐步指示。

You say "fix the failing tests" → Claude runs tests, reads error output, finds source files, edits code, runs tests again to verify — every step is autonomous, no step-by-step instructions needed from you.

推荐工作流:探索 → 计划 → 实现 → 提交Recommended Workflow: Explore → Plan → Code → Commit

对于复杂任务,不要让 Claude 直接跳进去写代码——先分阶段处理效果更好:

For complex tasks, don't let Claude jump straight to coding — a phased approach produces far better results:

阶段Phase 操作Action 示例指令Example Prompt
1️⃣ 探索Explore 进入 Plan Mode(只读,不修改文件)Enter Plan Mode (read-only, no file edits) 读取 /src/auth,理解登录流程和 Session 管理
2️⃣ 计划Plan 让 Claude 生成详细实施计划(可用 Ctrl+G 在编辑器中直接修改)Ask Claude to create a detailed plan (use Ctrl+G to edit it directly in your editor) 我想加 Google OAuth,哪些文件需要改?列出计划
3️⃣ 实现Implement 退出 Plan Mode,让 Claude 按计划执行并运行测试Exit Plan Mode — Claude implements the plan and runs tests 按计划实现 OAuth 流程,写测试并修复失败的测试
4️⃣ 提交Commit 让 Claude 生成 commit 信息并创建 PRAsk Claude to generate a commit message and open a PR 用描述性信息 commit,然后创建 PR
💡 Plan Mode 使用技巧Plan Mode Tip 按 Shift+Tab 两次进入 Plan Mode(只读/分析模式)。任务明确且改动小时(如改一行代码)可跳过计划阶段,直接让 Claude 执行。 Press Shift+Tab twice to enter Plan Mode (read-only/analysis). For small, clear tasks (e.g. fixing a single line) skip planning and ask Claude to act directly.

上下文管理:Claude Code 最重要的资源Context Management: Claude Code's Most Important Resource

Claude 的上下文窗口(Context Window)存放你们对话的所有内容——每条消息、每次文件读取、每次命令输出。上下文越满,性能越差。管理好上下文是用好 Claude Code 的核心技能。

Claude's context window holds your entire conversation — every message, file read, and command output. As it fills up, performance degrades. Managing context is the single most important skill for using Claude Code effectively.

🧹

/clear

任务之间清空上下文。不相关的任务混在一起会让 Claude 表现变差。

Clear context between unrelated tasks. Mixed-topic sessions degrade Claude's performance.

🗜️

/compact

压缩对话历史,保留关键内容。可加参数:/compact 聚焦 API 改动。

Compress history while preserving key content. Add focus: /compact focus on API changes.

⏪

/rewind

回退到之前任意检查点,恢复对话或代码状态。每次发送消息都自动创建检查点。

Rewind to any previous checkpoint to restore conversation or code state. Every prompt auto-creates a checkpoint.

🔁 同一问题纠正超过 2 次?Corrected Claude more than twice on the same issue? 说明上下文已被失败尝试污染。运行 /clear,用更具体的提示词重新开始——干净的 Session + 更好的提示词,几乎总是比长对话 + 反复纠正效果更好。 Context is polluted with failed attempts. Run /clear and restart with a more specific prompt — a clean session + better prompt almost always outperforms a long session with repeated corrections.

权限模式:控制 Claude 能做什么Permission Modes: Control What Claude Can Do

按 Shift+Tab 循环切换以下四种模式,根据任务风险级别选择:

Press Shift+Tab to cycle through four modes — choose based on task risk level:

模式Mode 说明Description 适用场景When to Use
默认Default 每次文件写入和 Shell 命令都需要确认Claude asks before every file write and shell command 生产环境、敏感操作Production, sensitive operations
自动接受编辑Auto-Accept Edits 文件写入和常见文件系统命令(mkdir/mv)无需确认,其他仍需确认File edits and common filesystem commands (mkdir/mv) proceed without asking; others still need approval 开发分支、日常开发Dev branches, everyday coding
Plan Mode 只读工具,Claude 只分析不修改——生成计划供你审查后再执行Read-only tools only — Claude analyzes without modifying, generates a plan for your approval 复杂任务探索阶段Exploration phase of complex tasks
Auto Mode 后台安全分类器自动审查命令,拦截高风险操作,常规操作无需确认(实验性功能)Background classifier reviews commands, blocks risky ones, routine operations proceed without prompts (experimental) CI/CD 流水线、批量自动化CI/CD pipelines, batch automation
🆕 2026 年 7 月更新:Claude Code 桌面端新增内置浏览器——Claude 能自己打开网页、查文档/设计,并像操作本地预览那样操作页面;新增 Artifacts:把会话成果变成可实时更新、可分享的网页(Team/企业版);子 agent 可再创建子 agent(后台链最多 5 层),适合拆解跨模块的大任务;/doctor 升级为完整环境体检并能直接修复发现的问题(别名 /checkup);auto 模式进一步收紧——拦截篡改会话记录、对无法解析的变量执行 rm -rf 前会先询问。生产环境仍建议先在测试分支验证。 🆕 July 2026 update: Claude Code's desktop app adds a built-in browser — Claude can open sites, pull up docs/designs, and interact with pages the way it does local previews; Artifacts turn a session's output into a live, shareable web page that updates in place (Team/Enterprise); subagents can now spawn their own subagents (background chains up to five levels deep) for breaking down large cross-module tasks; /doctor is now a full setup checkup that can fix the issues it finds (aliased /checkup); and auto mode is tighter still — it blocks transcript tampering and asks before rm -rf on a variable it can't resolve. For production, still verify on a test branch first.

VWD IT 部门实战示例VWD IT Real-World Examples

# 示例 1:让 Claude 批量处理 CSV 报价文件 # Example 1: Have Claude batch-process CSV quote files claude "读取 /data/quotes/ 下所有 CSV 文件,合并成一张汇总表,按客户分组,输出到 /output/summary.xlsx"
# 示例 2:分析 CANTOR 系统导出的日志 # Example 2: Analyze CANTOR system export logs claude "帮我分析 cantor_export_2026.log,找出所有报错行,统计错误类型,按频率排序后写入 error_report.md"
# 示例 3:自动化数据库对账脚本 # Example 3: Automated database reconciliation script claude "给我写一个 Python 脚本,连接 PostgreSQL,对比 orders 表和 shipments 表,找出未匹配的订单,每天 8am 自动发邮件提醒"
⚠️ 安全注意事项Security Reminder Claude Code 会真实执行文件操作和命令——请在运行前检查 Claude 计划执行的操作,避免在生产环境中开启自动接受模式(Shift+Tab)。建议先在测试分支操作,再合并到主分支。 Claude Code executes real file operations and shell commands — always review Claude's planned actions before proceeding. Avoid auto-accept mode in production. Work on a test branch first, then merge to main.

VWD AI Guide v3.9 | VWD | 2026 | Created by IT depart. | 有问题发邮件到Questions? Email it@valuewds.com