本文已收录在Github关注我,紧跟本系列专栏文章,咱们下篇再续!

  • 🚀 魔都架构师 | 全网30W技术追随者
  • 🔧 大厂分布式系统/数据中台实战专家
  • 🏆 主导交易系统百万级流量调优 & 车联网平台架构
  • 🧠 AIGC应用开发先行者 | 区块链落地实践者
  • 🌍 以技术驱动创新,我们的征途是改变世界!
  • 👉 实战干货:编程严选网

0 前言

Claude Code 自带了一套功能完整的内置工具 (built-in tools),可处理常见开发任务,如读取文件、编写代码、执行命令和管理目录。

但 Claude Code 真正强大的地方在于:它能智能地把这些工具组合起来,解决复杂的多步骤任务。

1 Claude Code的工具

Name Purpose 中文解释
Agent Launch a subagent to handle a task 启动一个子代理来处理任务
Bash Run a shell command 运行一个 Shell 命令
Edit Edit a file 编辑文件
Glob Find files based upon a pattern 根据模式查找文件
Grep Search the contents of a file 搜索文件内容
LS List files and directories 列出文件和目录
MultiEdit Make several edits at the same time 同时进行多次编辑
NotebookEdit Write to a cell in a Jupyter notebook 向 Jupyter Notebook 的单元格写入内容
NotebookRead Read a cell 读取 Jupyter Notebook 的单元格
Read Read a file 读取文件
TodoRead Read one of the created to-do’s 读取已创建的待办事项之一
TodoWrite Update the list of to-do’s 更新待办事项列表
WebFetch Fetch from a URL 从 URL 获取内容
WebSearch Search the web 搜索互联网
Write Write to a file 写入文件

下面来看几个实战案例:

2 优化任务

目标:发现性能问题并优化 Chalk 库

任务

运行 Chalk 库的基准测试。对于任何看起来缓慢的结果,找出根本原因并修复它。

Claude Code(执行步骤)

  1. 运行基准测试
    (Run benchmarks)
  2. 编写示例文件以探索最坏情况
    (Write a sample file to explore the worst case)
  3. 使用 CPU 分析器并分析结果
    (Use a CPU profiler and analyze the results)
  4. 实施改进措施
    (Implement improvements)
  5. 验证改进效果
    (Verify improvements)

3 数据分析任务

利用视频流媒体平台用户的数据发现洞察

任务

streaming.csv 文件中的数据进行分析。

Claude Code(执行步骤)

  1. 在 Notebook 中编写代码以检查数据格式
    (Write code in a notebook to examine the data format)
  2. 运行代码并检查结果
    (Run the code and examine the results)
  3. 添加单元格,逐步执行以引导分析过程
    (Add cells, executing each to guide its analysis)
  4. 撰写最终总结
    (Write a final summary)

4 UI样式任务

任务

改进此应用的设计。重点关注聊天界面和头部。

Playwright MCP 服务器

允许 Claude 控制浏览器的一组工具

Claude Code(执行步骤)

  • 打开浏览器
  • 导航至应用
  • 截图
  • 更新样式

5 Github 集成

任务:审查拉取请求中的更改

Github MCP 服务器:一组允许 Claude 与 Github 交互的工具

Claude Code(执行步骤)

  • 阅读拉取请求中的更改
  • 评估代码质量、性能等
  • 撰写总结报告

6 强大的工具使用即是一切

工具使用的强度能带来独特(且出人意料)的益处

Claude Code 可以处理更复杂的任务

  • Claude 会积极地将不同的工具结合起来,以应对更复杂的工作
  • Claude 能够熟练地使用它以前从未见过的工具

Claude Code 具有可扩展性

  • 你可以轻松地为 Claude Code 添加额外的工具(功能)
  • 添加工具允许根据你的特定工作流程进行定制
  • 添加工具使 Claude Code 能够跟上 AI 驱动的开发的快速变化

安全性提升

  • 得益于 Claude 强大的工具使用能力,Claude Code 可轻松浏览代码库
  • Claude Code 不依赖于索引你的代码库,而索引通常需要将你的整个代码库发送到外部服务器
Logo

有“AI”的1024 = 2048,欢迎大家加入2048 AI社区

更多推荐