/images/hugo/avatar.png

Claude Code Tool 设计

这一节我们来学习 Claude Code 实现的通用基础工具

1. Edit Tool

Edit Tool 的核心需求是实现精准修改。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
name: Edit
description: >-
  对文件执行精确的字符串替换。


  使用方式:

  - 在对话中编辑之前,必须至少使用一次 `Read` 工具。
  如果尝试未读取文件就编辑,此工具将报错。

  - 使用 Read 工具输出的文本进行编辑时,请确保保留行号前缀之后显示的确切缩进(制表符/空格)。
  行号前缀格式为:空格 + 行号 + 制表符。制表符之后的所有内容才是要匹配的实际文件内容。
  切勿在 old_string 或 new_string 中包含行号前缀的任何部分。

  - 始终优先编辑代码库中已存在的文件。除非有明确要求,绝不编写新文件。

  - 仅在用户明确要求时使用emoji。除非被要求,避免向文件添加emoji。

  - 如果 `old_string` 在文件中不唯一,编辑将会失败。
  请提供包含更多周边上下文的更长字符串使其唯一,或使用 `replace_all` 更改每一处 `old_string`。

  - 使用 `replace_all` 在整个文件中替换和重命名字符串。该参数适用于例如重命名变量的场景。
input_schema:
  type: object
  properties:
    file_path:
      type: string
      description: 待修改文件的绝对路径
    old_string:
      type: string
      description: 要替换的文本
    new_string:
      type: string
      description: 用来替换的文本(必须与 old_string 不同)
    replace_all:
      type: boolean
      default: false
      description: 替换所有 old_string 的匹配项(默认为 false)
  required:
    - file_path
    - old_string
    - new_string
  additionalProperties: false
  $schema: http://json-schema.org/draft-07/schema#

2. TodoWriter

English original 中文翻译
name: TodoWrite
description: >- Use this tool to create and manage a structured task list for your current coding session. This helps you track progress, organize complex tasks, and demonstrate thoroughness to the user. It also helps the user understand the progress of the task and overall progress of their requests.
名称:TodoWrite
描述:>- 使用此工具为当前编码会话创建和管理结构化任务列表。它可以帮助你跟踪进度、组织复杂任务,并向用户展示工作的周全程度。它还能帮助用户了解任务的执行进度,以及其请求的整体完成情况。
When to Use This Tool
Use this tool proactively in these scenarios:
  1. Complex multi-step tasks - When a task requires 3 or more distinct steps or actions
  2. Non-trivial and complex tasks - Tasks that require careful planning or multiple operations
  3. User explicitly requests todo list - When the user directly asks you to use the todo list
  4. User provides multiple tasks - When users provide a list of things to be done (numbered or comma-separated)
  5. After receiving new instructions - Immediately capture user requirements as todos
  6. When you start working on a task - Mark it as in_progress BEFORE beginning work. Ideally you should only have one todo as in_progress at a time
  7. After completing a task - Mark it as completed and add any new follow-up tasks discovered during implementation
何时使用此工具


在以下场景中,应主动使用此工具:

Claude Code 核心 Agent 流程

抛开各种争议,Claude Code 还是目前为止最好用的 Coding Agent。我们的目的是从中习得 Agent 开发的最佳实践。

今天我们重点来学习 Claude Code 核心 Agent 流程。

1. Claude Code 的逆向

Claude Code 目前未开源,市面上有关 Claude Code 代码的分析主要是逆向和基于 Source Map 还原代码。

一个持续更新的工具集

本文按用途归类整理 Koala《科技周报》中介绍的工具。“发布时间”优先采用项目首次公开或对应版本正式发布的日期,并通过官方仓库、官网或作者发布记录核验;“Koala 给予的评价”是对字幕中观点的转述,不代表本文作者背书。原文已有但尚未进入本轮字幕与联网核验流程的条目,暂保留“原文未记录”标记。

Rag 信息检索理论

1. 检索核心技术

现代检索系统主要采用两种搜索技术

  1. 语义搜索(Semantic Search): 通过理解文档含义进行匹配
  2. 关键词搜索(Keyword Search)

/images/rag/search.png

Redis Barrier

1. 背景

2.1 背景

项目上需要周期性完成一些计算任务,这些任务具有如下特点:

  1. 任务相似但是独立
  2. 任务执行需要读取过去 7 天的历史数据,但是只有当天数据会更新
  3. 任务计算的性能要求很高,需要充分利用计算资源,尽快完成计算

为了快速完成这些任务的计算,设计了如下的分布式计算系统:

ES 基础

1. 倒排索引

1.1 什么是倒排索引

倒排索引是一种 从内容到文档的映射 数据结构,它和“正向索引”相反。

  • 正向索引:文档 → 内容
  • 倒排索引:内容(词语) → 出现该词语的文档列表

它的核心作用是 快速找到包含某个词的文档,是搜索引擎(比如 ElasticSearch、Lucene)最核心的数据结构。