链载Ai

标题: Claude Code 系统提示词和 11个内置 Tool拆解 [打印本页]

作者: 链载Ai    时间: 昨天 12:44
标题: Claude Code 系统提示词和 11个内置 Tool拆解

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

5c14a5b3-788c-435c-a55d-ae85b1a02e5b.png

Claude Code目前是闭源的,而且使用的话需要单独收费另外充值 Token,因为成本太高,而且封号严重,不太建议直接上手。

为了获取它的系统提示词,本次同样使用了Go起了一个转发后台服务,将原本请求Claude的 API代理到了DeepSeek。

请求转发示意图:

a2438844-9087-4808-bf7c-d3ccab7b4ee5.png

下面是对Claude Code系统提示词和11个功能工具tools参数解析。

API 请求内容结构

{
"model":"deepseek-ai/DeepSeek-V3",
"messages":[
{
"content":"YouareClaudeCode,Anthropic'sofficialCLIforClaude...",
"role":"system"
},
{
"content":"1",
"role":"user"
},
{
"content":[
{
"text":"APIError:400OpenAIAPIerror:{\"code\":20015,\"message\":\"max_tokens:Mustbelessthanorequalto4096\",\"data\":null}\n",
"type":"text"
}
],
"role":"assistant"
},
{
"content":"<bash-input>cd/tmp</bash-input>",
"role":"user"
},
{
"content":[
{
"text":"<bash-stdout>Changeddirectoryto\u001b[1m/tmp/\u001b[22m</bash-stdout>",
"type":"text"
}
],
"role":"assistant"
},
{
"content":"ls",
"role":"user"
},
{
"content":[
{
"text":"APIError:400OpenAIAPIerror:{\"code\":20015,\"message\":\"max_tokens:Mustbelessthanorequalto4096\",\"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":"Launchanewagentthathasaccesstothefollowingtools:View,GlobTool,GrepTool,LS,ReadNotebook.Whenyouaresearchingforakeywordorfileandarenotconfidentthatyouwillfindtherightmatchinthefirstfewtries,usetheAgenttooltoperformthesearchforyou...","name":"dispatch_agent","parameters":{"$schema":"http://json-schema.org/draft-07/schema#","additionalProperties":false,"properties":{"prompt":{"description":"Thetaskfortheagenttoperform","type":"string"}},"required":["prompt"],"type":"object"}
},
"type":"function"}

功能: 启动新的代理进程,该代理可以访问View、GlobTool、GrepTool、LS和ReadNotebook工具
适用场景: 搜索关键词或文件,特别是在不确定能否快速找到匹配时
参数:

使用注意:

2. Bash

{
"function":{"description":"Executesagivenbashcommandinapersistentshellsessionwithoptionaltimeout,ensuringproperhandlingandsecuritymeasures...","name":"Bash","parameters":{"$schema":"http://json-schema.org/draft-07/schema#","additionalProperties":false,"properties":{"command":{"description":"Thecommandtoexecute","type":"string"},"timeout":{"description":"Optionaltimeoutinmilliseconds(max600000)","type":"number"}},"required":["command"],"type":"object"}
},
"type":"function"}

功能: 在持久化的shell会话中执行bash命令
参数:

使用规则:

3. BatchTool

{
"function":{"description":"Batchexecutiontoolthatrunsmultipletoolinvocationsinasinglerequest...","name":"BatchTool","parameters":{"$schema":"http://json-schema.org/draft-07/schema#","additionalProperties":false,"properties":{"description":{"description":"Ashort(3-5word)descriptionofthebatchoperation","type":"string"},"invocations":{"description":"Thelistoftoolinvocationstoexecute","items":{"additionalProperties":false,"properties":{"input":{"additionalProperties":{},"description":"Theinputtopasstothetool","type":"object"},"tool_name":{"description":"Thenameofthetooltoinvoke","type":"string"}},"required":["tool_name","input"],"type":"object"},"type":"array"}},"required":["description","invocations"],"type":"object"}
},
"type":"function"}

功能: 批量执行多个工具调用
参数:

特点:

4. GlobTool

{
"function":{"description":"Fastfilepatternmatchingtoolthatworkswithanycodebasesize...","name":"GlobTool","parameters":{"$schema":"http://json-schema.org/draft-07/schema#","additionalProperties":false,"properties":{"path":{"description":"Thedirectorytosearchin.Defaultstothecurrentworkingdirectory.","type":"string"},"pattern":{"description":"Theglobpatterntomatchfilesagainst","type":"string"}},"required":["pattern"],"type":"object"}
},
"type":"function"}

功能: 文件名模式匹配
参数:

特点:

5. GrepTool

{
"function":{"description":"Fastcontentsearchtoolthatworkswithanycodebasesize...","name":"GrepTool","parameters":{"$schema":"http://json-schema.org/draft-07/schema#","additionalProperties":false,"properties":{"include":{"description":"Filepatterntoincludeinthesearch(e.g.\"*.js\",\"*.{ts,tsx}\")","type":"string"},"path":{"description":"Thedirectorytosearchin.Defaultstothecurrentworkingdirectory.","type":"string"},"pattern":{"description":"Theregularexpressionpatterntosearchforinfilecontents","type":"string"}},"required":["pattern"],"type":"object"}
},
"type":"function"}

功能: 文件内容搜索
参数:

特点:

6. LS

{
"function":{"description":"Listsfilesanddirectoriesinagivenpath...","name":"LS","parameters":{"$schema":"http://json-schema.org/draft-07/schema#","additionalProperties":false,"properties":{"ignore":{"description":"Listofglobpatternstoignore","items":{"type":"string"},"type":"array"},"path":{"description":"Theabsolutepathtothedirectorytolist(mustbeabsolute,notrelative)","type":"string"}},"required":["path"],"type":"object"}
},
"type":"function"}

功能: 列出目录中的文件和子目录
参数:

注意:

7. View

{
"function":{"description":"Readsafilefromthelocalfilesystem...","name":"View","parameters":{"$schema":"http://json-schema.org/draft-07/schema#","additionalProperties":false,"properties":{"file_path":{"description":"Theabsolutepathtothefiletoread","type":"string"},"limit":{"description":"Thenumberoflinestoread.Onlyprovideifthefileistoolargetoreadatonce.","type":"number"},"offset":{"description":"Thelinenumbertostartreadingfrom.Onlyprovideifthefileistoolargetoreadatonce","type":"number"}},"required":["file_path"],"type":"object"}
},
"type":"function"}

功能: 读取本地文件系统中的文件
参数:

特点:

8. Edit

{
"function":{"description":"Thisisatoolforeditingfiles...","name":"Edit","parameters":{"$schema":"http://json-schema.org/draft-07/schema#","additionalProperties":false,"properties":{"file_path":{"description":"Theabsolutepathtothefiletomodify","type":"string"},"new_string":{"description":"Thetexttoreplaceitwith","type":"string"},"old_string":{"description":"Thetexttoreplace","type":"string"}},"required":["file_path","old_string","new_string"],"type":"object"}
},
"type":"function"}

功能: 编辑文件内容
参数:

关键要求:

9. Replace

{
"function":{"description":"Writeafiletothelocalfilesystem.Overwritestheexistingfileifthereisone...","name":"Replace","parameters":{"$schema":"http://json-schema.org/draft-07/schema#","additionalProperties":false,"properties":{"content":{"description":"Thecontenttowritetothefile","type":"string"},"file_path":{"description":"Theabsolutepathtothefiletowrite(mustbeabsolute,notrelative)","type":"string"}},"required":["file_path","content"],"type":"object"}
},
"type":"function"}

功能: 创建或覆盖文件
参数:

使用前:


10. ReadNotebook

{
"function":{"description":"ReadsaJupyternotebook(.ipynbfile)andreturnsallofthecellswiththeiroutputs...","name":"ReadNotebook","parameters":{"$schema":"http://json-schema.org/draft-07/schema#","additionalProperties":false,"properties":{"notebook_path":{"description":"TheabsolutepathtotheJupyternotebookfiletoread(mustbeabsolute,notrelative)","type":"string"}},"required":["notebook_path"],"type":"object"}
},
"type":"function"}

功能: 读取Jupyter笔记本文件
参数:

说明:

11. NotebookEditCell

{
"function":{"description":"CompletelyreplacesthecontentsofaspecificcellinaJupyternotebook(.ipynbfile)withnewsource...","name":"NotebookEditCell","parameters":{"$schema":"http://json-schema.org/draft-07/schema#","additionalProperties":false,"properties":{"cell_number":{"description":"Theindexofthecelltoedit(0-based)","type":"number"},"cell_type":{"description":"Thetypeofthecell(codeormarkdown).Ifnotspecified,itdefaultstothecurrentcelltype.Ifusingedit_mode=insert,thisisrequired.","enum":["code","markdown"],"type":"string"},"edit_mode":{"description":"Thetypeofedittomake(replace,insert,delete).Defaultstoreplace.","type":"string"},"new_source":{"description":"Thenewsourceforthecell","type":"string"},"notebook_path":{"description":"TheabsolutepathtotheJupyternotebookfiletoedit(mustbeabsolute,notrelative)","type":"string"}},"required":["notebook_path","cell_number","new_source"],"type":"object"}
},
"type":"function"}

功能: 编辑Jupyter笔记本中的特定单元格
参数:

模式说明:






欢迎光临 链载Ai (https://www.lianzai.com/) Powered by Discuz! X3.5