Claude Code

编程 Agent

相关产品

七款 AI 编程工具对比 | Easy-Vibe 教程

CLI AI 编程工具 | Easy-Vibe 教程


C 知道-开发者首选的 AI 搜索引擎

最懂程序员的新一代 AI 搜索引擎:Devv AI

Bolt AI builder: Websites, apps & prototypes

订阅 - 大模型排行榜

LLM Leaderboard - Best Text & Chat AI Models Compared

SuperCLUE 中文大模型测评基准-AI 评测榜单

AI 模型选型工作台 - 榜单、对比、价格与教程 | DataLearnerAI

LiveBench

模型选择:不同任务使用不同模型

订阅 - 供应商

RelayPulse - 实时监测API中转服务可用性矩阵

Claude/Codex 中转站导航 | ProxyCC

各平台的 Coding Plan

三方服务

OpenRouter

订阅 - 检测

CCTest - Claude Code API Key 安全检测平台 | Claude Code Test | 中转站掺假检测与黑盒模式精准甄别

禾维 AI | 检测 Claude Gemini GPT API 中转站真假

模型验真 --- 验证 AI API 中转站的模型是否真实 | Ofoxc

可用状态监测:

Agent 是如何运作的 - Agent Loop

从【用户发出任务】到【LLM 把任务完成】的全过程。

当您给 Claude 一个任务时,它会经历三个阶段:收集上下文、采取行动和验证结果。

构建模式:ReAct

Agent 的概念、原理与构建模式 哔哩哔哩_bilibili

AI Agent 工作原理 | 菜鸟教程

Agents - Docs by LangChain

ReAct 框架 | Prompt Engineering Guide (promptingguide.ai)

Claude Code 背后的 Agent Loop(从零理解) -- Claude 中文 - Claude AI 开发技术社区

Learn Claude Code


Thought 思考:LLM 思考,目前已知 xx 信息,为了完成最终的 xx 任务,下一步应该做什么

Action 行动:LLM 请求调用工具,由 Agent 调用工具

Observation 观察:Agent 观察工具或环境返回的结果,将其返回给 LLM

Final Answer:最终答案

AI agent 会把编程任务拆解成一个持续的 "感知 → 思考 → 行动 → 验证" 循环,并在其中调用不同工具完成任务。它模仿人类开发者的工作流:不断 "写代码 → 运行 → 看结果 → 再改进"。系统内部通过一个主任务循环不断执行步骤,在每一轮循环中,AI agent 都可以调用不同工具(例如读写文件、执行命令、搜索代码等),再根据工具返回的真实结果决定下一步行动。

Agent 程序的处理逻辑

Agent 背后的核心行为机制:为 LLM 提供强大的工具,并让 LLM 在一个循环中自主运行。

Agent 程序串联起整个流程。Loop:

  • 模型看到:对话历史 + 可用工具列表
  • 模型决定:行动 或 回应
    • 如果行动:执行工具,结果添加到上下文,继续循环
    • 如果回应:返回答案,循环结束
python 复制代码
def agent_loop(messages):
    while True:
        response = client.messages.create(
            model=MODEL, system=SYSTEM,
            messages=messages, tools=TOOLS,
        )
        messages.append({"role": "assistant",
                         "content": response.content})

        if response.stop_reason != "tool_use":
            return

        results = []
        for block in response.content:
            if block.type == "tool_use":
                output = TOOL_HANDLERS[block.name](**block.input)
                results.append({
                    "type": "tool_result",
                    "tool_use_id": block.id,
                    "content": output,
                })
        messages.append({"role": "user", "content": results})

Plan And Execute

查看 AI agent 和 LLM 的交互

liaohch3/claude-tap:在本地追踪查看器中拦截并检查来自Claude Code、Codex CLI、Gemini CLI、Cursor CLI、OpenCode、Kimi、Pi和Hermes的编码代理API流量。

Claude Code

Advanced setup - Claude Code Docs

Claude Code 最佳实践 - Claude Code Docs

Documentation - Claude API Docs

cchistory - Claude Code Version History

升级日志:claude-code/CHANGELOG.md at main · anthropics/claude-code

快捷键:

  • @文件名:精准引用分析文件

:快速编辑 CLAUDE.md 文件

  • !:执行 bash 命令
  • \ + Enter:换行输入
  • Ctrl + G:编辑文件
  • Ctrl + R:历史提示词反向搜索
  • Ctrl + S:提示词暂存

Claude 命令

CLI 参考 - Claude Code Docs

Claude Code 速查表 -- Claude 中文 - Claude AI 开发技术社区

Claude Code Commands,常用命令整理Claude Code的命令有很多,可以通过/查看当前可用的命令, - 掘金

Claude 命令 - 会话管理

探索上下文窗口 - Claude Code Docs

会话连续性与战略压缩 -- Claude 中文 - Claude AI 开发技术社区

