微信扫码
添加专属顾问
我要投稿
探索Anthropic的Claude Code,深入了解其系统提示词和内置工具。 核心内容: 1. Claude Code的设计理念和功能概述 2. 系统提示词和11个内置工具的详细解析 3. API请求内容结构和请求转发过程解析
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个功能工具。以下是对每个工具的详细解析:
{ "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
(必需): 字符串,描述代理需要执行的任务使用注意:
{ "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分钟)使用规则:
find
和grep
,使用专用工具代替cat
、head
、tail
、ls
等,使用View和LS工具代替{ "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
: 传递给工具的输入参数特点:
{ "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/**/*.ts
path
(可选): 搜索目录,默认为当前工作目录特点:
{ "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
或function\s+\w+
path
(可选): 搜索目录,默认为当前工作目录include
(可选): 文件模式筛选,如*.js
或*.{ts,tsx}
特点:
{ "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模式列表注意:
{ "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
(可选): 要读取的行数,仅当文件太大无法一次读取时使用特点:
{ "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
(必需): 替换的新文本关键要求:
{ "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
(必需): 要写入文件的内容使用前:
{ "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笔记本文件的绝对路径说明:
{ "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模式说明:
53AI,企业落地大模型首选服务商
产品:场景落地咨询+大模型应用平台+行业解决方案
承诺:免费场景POC验证,效果验证后签署服务协议。零风险落地应用大模型,已交付160+中大型企业
2025-04-30
通俗易懂的梳理MCP的工作流程(以高德地图MCP为例)
2025-04-30
一文说明 Function Calling、MCP、A2A 的区别!
2025-04-30
MCP很好,但它不是万灵药|一文读懂 MCP
2025-04-30
旅行规划太难做?5 分钟构建智能Agent,集成地图 MCP Server
2025-04-29
10万元跑满血版DeepSeek,这家公司掀了一体机市场的桌子|甲子光年
2025-04-29
谷歌大神首次揭秘Gemini预训练秘密:52页PPT干货,推理成本成最重要因素
2025-04-29
一文说清:什么是算法备案、大模型备案、大模型登记 2.0
2025-04-29
MCP:AI时代的“万能插座”,大厂竞逐的焦点
2024-08-13
2024-06-13
2024-08-21
2024-09-23
2024-07-31
2024-05-28
2024-08-04
2024-04-26
2024-07-09
2024-09-17
2025-04-29
2025-04-29
2025-04-29
2025-04-28
2025-04-28
2025-04-28
2025-04-28
2025-04-28