Claude Code 是 Anthropic 开发的一个人工智能代码助手工具,它作为命令行界面 (CLI) 工具直接在你的终端中运行。它被设计为帮助开发人员更快速地编写代码、解决问题和理解代码库。

Claude Code目前是闭源的,而且使用的话需要单独收费另外充值 Token,因为成本太高,而且封号严重,不太建议直接上手。
为了获取它的系统提示词,本次同样使用了Go起了一个转发后台服务,将原本请求Claude的 API代理到了DeepSeek。
请求转发示意图:
下面是对Claude Code系统提示词和11个功能工具tools参数解析。
API 请求内容结构
{ "model": "deepseek-ai/DeepSeek-V3", "messages": [ { "content": "You are Claude Code, Anthropic's official CLI for Claude...", "role": "system" }, { "content": "1", "role": "user" }, { "content": [ { "text": "API Error: 400 OpenAI API error: {"code":20015,"message":"max_tokens: Must be less than or equal to 4096","data":null}n", "type": "text" } ], "role": "assistant" }, { "content": "<bash-input>cd /tmp</bash-input>", "role": "user" }, { "content": [ { "text": "<bash-stdout>Changed directory to u001b[1m/tmp/u001b[22m</bash-stdout>", "type": "text" } ], "role": "assistant" }, { "content": "ls", "role": "user" }, { "content": [ { "text": "API Error: 400 OpenAI API error: {"code":20015,"message":"max_tokens: Must be less than or equal to 4096","data":null}n", "type": "text" } ], "role": "assistant" }, { "content": [ { "text": "ls", "type": "text" } ], "role": "user" } ], "max_tokens": 16384, "temperature": 1, "stream": true, "tools": [ // 这里是工具数组,包含各种工具的定义 ] }
工具数组(tools)定义了模型可以使用的11个功能工具。以下是对每个工具的详细解析:
1. dispatch_agent
{ "function": {"description": "Launch a new agent that has access to the following tools: View, GlobTool, GrepTool, LS, ReadNotebook. When you are searching for a keyword or file and are not confident that you will find the right match in the first few tries, use the Agent tool to perform the search for you...","name": "dispatch_agent","parameters": {"$schema": "http://json-schema.org/draft-07/schema#","additionalProperties": false,"properties": {"prompt": {"description": "The task for the agent to perform","type": "string"}},"required": ["prompt"],"type": "object"} }, "type": "function"}
功能: 启动新的代理进程,该代理可以访问View、GlobTool、GrepTool、LS和ReadNotebook工具
适用场景: 搜索关键词或文件,特别是在不确定能否快速找到匹配时
参数:
prompt(必需): 字符串,描述代理需要执行的任务
使用注意:
- 可以并行启动多个代理以提高性能
- 代理完成后会返回一条消息,该消息对用户不可见
- 代理调用是无状态的,不能发送额外消息
- 代理不能使用Bash、Replace、Edit、NotebookEditCell等修改文件的工具
2. Bash
{ "function": {"description": "Executes a given bash command in a persistent shell session with optional timeout, ensuring proper handling and security measures...","name": "Bash","parameters": {"$schema": "http://json-schema.org/draft-07/schema#","additionalProperties": false,"properties": {"command": {"description": "The command to execute","type": "string"},"timeout": {"description": "Optional timeout in milliseconds (max 600000)","type": "number"}},"required": ["command"],"type": "object"} }, "type": "function"}
功能: 在持久化的shell会话中执行bash命令
参数:
command(必需): 要执行的命令timeout(可选): 超时时间(毫秒),最大600000ms(10分钟)
使用规则:
- 创建文件前先验证目录路径
- 禁止使用特定命令(alias, curl, wget等)
- 避免使用搜索命令如
find和grep,使用专用工具代替 - 避免使用
cat、head、tail、ls等,使用View和LS工具代替 - 命令共享同一个shell会话,环境变量等状态会持续
- 提供详细的git提交和PR创建流程指导
3. BatchTool
{ "function": {"description": "Batch execution tool that runs multiple tool invocations in a single request...","name": "BatchTool","parameters": {"$schema": "http://json-schema.org/draft-07/schema#","additionalProperties": false,"properties": {"description": {"description": "A short (3-5 word) description of the batch operation","type": "string"},"invocations": {"description": "The list of tool invocations to execute","items": {"additionalProperties": false,"properties": {"input": {"additionalProperties": {},"description": "The input to pass to the tool","type": "object"},"tool_name": {"description": "The name of the tool to invoke","type": "string"}},"required": ["tool_name", "input"],"type": "object"},"type": "array"}},"required": ["description", "invocations"],"type": "object"} }, "type": "function"}
功能: 批量执行多个工具调用
参数:
description(必需): 批处理操作的简短描述(3-5个词)invocations(必需): 要执行的工具调用列表,每个包含:tool_name: 工具名称input: 传递给工具的输入参数
特点:
- 并行执行工具调用
- 减少上下文使用和延迟
- 工具输出不直接显示给用户,需要后续消息展示
4. GlobTool
{ "function": {"description": "Fast file pattern matching tool that works with any codebase size...","name": "GlobTool","parameters": {"$schema": "http://json-schema.org/draft-07/schema#","additionalProperties": false,"properties": {"path": {"description": "The directory to search in. Defaults to the current working directory.","type": "string"},"pattern": {"description": "The glob pattern to match files against","type": "string"}},"required": ["pattern"],"type": "object"} }, "type": "function"}
功能: 文件名模式匹配
参数:
pattern(必需): glob模式,如**/*.js或src/**/*.tspath(可选): 搜索目录,默认为当前工作目录
特点:
- 适用于任何规模的代码库
- 按修改时间排序返回匹配的文件路径
- 适合按名称模式查找文件
5. GrepTool
{ "function": {"description": "Fast content search tool that works with any codebase size...","name": "GrepTool","parameters": {"$schema": "http://json-schema.org/draft-07/schema#","additionalProperties": false,"properties": {"include": {"description": "File pattern to include in the search (e.g. "*.js", "*.{ts,tsx}")","type": "string"},"path": {"description": "The directory to search in. Defaults to the current working directory.","type": "string"},"pattern": {"description": "The regular expression pattern to search for in file contents","type": "string"}},"required": ["pattern"],"type": "object"} }, "type": "function"}
功能: 文件内容搜索
参数:
pattern(必需): 正则表达式,如log.*Error或functions+w+path(可选): 搜索目录,默认为当前工作目录include(可选): 文件模式筛选,如*.js或*.{ts,tsx}
特点:
- 使用正则表达式搜索文件内容
- 按修改时间排序返回匹配文件
- 适合查找包含特定内容的文件
6. LS
{ "function": {"description": "Lists files and directories in a given path...","name": "LS","parameters": {"$schema": "http://json-schema.org/draft-07/schema#","additionalProperties": false,"properties": {"ignore": {"description": "List of glob patterns to ignore","items": {"type": "string"},"type": "array"},"path": {"description": "The absolute path to the directory to list (must be absolute, not relative)","type": "string"}},"required": ["path"],"type": "object"} }, "type": "function"}
功能: 列出目录中的文件和子目录
参数:
path(必需): 要列出内容的目录的绝对路径ignore(可选): 要忽略的glob模式列表
注意:
- 路径必须是绝对路径,不能是相对路径
- 如果知道要搜索的目录,通常应优先使用GlobTool和GrepTool
7. View
{ "function": {"description": "Reads a file from the local filesystem...","name": "View","parameters": {"$schema": "http://json-schema.org/draft-07/schema#","additionalProperties": false,"properties": {"file_path": {"description": "The absolute path to the file to read","type": "string"},"limit": {"description": "The number of lines to read. Only provide if the file is too large to read at once.","type": "number"},"offset": {"description": "The line number to start reading from. Only provide if the file is too large to read at once","type": "number"}},"required": ["file_path"],"type": "object"} }, "type": "function"}
功能: 读取本地文件系统中的文件
参数:
file_path(必需): 要读取的文件的绝对路径offset(可选): 起始行号,仅当文件太大无法一次读取时使用limit(可选): 要读取的行数,仅当文件太大无法一次读取时使用
特点:
- 默认从文件开始读取最多2000行
- 任何长度超过2000字符的行会被截断
- 结果使用cat -n格式返回,行号从1开始
- 对于图像文件,会显示图像
- Jupyter笔记本(.ipynb)文件应使用ReadNotebook工具
8. Edit
{ "function": {"description": "This is a tool for editing files...","name": "Edit","parameters": {"$schema": "http://json-schema.org/draft-07/schema#","additionalProperties": false,"properties": {"file_path": {"description": "The absolute path to the file to modify","type": "string"},"new_string": {"description": "The text to replace it with","type": "string"},"old_string": {"description": "The text to replace","type": "string"}},"required": ["file_path", "old_string", "new_string"],"type": "object"} }, "type": "function"}
功能: 编辑文件内容
参数:
file_path(必需): 要修改的文件的绝对路径old_string(必需): 要替换的文本new_string(必需): 替换的新文本
关键要求:
- 唯一性: old_string必须唯一标识要修改的实例,包括至少3-5行上下文
- 单一实例: 工具每次只能替换一个实例
- 验证: 使用前检查目标文本的实例数量,确保有足够上下文唯一标识
- 创建新文件时使用空的old_string和完整内容作为new_string
9. Replace
{ "function": {"description": "Write a file to the local filesystem. Overwrites the existing file if there is one...","name": "Replace","parameters": {"$schema": "http://json-schema.org/draft-07/schema#","additionalProperties": false,"properties": {"content": {"description": "The content to write to the file","type": "string"},"file_path": {"description": "The absolute path to the file to write (must be absolute, not relative)","type": "string"}},"required": ["file_path", "content"],"type": "object"} }, "type": "function"}
功能: 创建或覆盖文件
参数:
file_path(必需): 要写入的文件的绝对路径content(必需): 要写入文件的内容
使用前:
- 使用View工具了解文件内容和上下文
- 创建新文件时验证父目录是否存在
10. ReadNotebook
{ "function": {"description": "Reads a Jupyter notebook (.ipynb file) and returns all of the cells with their outputs...","name": "ReadNotebook","parameters": {"$schema": "http://json-schema.org/draft-07/schema#","additionalProperties": false,"properties": {"notebook_path": {"description": "The absolute path to the Jupyter notebook file to read (must be absolute, not relative)","type": "string"}},"required": ["notebook_path"],"type": "object"} }, "type": "function"}
功能: 读取Jupyter笔记本文件
参数:
notebook_path(必需): Jupyter笔记本文件的绝对路径
说明:
- 返回笔记本中所有单元格及其输出
- 路径必须是绝对路径,不能是相对路径
11. NotebookEditCell
{ "function": {"description": "Completely replaces the contents of a specific cell in a Jupyter notebook (.ipynb file) with new source...","name": "NotebookEditCell","parameters": {"$schema": "http://json-schema.org/draft-07/schema#","additionalProperties": false,"properties": {"cell_number": {"description": "The index of the cell to edit (0-based)","type": "number"},"cell_type": {"description": "The type of the cell (code or markdown). If not specified, it defaults to the current cell type. If using edit_mode=insert, this is required.","enum": ["code", "markdown"],"type": "string"},"edit_mode": {"description": "The type of edit to make (replace, insert, delete). Defaults to replace.","type": "string"},"new_source": {"description": "The new source for the cell","type": "string"},"notebook_path": {"description": "The absolute path to the Jupyter notebook file to edit (must be absolute, not relative)","type": "string"}},"required": ["notebook_path", "cell_number", "new_source"],"type": "object"} }, "type": "function"}
功能: 编辑Jupyter笔记本中的特定单元格
参数:
notebook_path(必需): 笔记本文件的绝对路径cell_number(必需): 要编辑的单元格索引(从0开始)new_source(必需): 单元格的新内容cell_type(可选): 单元格类型(code或markdown),使用edit_mode=insert时必需edit_mode(可选): 编辑类型(replace, insert, delete),默认为replace
模式说明:
- replace: 替换现有单元格内容
- insert: 在指定索引处插入新单元格
- delete: 删除指定索引处的单元格