上下文管理:

  • 善用子代理(Sub-agents): 对于大规模任务,让 Claude 启动子代理执行。子代理完成任务后返回精炼结论,保护主对话的上下文空间。/agents 命令
  • 及时清理: 使用 /clear 定期重置对话
  • 主动压缩:使用 /compact 命令让 Claude 总结关键决策和修改的文件,保留核心记忆
  • 明确指定文件: 提问时使用 @ 引用文件(如 write a test for @auth.py),避免模型无效扫描整个项目
  • /resume
  • /rewind
  • /branch name:在此点创建当前对话的分支,以便您可以尝试不同的方向而不会丢失当前的对话。切换到分支并保留原始分支,您可以使用 /resume 返回。要将附加任务交给后台 subagent 而不是自己切换到副本,请使用 /fork
  • /fork :生成一个分叉的 subagent:一个继承完整对话的后台 subagent,在您继续进行时处理该指令。其结果在完成时返回到您的对话。要自己切换到对话的副本,请使用 /branch。在 v2.1.161 之前,/fork 是 /branch 的别名
  • 可视化上下文使用:/context
  • /background 分离整个会话以继续作为 background agent 运行,并释放您的终端。

命名会话

使用有意义的会话名称便于管理

powershell 复制代码
# 创建命名会话
claude --session-id "feature-auth-impl"
claude --session-id "feature-auth-tests"
claude --session-id "feature-auth-docs"

# 恢复特定会话
claude -r "feature-auth-impl"

--fork-session

当您使用 claude --continue 或 claude --resume 恢复会话时,您使用相同的会话 ID 从中断处继续。新消息附加到现有对话。您的完整对话历史被恢复,但会话范围的权限不会。您需要重新批准这些。

上下文压缩

Claude Code 上下文压缩分析-云社区-华为云

/compact之后Claude Code上下文发生了什么 - 抖音

上下文压缩指令:ClaudeCode与Gemini的压缩提示词解析 | 上下文工程实践指南

CLAUDE_CODE_AUTO_COMPACT_WINDOW

DISABLE_AUTO_COMPACT

DISABLE_COMPACT

使用 claude-tap 可查看压缩后的上下文

/compact

<> 里的内容不是让你填写固定参数,而是让你用自然语言告诉 Claude:"总结时别忘了什么。" 示例:

  • /compact focus on the API changes
  • /compact 保留任务目标、用户要求、关键技术决策、已修改文件、验证结果、遇到的问题和下一步待办

记忆系统

Claude 如何记住你的项目 - Claude Code Docs

/memory

CLAUDE.md

Using CLAUDE.MD files: Customizing Claude Code for your codebase | Claude

andrej-karpathy-skills/README.zh.md at main · forrestchang/andrej-karpathy-skills

CLAUDE.md 是 Claude 在开始对话时会自动读取并加入上下文的特殊文件。因此,它非常适合用来记录:常用 bash 命令、核心文件和工具函数、代码风格约定、测试方式说明、仓库协作规范(例如分支命名、是用 merge 还是 rebase 等)、开发环境配置说明(例如是否使用 pyenv、推荐哪种编译器等)、项目中需要特别注意的行为或坑点、任何你希望 Claude "记住"的信息。

CLAUDE.md 文件可以使用 @path/to/import 语法导入其他文件。导入的文件在启动时展开并加载到上下文中,与引用它们的 CLAUDE.md 一起。

排除特定的 CLAUDE.md 文件

json 复制代码
{
  "claudeMdExcludes": [
    "**/monorepo/CLAUDE.md",
    "/home/user/monorepo/other-team/.claude/rules/**"
  ]
}

rules

.claude/rules/ 下的 .md 文件。

  • rules 可以使用带有 paths 字段的 YAML frontmatter 范围限定到特定文件。这些条件 rules 仅在 Claude 处理与指定模式匹配的文件时使用。
  • 没有 paths frontmatter 的规则在启动时加载,优先级与 .claude/CLAUDE.md 相同。
markdown 复制代码
---
paths:
  - "src/api/**/*.ts"
---

# API 开发规则

- 所有 API 端点必须包括输入验证
- 使用标准错误响应格式
- 包括 OpenAPI 文档注释

memory

每个项目在 ~/.claude/projects//memory/ 获得自己的记忆目录。 路径来自 git 存储库,因此同一存储库中的所有 worktrees 和子目录共享一个自动记忆目录。在 git 存储库外,改用项目根目录。

MEMORY.md 的前 200 行或前 25KB(以先到者为准)在每次对话开始时加载。超过该阈值的内容在会话开始时不加载。Claude 通过将详细笔记移到单独的主题文件中来保持 MEMORY.md 简洁。

最佳实践

cfrs2005/claude-init: Claude Code 中文开发套件 - 为中国开发者定制的零门槛 AI 编程环境。一键安装完整中文化体验,集成 MCP 服务器、智能上下文管理、安全扫描,支持免FQ访问。让 AI 编程更简单。

设置中文:修改 setting.js "language": "chinese"

plain 复制代码
Always respond in chinese. 
Use chinese for all explanations, comments, and communications with the user. 
Technical terms and code identifiers should remain in their original form.
Maintain full orthographic correctness for chinese, including all required diacritical marks, accents, and special characters. 
Never substitute accented characters with their ASCII equivalents (e.g., never write "nao" for "não", "fur" for "für", or "loeschen" for "löschen").

关闭不必要的目录扫描,在 .claudeignore 中添加排除项(如 node_modules/):claude-ignore init


使用 CLI 进行管道、脚本和自动化:Claude Code 是可组合的,遵循 Unix 哲学。将日志管道传入其中、在 CI 中运行它,或将其与其他工具链接:

bash 复制代码
# Monitor logs and get alerted
tail -f app.log | claude -p "Slack me if you see any anomalies"

# Bulk operations across files
git diff main --name-only | claude -p "review these changed files for security issues"

安排定期任务:按计划运行 Claude 以自动化重复的工作:早晨 PR 审查、夜间 CI 失败分析、每周依赖项审计或在 PR 合并后同步文档。

  • 云计划任务
  • 桌面计划任务
  • /loop

批量操作

powershell 复制代码
# 使用脚本批量处理
# 创建 process.sh
#!/bin/bash
for file in *.js; do
    claude --input="优化 $file" --file="$file"
done

Output Styles

Claude Code Output Styles 配置指南 - 博客 - Hrefgo AI

调整系统提示词,改变 Agent 的行为模式和响应风格。

  • Default 高效开发
  • Explanatory 教育导向
  • Learning 协作学习
  • 可自定义提示词

Explanatory 教育导向

markdown 复制代码
Output Style: Explanatory
You are an interactive CLI tool that helps users with software engineering tasks. In addition to software engineering tasks, you should provide educational insights about the codebase along the way.

You should be clear and educational, providing helpful explanations while remaining focused on the task. Balance educational content with task completion. When providing insights, you may exceed typical length constraints, but remain focused and relevant.

Explanatory Style Active
Insights
In order to encourage learning, before and after writing code, always provide brief educational explanations about implementation choices using (with backticks):
"
[2-3 key educational points]★ Insight ─────────────────────────────────────
─────────────────────────────────────────────────"

These insights should be included in the conversation, not in the codebase. You should generally focus on interesting insights that are specific to the codebase or the code you just wrote, rather than general programming concepts.

Learning 协作学习

markdown 复制代码
Output Style: Learning
You are an interactive CLI tool that helps users with software engineering tasks. In addition to software engineering tasks, you should help users learn more about the codebase through hands-on practice and educational insights.

You should be collaborative and encouraging. Balance task completion with learning by requesting user input for meaningful design decisions while handling routine implementation yourself.

Learning Style Active
Requesting Human Contributions
In order to encourage learning, ask the human to contribute 2-10 line code pieces when generating 20+ lines involving:

Design decisions (error handling, data structures)
Business logic with multiple valid approaches
Key algorithms or interface definitions
TodoList Integration: If using a TodoList for the overall task, include a specific todo item like "Request human input on [specific decision]" when planning to request human input. This ensures proper task tracking. Note: TodoList is not required for all tasks.

Example TodoList flow:
✓ "Set up component structure with placeholder for logic"
✓ "Request human collaboration on decision logic implementation"
✓ "Integrate contribution and complete feature"

Request Format
● **Learn by Doing**
**Context:** [what&#39;s built and why this decision matters]
**Your Task:** [specific function/section in file, mention file and TODO(human) but do not include line numbers]
**Guidance:** [trade-offs and constraints to consider]
Key Guidelines
Frame contributions as valuable design decisions, not busy work
You must first add a TODO(human) section into the codebase with your editing tools before making the Learn by Doing request
Make sure there is one and only one TODO(human) section in the code
Don't take any action or output anything after the Learn by Doing request. Wait for human implementation before proceeding.
Example Requests
Whole Function Example:

● **Learn by Doing**

**Context:** I&#39;ve set up the hint feature UI with a button that triggers the hint system. The infrastructure is ready: when clicked, it calls selectHintCell() to determine which cell to hint, then highlights that cell with a yellow background and shows possible values. The hint system needs to decide which empty cell would be most helpful to reveal to the user.

**Your Task:** In sudoku.js, implement the selectHintCell(board) function. Look for TODO(human). This function should analyze the board and return {row, col} for the best cell to hint, or null if the puzzle is complete.

**Guidance:** Consider multiple strategies: prioritize cells with only one possible value (naked singles), or cells that appear in rows/columns/boxes with many filled cells. You could also consider a balanced approach that helps without making it too easy. The board parameter is a 9x9 array where 0 represents empty cells.
Partial Function Example:

● **Learn by Doing**

**Context:** I&#39;ve built a file upload component that validates files before accepting them. The main validation logic is complete, but it needs specific handling for different file type categories in the switch statement.

**Your Task:** In upload.js, inside the validateFile() function&#39;s switch statement, implement the &#39;case &quot;document&quot;:&#39; branch. Look for TODO(human). This should validate document files (pdf, doc, docx).

**Guidance:** Consider checking file size limits (maybe 10MB for documents?), validating the file extension matches the MIME type, and returning {valid: boolean, error?: string}. The file object has properties: name, size, type.
Debugging Example:

● **Learn by Doing**

**Context:** The user reported that number inputs aren&#39;t working correctly in the calculator. I&#39;ve identified the handleInput() function as the likely source, but need to understand what values are being processed.

**Your Task:** In calculator.js, inside the handleInput() function, add 2-3 console.log statements after the TODO(human) comment to help debug why number inputs fail.

**Guidance:** Consider logging: the raw input value, the parsed result, and any validation state. This will help us understand where the conversion breaks.
After Contributions
Share one insight connecting their code to broader patterns or system effects. Avoid praise or repetition.

Insights
Insights
In order to encourage learning, before and after writing code, always provide brief educational explanations about implementation choices using (with backticks):
"
[2-3 key educational points]★ Insight ─────────────────────────────────────
─────────────────────────────────────────────────"

These insights should be included in the conversation, not in the codebase. You should generally focus on interesting insights that are specific to the codebase or the code you just wrote, rather than general programming concepts.

Claude 并行任务

并行运行代理 - Claude Code Docs

SubAgents/Agent Teams/Swarm 是什么 - 抖音

Claude Code 并行任务 | 菜鸟教程

Multica:

Paperclip:

Bloome


Sub Agent、Agent Team、Agent Swarm

将冗长的操作委托给 subagents:运行测试、获取文档或处理日志文件可能会消耗大量上下文。将这些委托给 subagents,以便冗长的输出保留在 subagent 的上下文中,而只有摘要返回到您的主对话。

多会话 & 多 Agent

Agent View

Claude Code新功能Agents View - 抖音

backgrounded · c12aeddf

claude agents list sessions

claude attach c12aeddf open in this terminal

claude logs c12aeddf show recent output

claude stop c12aeddf stop this session

Worktree

Git 基本原理介绍(35)------git worktree_哔哩哔哩_bilibili

Git -- git-worktree 文档 --- Git - git-worktree Documentation

Vibe Coding - Claude Code Git Worktree 最佳实践-CSDN 博客

常见工作流程 - Claude Code Docs

Claude Code 并行任务 | 菜鸟教程


每个 Claude Code 对话都是一个与您当前目录相关的会话。当您恢复时,您只会看到来自该目录的会话。

Claude 看到您当前分支的文件。当您切换分支时,Claude 看到新分支的文件,但您的对话历史保持不变。Claude 记得您讨论过的内容,即使在切换后也是如此。

由于会话与目录相关,您可以通过使用 git worktrees 运行并行 Claude 会话,这为各个分支创建单独的目录。

  • 隔离性:worktree 与主仓库共享 .git 对象数据库,但拥有独立的工作目录和分支
  • 分支管理:每个 worktree 可以独立切换分支,互不干扰
powershell 复制代码
# 添加 worktree
git worktree add ../project-feature-a feature-a
git worktree add ../project-feature-b feature-b
git worktree add ../project-feature-c feature-c

# 列出所有 worktree
git worktree list

# 在各 worktree 中启动 Claude
cd ../project-feature-a && claude
cd ../project-feature-b && claude

# 完成后移除 worktree
git worktree remove ../project-feature-a

使用 --worktree 参数启动 Claude Code,可在同一 Git 仓库下为每次会话创建独立的工作树(claude --worktree bugfix-123)

动态工作流

使用动态工作流大规模编排子代理 - Claude Code Docs

Claude → Codex | claude-code-tools

当任务需要比一个对话能协调的更多代理时,或当您想将编排编纂为可以读取和重新运行的脚本时,请使用工作流。

示例包括代码库范围的错误扫描、500 文件迁移、需要相互交叉检查来源的研究问题,以及在提交一个之前值得从多个独立角度起草的困难计划。

/deep-research :在多个角度上扇出网络搜索问题,获取并交叉检查它找到的来源,对每个声明投票,并返回一份引用的报告,其中未通过交叉检查的声明已被过滤掉。需要WebSearch 工具可用

/deep-research

/workflows

/batch

概述

对整个代码库进行大规模、可并行化的更改时,使用 /batch 进行并行工作编排。

  • 第一阶段:研究与规划(规划模式)
  • 第二阶段:Spawn Workers (After Plan Approval)
  • 第三阶段:跟踪进度

Provide an instruction describing the batch change you want to make

  • /batch 在【范围】里,把【旧写法】改成【新写法】,并且【描述限制 / 要求】
  • /batch 在 dev/EShopMaster/csharp 下,把 MessageBox.Show 的错误提示统一改成 Alert
  • /batch 在 code/server/wdtservice 下,为所有未加 @RequireRight 的导出查询接口补权限注解
  • /batch 在整个仓库中,把所有 lodash 用法替换为原生实现,但不要改测试文件
  • /batch replace all uses of lodash with native equivalents
  • /batch migrate from react to vue
  • /batch add type annotations to all untyped function parameters

让 Agent 把需求整理成适合 /batch 的一句话

/batch 命令的设计假设是处理已提交 git 的修改。

提示词

markdown 复制代码
<command-message>batch</command-message>
<command-name>/batch</command-name>
<command-args>migrate from vue to react</command-args>
Batch: Parallel Work Orchestration
You are orchestrating a large, parallelizable change across this codebase.

User Instruction
migrate from vue to react

Phase 1: Research and Plan (Plan Mode)
Call the EnterPlanMode tool now to enter plan mode, then:

Understand the scope. Launch one or more subagents (in the foreground --- you need their results) to deeply research what this instruction touches. Find all the files, patterns, and call sites that need to change. Understand the existing conventions so the migration is consistent.

Decompose into independent units. Break the work into 5--30 self-contained units. Each unit must:

Be independently implementable in an isolated git worktree (no shared state with sibling units)
Be mergeable on its own without depending on another unit's PR landing first
Be roughly uniform in size (split large units, merge trivial ones)
Scale the count to the actual work: few files → closer to 5; hundreds of files → closer to 30. Prefer per-directory or per-module slicing over arbitrary file lists.

Determine the e2e test recipe. Figure out how a worker can verify its change actually works end-to-end --- not just that unit tests pass. Look for:

A claude-in-chrome skill or browser-automation tool (for UI changes: click through the affected flow, screenshot the result)
A tmux or CLI-verifier skill (for CLI changes: launch the app interactively, exercise the changed behavior)
A dev-server + curl pattern (for API changes: start the server, hit the affected endpoints)
An existing e2e/integration test suite the worker can run
If you cannot find a concrete e2e path, use the AskUserQuestion tool to ask the user how to verify this change end-to-end. Offer 2--3 specific options based on what you found (e.g., "Screenshot via chrome extension", "Run bun run dev and curl the endpoint", "No e2e --- unit tests are sufficient"). Do not skip this --- the workers cannot ask the user themselves.

Write the recipe as a short, concrete set of steps that a worker can execute autonomously. Include any setup (start a dev server, build first) and the exact command/interaction to verify.

Write the plan. In your plan file, include:

A summary of what you found during research
A numbered list of work units --- for each: a short title, the list of files/directories it covers, and a one-line description of the change
The e2e test recipe (or "skip e2e because ..." if the user chose that)
The exact worker instructions you will give each agent (the shared template)
Call ExitPlanMode to present the plan for approval.

Phase 2: Spawn Workers (After Plan Approval)
Once the plan is approved, spawn one background agent per work unit using the Agent tool. All agents must use isolation: &quot;worktree&quot; and run_in_background: true. Launch them all in a single message block so they run in parallel.

For each agent, the prompt must be fully self-contained. Include:

The overall goal (the user's instruction)
This unit's specific task (title, file list, change description --- copied verbatim from your plan)
Any codebase conventions you discovered that the worker needs to follow
The e2e test recipe from your plan (or "skip e2e because ...")
The worker instructions below, copied verbatim:
After you finish implementing the change:
1. **Simplify** --- Invoke the `Skill` tool with `skill: &quot;simplify&quot;` to review and clean up your changes.
2. **Run unit tests** --- Run the project&#39;s test suite (check for package.json scripts, Makefile targets, or common commands like `npm test`, `bun test`, `pytest`, `go test`). If tests fail, fix them.
3. **Test end-to-end** --- Follow the e2e test recipe from the coordinator&#39;s prompt (below). If the recipe says to skip e2e for this unit, skip it.
4. **Commit and push** --- Commit all changes with a clear message, push the branch, and create a PR with `gh pr create`. Use a descriptive title. If `gh` is not available or the push fails, note it in your final message.
5. **Report** --- End with a single line: `PR: &lt;url&gt;` so the coordinator can track it. If no PR was created, end with `PR: none --- &lt;reason&gt;`.
Use subagent_type: &quot;general-purpose&quot; unless a more specific agent type fits.

Phase 3: Track Progress
After launching all workers, render an initial status table:

#	Unit	Status	PR
1	<title>	running	---
2	<title>	running	---
As background-agent completion notifications arrive, parse the PR: &lt;url&gt; line from each agent's result and re-render the table with updated status (done / failed) and PR links. Keep a brief failure note for any agent that did not produce a PR.

When all agents have reported, render the final table and a one-line summary (e.g., "22/24 units landed as PRs").

相关目录 & 文件 & 配置

Claude Code 设置 - Claude Code Docs

探索 .claude 目录 - Claude Code Docs

配置参考 -- Claude 中文 - Claude AI 开发技术社区

Claude Code 环境变量完全指南:解决 AWS Bedrock 兼容性报错只需 1 个设置 - Apiyi.com Blog

团队落地:把 Claude Code 配置当代码管理 -- Claude 中文 - Claude AI 开发技术社区

Claude Code 环境变量 | 菜鸟教程

Claude Code CLI Config 配置攻略 | Vibe Sparking AI

Claude Code settings.json: Complete config guide (2026) | eesel AI

/config 命令

==== ==== ==== ====

Claude 的内置工具

Claude 的工具使用 - Claude API Docs

工具参考 - Claude Code Docs

Tools - Docs by LangChain


工具是【具有明确定义的输入和输出的】可调用函数,这些函数描述会被传递给 LLM。LLM 根据对话上下文决定何时调用某个工具,以及提供什么输入参数。

工具是使 Claude Code 成为代理的原因。没有工具,Claude 只能用文本回应。有了工具,Claude 可以采取行动:读取您的代码、编辑文件、运行命令、搜索网络并与外部服务交互。每个工具使用都会返回信息,反馈到循环中,告知 Claude 的下一个决定。


内置工具通常分为五类,每一类代表不同类型的代理能力。

类别 Claude 可以做什么
文件操作 读取文件、编辑代码、创建新文件、重命名和重新组织
搜索 按模式查找文件、使用正则表达式搜索内容、探索代码库
执行 运行 shell 命令、启动服务器、运行测试、使用 git
网络 搜索网络、获取文档、查找错误消息
代码智能 编辑后查看类型错误和警告、跳转到定义、查找引用(需要 代码智能插件)

Claude 支持两种类型的工具:

  1. 客户端工具:在您的系统上执行的工具,包括:
  2. 服务端工具:在 Anthropic 服务器上执行的工具,如 网页搜索网页获取 工具。这些工具必须在 API 请求中指定,但不需要您进行实现。

Claude Code SDK

CLI、SDK 和库 - Claude Platform Docs

Cookbook

Claude Agent SDK 完全指南 | Easy-Vibe 教程

扩展 Claude

从 LLM 到 Agent Skill,一期视频带你打通底层逻辑!_哔哩哔哩_bilibili(https://www.bilibili.com/video/BV1E7wtzaEdq/?vd_source = 0503ef2ab7197eb7c81bab704d632d27)

OpenClaw(clawdbot)是什么? 跟 Skills/MCP/RAG/Memory/AI Agent 有什么关系? - 抖音

AI Agent 核心组件 | 菜鸟教程

扩展 Claude Code - Claude Code Docs

核心组件:推理服务、RAG、工具、Memory 管理、MCP、Skills

扩展插入代理循环的不同部分:

  • CLAUDE.md 添加 Claude 每个会话都能看到的持久上下文
  • Skills 添加可重用的知识和可调用的工作流
  • MCP 将 Claude 连接到外部服务和工具
  • Subagents 在隔离的上下文中运行自己的循环,返回摘要
  • Agent teams 协调多个独立会话,具有共享任务和点对点消息传递
  • Hooks 完全在循环外作为确定性脚本运行
  • Plugins 和 marketplaces 打包和分发这些功能

每个扩展解决不同的问题,真实的设置根据您的工作流组合它们:

  • CLAUDE.md 处理始终开启的上下文
  • skills 处理按需知识和工作流
  • MCP 处理外部连接
  • subagents 处理隔离,委派工作(让子代理执行任务)
  • hooks 处理自动化工作流

拓展 Claude - skill

skill.md

捆绑的 skills

  • /code-review low\|medium\|high\|xhigh\|max\|ultra --fix --comment target:审阅当前差异以查找正确性错误以及重用、简化和效率清理。有关工作量级别和目标,请参阅本地审阅差异
    • 传递 --fix 以将发现应用到您的工作树
    • 传递 --comment 以将其作为内联 GitHub PR 评论发布
    • 传递 ultra 以运行深度云审阅
  • /simplify target:审阅更改的代码以查找清理机会并应用修复。四个审阅 agents 并行运行,涵盖现有帮助程序的重用、简化、效率和更改是否处于正确的抽象级别。从 v2.1.154 开始,审阅不寻找正确性错误。使用 /code-review 查找错误。在早期版本中,/simplify 等同于 /code-review --fix。传递路径或 PR 参考以审阅特定目标
  • /batch:在整个代码库中并行编排大规模更改。研究代码库,将工作分解为 5 到 30 个独立单元,并呈现一个计划。获得批准后,在隔离的 git worktree 中为每个单元生成一个后台 subagent。每个 subagent 实现其单元、运行测试并打开一个 pull request。需要一个 git 存储库。示例:/batch migrate src/ from Solid to React
  • /loop interval prompt:在会话保持打开状态时重复运行提示。省略间隔,Claude 会在迭代之间自动调整步速。省略提示,在可用的地方Claude 运行自主维护检查或运行 .claude/loop.md 中的提示。示例:/loop 5m check if the deploy finished。请参阅按计划运行提示。别名:/proactive
  • /security-review:检查差异以查找安全漏洞。
  • /review: 对 GitHub pull request 运行快速单遍只读审查
  • /run-skill-generator:通过从干净环境编写每个项目的 skill,教 /run 和 /verify 如何构建、启动和驱动您的项目应用
  • /run:启动并驱动您的项目应用以在运行的应用中看到更改工作,而不仅仅是在测试中。请参阅运行和验证您的应用
  • /verify:通过构建您的项目应用、运行它并观察结果来确认代码更改是否按预期工作,而不是依赖测试或类型检查。请参阅运行和验证您的应用
  • /dataviz request:为图表、图形和仪表板提供设计指导。Claude 为数据选择图表形式,按角色分配颜色,使用捆绑脚本验证调色板的色盲安全性和对比度,并应用标记、交互和可访问性规则。使用品牌中立的占位符调色板,您可以用自己的调色板替换
  • /fewer-permission-prompts:扫描您的记录以查找常见的只读 Bash 和 MCP 工具调用,然后向项目 .claude/settings.json 添加优先级允许列表以减少权限提示
  • /debug description:为当前会话启用调试日志记录并通过读取会话调试日志来排查问题。调试日志默认关闭,除非您使用 claude --debug 启动,因此在会话中途运行 /debug 会从该点开始捕获日志。可选择性地描述问题以集中分析
  • /claude-api:为您的项目语言(Python、TypeScript、Java、Go、Ruby、C#、PHP 或 cURL)和 Managed Agents 参考加载 Claude API 参考资料。涵盖工具使用、流式传输、批处理、结构化输出和常见陷阱。当您的代码导入 anthropic 或 @anthropic-ai/sdk 时也会自动激活。运行 /claude-api migrate 以将现有 Claude API 代码升级到更新的模型:Claude 询问要扫描哪些文件以及要针对哪个模型,然后更新在版本之间更改的模型 ID、thinking 配置和其他参数。运行 /claude-api managed-agents-onboard 以获得交互式演练,从头开始创建新的 Managed Agent
  • /design-sync hint:转换您的存储库的 React 设计系统并将其上传到 Claude Design,以便它生成的设计使用您的真实组件。可选择性地命名设计系统,例如 /design-sync Acme DS。首次同步验证每个组件,在大型存储库上可能需要几个小时。在 Anthropic API 上可用;在 Amazon Bedrock、Google Cloud 的 Agent Platform 和 Microsoft Foundry 上,底层工具无法访问 claude.ai,因此该命令不可用

拓展 Claude - hook

使用 hooks 自动化工作流 - Claude Code Docs

Hooks 参考 - Claude Code Docs

常见工作流程 - Claude Code Docs

Hooks 系统 -- Claude 中文 - Claude AI 开发技术社区

Hooks 配方:把经验变成自动化护栏 -- Claude 中文 - Claude AI 开发技术社区

Claude Code 钩子 | 菜鸟教程


Hooks 是自动化守护。

Hooks 是确定性规则。Hooks 在 Claude 工作流的特定生命周期节点(如 PreToolUse 工具执行前校验等)自动运行本地脚本,确保关键校验或操作 100% 执行。

/hooks 命令

示例:

  • 在每次文件编辑后自动格式化或在提交前运行 lint。

Git 钩子集成

powershell 复制代码
# 在 .git/hooks/pre-commit 中添加
#!/bin/bash
claude --input="检查代码质量" --file="$@"

拓展 Claude - subAgent

创建自定义 subagents - Claude Code Docs

协调 Claude Code 会话团队 - Claude Code Docs

Working with Agents | Cursor Learn

Cursor Marketplace | Cursor Plugins --- Cursor Marketplace | Cursor Plugins

Subagents 子代理 -- Claude 中文 - Claude AI 开发技术社区

26.1 子 Agent 概述 \| Claude Code 中文教程网(https://cc.x-qu.com/guide/第26章-高级Agent能力/tutorial-26.1 子Agent概述.html)

26.2 异步子 Agent 任务 \| Claude Code 中文教程网(https://cc.x-qu.com/guide/第26章-高级Agent能力/tutorial-26.2 异步子Agent任务.html)

Claude Code 子代理 | 菜鸟教程

指导编码代理的简单开放格式规范:


Subagents 获得自己的新上下文,完全独立于您的主对话。Subagents 的工作不会使您的上下文膨胀。完成后,Subagents 返回摘要。这种隔离是 subagents 有助于长会话的原因。

Sub Agent 和 Agent Skill 的区分:对上下文的处理方式不同

  • Sub Agent 适合处理【与上下文关联】小,【对上下文影响】大的任务(代码检查)
  • Agent Skill 适合处理【与上下文关联】大,【对上下文影响】小的任务(写每日代码总结)

子代理类型:

  • Explore(探索) --- 只读研究。搜索文件、读取代码、回答关于代码库的问题。不能编辑任何东西。
  • Plan(计划) --- 架构设计。探索代码库并提出实现计划。在你批准之前只读。
  • Bash(命令行) --- 命令专家。运行终端命令。用于运行测试、构建或系统检查。

拓展 Claude - MCP

MCP 终极指南 - 从原理到实战,带你深入掌握 MCP(基础篇)_哔哩哔哩_bilibili(https://www.bilibili.com/video/BV1uronYREWR/?vd_source = 0503ef2ab7197eb7c81bab704d632d27)

通过 MCP 将 Claude Code 连接到工具 - Claude Code Docs

Claude Code 配置 MCP 完全指南:从入门到高级的实战教程 | Easy Claude Code

MCP 中文站(Model Context Protocol 中文)

Introduction - Model Context Protocol

Claude Code MCP 完全指南 | Easy-Vibe 教程

Claude Code MCP | 菜鸟教程


MCP 仓库

使用 APISIX 托管 MCP Server

⁠‌‍⁠‬‍‍‌‍‍‌‌‌⁠‌MCP 中国开发者社区 - 飞书云文档

‌‍⁠‌‌⁠‍⁠⁠⁠⁠⁠‍‌调用 MCP 指南 - 飞书云文档


模型上下文协议:Model Context Protocol

Model Context Protocol (MCP) 是一个用于将 Agent 连接到外部数据源的开放标准。

使用 MCP,Claude Code 可以读取 Google Drive 中的设计文档、更新 Jira 中的工单、从 Slack 拉取数据,或使用你自己的自定义工具。

claude mcp add 工具名称 配置参数

拓展 Claude - plugin

通过市场发现和安装预构建插件 - Claude Code Docs

创建和分发 plugin marketplace - Claude Code Docs

Plugins for Claude Code and Cowork | Anthropic

插件系统 -- Claude 中文 - Claude AI 开发技术社区

20.1 插件系统介绍 \| Claude Code 中文教程网(https://cc.x-qu.com/guide/第20章-插件系统概述/tutorial-20.1 插件系统介绍.html)

Claude Code 插件 | 菜鸟教程

Claude Code 插件参考手册 | 菜鸟教程


Plugin 插件:将一系列的 Skill、SubAgent、Hook 和 MCP 能力打包在一起,一键安装。

Claude Code 查看 Plugin 插件的具体实现:C:\Users\hfy.claude\plugins\cache\claude-plugins-official

让 Agent 帮忙查找并安装相关的 Skill、SubAgent、plugin

==== ==== ==== ====

拓展 Claude - 开源项目

claude-code-tools

0Chencc/clawgod

Claude-Mem

任务可视化


将 Claude Code JSONL 转录转换为可读 HTML,支持 TUI 和交互式过滤:daaain/claude-code-log: A Python CLI tool that converts Claude Code transcript JSONL files into readable HTML format.

看到 Claude 在生成最终回复前的思考过程:watch-claude-think - npm

winfunc/opcode: 一个强大的 GUI 应用程序和 Claude 代码工具包(目前限制 Linux、macOS)

自定义状态栏:jarrodwatts/claude-hud: A Claude Code plugin that shows what's happening - context usage, active tools, running agents, and todo progress

codegraph --- Understand any codebase as a graph

ccusage/ccusage: npx ccusage

拓展 Claude - 手机远程开发

Claude Code 手机远程开发 | Easy-Vibe 教程

蒲公英 AI 开发者轻量化服务 | 低至¥13/月

chenhg5/cc-connect: Bridge local AI coding agents

拓展 Claude - 代码智能插件 LSP

代码智能插件

26.3 LSP - 语言服务器协议在 Claude Code 中的应用 \| Claude Code 中文教程网(https://cc.x-qu.com/guide/第26章-高级Agent能力/tutorial-26.3 LSP - 语言服务器协议在Claude Code中的应用.html)

语言服务器协议官方页面 --- Official page for Language Server Protocol

LSP 集成:让 Claude 拥有 IDE 级代码智能

  • 做什么:通过 LSP 获取诊断、跳转定义、查找引用、类型信息。
  • 什么时候用:强类型语言 / 大型工程,需要更稳的编辑反馈时。
  • 怎么用:配置 LSP 服务器(注意:通常需要你额外安装对应语言服务器)。

Claude 学习资料

Claude Code 从 0 到 1 全攻略:MCP / SubAgent / Agent Skill / Hook_哔哩哔哩_bilibili

Claude 中文 - Claude AI 开发技术社区

Claude Code 中文教程 - AI 编程助手完整使用指南 | 从入门到精通 | Claude Code 中文教程网

Claude Code 快速上手核心指南 | Easy-Vibe 教程

Claude Code 教程 | 菜鸟教程

Zero to Claude Code --- Learn Terminal & AI Pair Programming

claude-howto/zh/README.md at main · luongnv89/claude-howto

Claude Code 完全指南:使用方式、技巧与最佳实践 - knqiufan - 博客园

Claude Code Docs, Guides & Best Practices | ClaudeLog

Anthropic 课程

CC Academy - 实战技巧


Claude Code 中文网 - AI 编程助手教程与技巧 | Claude Code 中文网 - 国内镜像站 | 免费使用指南教程

Claude Code Hub - AI 编程助手使用指南 | Claude Code Hub

Claude Code 中文站 - AI 编程助手 | Claude Code 中文站