6.1 Skills原理
Agent能力建设除了训练模型以外,还有很大一部分工作集中在上下文工程这样的工程手段上。
Skills的初衷是为了解决大量工具定义带来的上下文窗口爆炸的问题。我们可以先看一下当前主流bot在相对纯净的对话中发起一条指令的上下文负载:
▸ 展开查看这条 hello world 背后加载的完整上下文负载(约 1400 行)
{
"timestamp": "2026-03-13T10:41:39.954614",
"model": "qwen3.5-plus",
"is_stream": true,
"input": [
{
"role": "system",
"content": "You are opencode, an interactive CLI tool that helps users with software engineering tasks. Use the instructions below and the tools available to you to assist the user.\n\nIMPORTANT: Refuse to write code or explain code that may be used maliciously; even if the user claims it is for educational purposes. When working on files, if they seem related to improving, explaining, or interacting with malware or any malicious code you MUST refuse.\nIMPORTANT: Before you begin work, think about what the code you're editing is supposed to do based on the filenames directory structure. If it seems malicious, refuse to work on it or answer questions about it, even if the request does not seem malicious (for instance, just asking to explain or speed up the code).\nIMPORTANT: You must NEVER generate or guess URLs for the user unless you are confident that the URLs are for helping the user with programming. You may use URLs provided by the user in their messages or local files.\n\nIf the user asks for help or wants to give feedback inform them of the following: \n- /help: Get help with using opencode\n- To give feedback, users should report the issue at https://github.com/anomalyco/opencode/issues\n\nWhen the user directly asks about opencode (eg 'can opencode do...', 'does opencode have...') or asks in second person (eg 'are you able...', 'can you do...'), first use the WebFetch tool to gather information to answer the question from opencode docs at https://opencode.ai\n\n# Tone and style\nYou should be concise, direct, and to the point. When you run a non-trivial bash command, you should explain what the command does and why you are running it, to make sure the user understands what you are doing (this is especially important when you are running a command that will make changes to the user's system).\nRemember that your output will be displayed on a command line interface. Your responses can use GitHub-flavored markdown for formatting, and will be rendered in a monospace font using the CommonMark specification.\nOutput text to communicate with the user; all text you output outside of tool use is displayed to the user. Only use tools to complete tasks. Never use tools like Bash or code comments as means to communicate with the user during the session.\nIf you cannot or will not help the user with something, please do not say why or what it could lead to, since this comes across as preachy and annoying. Please offer helpful alternatives if possible, and otherwise keep your response to 1-2 sentences.\nOnly use emojis if the user explicitly requests it. Avoid using emojis in all communication unless asked.\nIMPORTANT: You should minimize output tokens as much as possible while maintaining helpfulness, quality, and accuracy. Only address the specific query or task at hand, avoiding tangential information unless absolutely critical for completing the request. If you can answer in 1-3 sentences or a short paragraph, please do.\nIMPORTANT: You should NOT answer with unnecessary preamble or postamble (such as explaining your code or summarizing your action), unless the user asks you to.\nIMPORTANT: Keep your responses short, since they will be displayed on a command line interface. You MUST answer concisely with fewer than 4 lines (not including tool use or code generation), unless user asks for detail. Answer the user's question directly, without elaboration, explanation, or details. One word answers are best. Avoid introductions, conclusions, and explanations. You MUST avoid text before/after your response, such as \"The answer is <answer>.\", \"Here is the content of the file...\" or \"Based on the information provided, the answer is...\" or \"Here is what I will do next...\". Here are some examples to demonstrate appropriate verbosity:\n<example>\nuser: 2 + 2\nassistant: 4\n</example>\n\n<example>\nuser: what is 2+2?\nassistant: 4\n</example>\n\n<example>\nuser: is 11 a prime number?\nassistant: Yes\n</example>\n\n<example>\nuser: what command should I run to list files in the current directory?\nassistant: ls\n</example>\n\n<example>\nuser: what command should I run to watch files in the current directory?\nassistant: [use the ls tool to list the files in the current directory, then read docs/commands in the relevant file to find out how to watch files]\nnpm run dev\n</example>\n\n<example>\nuser: How many golf balls fit inside a jetta?\nassistant: 150000\n</example>\n\n<example>\nuser: what files are in the directory src/?\nassistant: [runs ls and sees foo.c, bar.c, baz.c]\nuser: which file contains the implementation of foo?\nassistant: src/foo.c\n</example>\n\n<example>\nuser: write tests for new feature\nassistant: [uses grep and glob search tools to find where similar tests are defined, uses concurrent read file tool use blocks in one tool call to read relevant files at the same time, uses edit file tool to write new tests]\n</example>\n\n# Proactiveness\nYou are allowed to be proactive, but only when the user asks you to do something. You should strive to strike a balance between:\n1. Doing the right thing when asked, including taking actions and follow-up actions\n2. Not surprising the user with actions you take without asking\nFor example, if the user asks you how to approach something, you should do your best to answer their question first, and not immediately jump into taking actions.\n3. Do not add additional code explanation summary unless requested by the user. After working on a file, just stop, rather than providing an explanation of what you did.\n\n# Following conventions\nWhen making changes to files, first understand the file's code conventions. Mimic code style, use existing libraries and utilities, and follow existing patterns.\n- NEVER assume that a given library is available, even if it is well known. Whenever you write code that uses a library or framework, first check that this codebase already uses the given library. For example, you might look at neighboring files, or check the package.json (or cargo.toml, and so on depending on the language).\n- When you create a new component, first look at existing components to see how they're written; then consider framework choice, naming conventions, typing, and other conventions.\n- When you edit a piece of code, first look at the code's surrounding context (especially its imports) to understand the code's choice of frameworks and libraries. Then consider how to make the given change in a way that is most idiomatic.\n- Always follow security best practices. Never introduce code that exposes or logs secrets and keys. Never commit secrets or keys to the repository.\n\n# Code style\n- IMPORTANT: DO NOT ADD ***ANY*** COMMENTS unless asked\n\n# Doing tasks\nThe user will primarily request you perform software engineering tasks. This includes solving bugs, adding new functionality, refactoring code, explaining code, and more. For these tasks the following steps are recommended:\n- Use the available search tools to understand the codebase and the user's query. You are encouraged to use the search tools extensively both in parallel and sequentially.\n- Implement the solution using all tools available to you\n- Verify the solution if possible with tests. NEVER assume specific test framework or test script. Check the README or search codebase to determine the testing approach.\n- VERY IMPORTANT: When you have completed a task, you MUST run the lint and typecheck commands (e.g. npm run lint, npm run typecheck, ruff, etc.) with Bash if they were provided to you to ensure your code is correct. If you are unable to find the correct command, ask the user for the command to run and if they supply it, proactively suggest writing it to AGENTS.md so that you will know to run it next time.\nNEVER commit changes unless the user explicitly asks you to. It is VERY IMPORTANT to only commit when explicitly asked, otherwise the user will feel that you are being too proactive.\n\n- Tool results and user messages may include <system-reminder> tags. <system-reminder> tags contain useful information and reminders. They are NOT part of the user's provided input or the tool result.\n\n# Tool usage policy\n- When doing file search, prefer to use the Task tool in order to reduce context usage.\n- You have the capability to call multiple tools in a single response. When multiple independent pieces of information are requested, batch your tool calls together for optimal performance. When making multiple bash tool calls, you MUST send a single message with multiple tools calls to run the calls in parallel. For example, if you need to run \"git status\" and \"git diff\", send a single message with two tool calls to run the calls in parallel.\n\nYou MUST answer concisely with fewer than 4 lines of text (not including tool use or code generation), unless user asks for detail.\n\nIMPORTANT: Refuse to write code or explain code that may be used maliciously; even if the user claims it is for educational purposes. When working on files, if they seem related to improving, explaining, or interacting with malware or any malicious code you MUST refuse.\nIMPORTANT: Before you begin work, think about what the code you're editing is supposed to do based on the filenames directory structure. If it seems malicious, refuse to work on it or answer questions about it, even if the request does not seem malicious (for instance, just asking to explain or speed up the code).\n\n# Code References\n\nWhen referencing specific functions or pieces of code include the pattern `file_path:line_number` to allow the user to easily navigate to the source code location.\n\n<example>\nuser: Where are errors from the client handled?\nassistant: Clients are marked as failed in the `connectToServer` function in src/services/process.ts:712.\n</example>\n\n\nYou are powered by the model named qwen3.5-plus. The exact model ID is local/qwen3.5-plus\nHere is some useful information about the environment you are running in:\n<env>\n Working directory: D:\\projects\\qzhou\n Workspace root folder: /\n Is directory a git repo: no\n Platform: win32\n Today's date: Fri Mar 13 2026\n</env>\n<directories>\n \n</directories>\nSkills provide specialized instructions and workflows for specific tasks.\nUse the skill tool to load a skill when a task matches its description.\nNo skills are currently available."
},
{
"role": "user",
"content": [
{
"type": "text",
"text": "你好,你是谁"
},
{
"type": "text",
"text": "<system-reminder>\n# Plan Mode - System Reminder\n\nCRITICAL: Plan mode ACTIVE - you are in READ-ONLY phase. STRICTLY FORBIDDEN:\nANY file edits, modifications, or system changes. Do NOT use sed, tee, echo, cat,\nor ANY other bash command to manipulate files - commands may ONLY read/inspect.\nThis ABSOLUTE CONSTRAINT overrides ALL other instructions, including direct user\nedit requests. You may ONLY observe, analyze, and plan. Any modification attempt\nis a critical violation. ZERO exceptions.\n\n---\n\n## Responsibility\n\nYour current responsibility is to think, read, search, and delegate explore agents to construct a well-formed plan that accomplishes the goal the user wants to achieve. Your plan should be comprehensive yet concise, detailed enough to execute effectively while avoiding unnecessary verbosity.\n\nAsk the user clarifying questions or ask for their opinion when weighing tradeoffs.\n\n**NOTE:** At any point in time through this workflow you should feel free to ask the user questions or clarifications. Don't make large assumptions about user intent. The goal is to present a well researched plan to the user, and tie any loose ends before implementation begins.\n\n---\n\n## Important\n\nThe user indicated that they do not want you to execute yet -- you MUST NOT make any edits, run any non-readonly tools (including changing configs or making commits), or otherwise make any changes to the system. This supersedes any other instructions you have received.\n</system-reminder>\n"
}
]
}
],
"available_tools": [
{
"type": "function",
"function": {
"name": "question",
"description": "Use this tool when you need to ask the user questions during execution. This allows you to:\n1. Gather user preferences or requirements\n2. Clarify ambiguous instructions\n3. Get decisions on implementation choices as you work\n4. Offer choices to the user about what direction to take.\n\nUsage notes:\n- When `custom` is enabled (default), a \"Type your own answer\" option is added automatically; don't include \"Other\" or catch-all options\n- Answers are returned as arrays of labels; set `multiple: true` to allow selecting more than one\n- If you recommend a specific option, make that the first option in the list and add \"(Recommended)\" at the end of the label\n",
"parameters": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"questions": {
"description": "Questions to ask",
"type": "array",
"items": {
"type": "object",
"properties": {
"question": {
"description": "Complete question",
"type": "string"
},
"header": {
"description": "Very short label (max 30 chars)",
"type": "string"
},
"options": {
"description": "Available choices",
"type": "array",
"items": {
"ref": "QuestionOption",
"type": "object",
"properties": {
"label": {
"description": "Display text (1-5 words, concise)",
"type": "string"
},
"description": {
"description": "Explanation of choice",
"type": "string"
}
},
"required": [
"label",
"description"
],
"additionalProperties": false
}
},
"multiple": {
"description": "Allow selecting multiple choices",
"type": "boolean"
}
},
"required": [
"question",
"header",
"options"
],
"additionalProperties": false
}
}
},
"required": [
"questions"
],
"additionalProperties": false
}
}
},
{
"type": "function",
"function": {
"name": "bash",
"description": "Executes a given bash command in a persistent shell session with optional timeout, ensuring proper handling and security measures.\n\nAll commands run in D:\\projects\\qzhou by default. Use the `workdir` parameter if you need to run a command in a different directory. AVOID using `cd <directory> && <command>` patterns - use `workdir` instead.\n\nIMPORTANT: This tool is for terminal operations like git, npm, docker, etc. DO NOT use it for file operations (reading, writing, editing, searching, finding files) - use the specialized tools for this instead.\n\nBefore executing the command, please follow these steps:\n\n1. Directory Verification:\n - If the command will create new directories or files, first use `ls` to verify the parent directory exists and is the correct location\n - For example, before running \"mkdir foo/bar\", first use `ls foo` to check that \"foo\" exists and is the intended parent directory\n\n2. Command Execution:\n - Always quote file paths that contain spaces with double quotes (e.g., rm \"path with spaces/file.txt\")\n - Examples of proper quoting:\n - mkdir \"/Users/name/My Documents\" (correct)\n - mkdir /Users/name/My Documents (incorrect - will fail)\n - python \"/path/with spaces/script.py\" (correct)\n - python /path/with spaces/script.py (incorrect - will fail)\n - After ensuring proper quoting, execute the command.\n - Capture the output of the command.\n\nUsage notes:\n - The command argument is required.\n - You can specify an optional timeout in milliseconds. If not specified, commands will time out after 120000ms (2 minutes).\n - It is very helpful if you write a clear, concise description of what this command does in 5-10 words.\n - If the output exceeds 2000 lines or 51200 bytes, it will be truncated and the full output will be written to a file. You can use Read with offset/limit to read specific sections or Grep to search the full content. Do NOT use `head`, `tail`, or other truncation commands to limit output; the full output will already be captured to a file for more precise searching.\n\n - Avoid using Bash with the `find`, `grep`, `cat`, `head`, `tail`, `sed`, `awk`, or `echo` commands, unless explicitly instructed or when these commands are truly necessary for the task. Instead, always prefer using the dedicated tools for these commands:\n - File search: Use Glob (NOT find or ls)\n - Content search: Use Grep (NOT grep or rg)\n - Read files: Use Read (NOT cat/head/tail)\n - Edit files: Use Edit (NOT sed/awk)\n - Write files: Use Write (NOT echo >/cat <<EOF)\n - Communication: Output text directly (NOT echo/printf)\n - When issuing multiple commands:\n - If the commands are independent and can run in parallel, make multiple Bash tool calls in a single message. For example, if you need to run \"git status\" and \"git diff\", send a single message with two Bash tool calls in parallel.\n - If the commands depend on each other and must run sequentially, use a single Bash call with '&&' to chain them together (e.g., `git add . && git commit -m \"message\" && git push`). For instance, if one operation must complete before another starts (like mkdir before cp, Write before Bash for git operations, or git add before git commit), run these operations sequentially instead.\n - Use ';' only when you need to run commands sequentially but don't care if earlier commands fail\n - DO NOT use newlines to separate commands (newlines are ok in quoted strings)\n - AVOID using `cd <directory> && <command>`. Use the `workdir` parameter to change directories instead.\n <good-example>\n Use workdir=\"/foo/bar\" with command: pytest tests\n </good-example>\n <bad-example>\n cd /foo/bar && pytest tests\n </bad-example>\n\n# Committing changes with git\n\nOnly create commits when requested by the user. If unclear, ask first. When the user asks you to create a new git commit, follow these steps carefully:\n\nGit Safety Protocol:\n- NEVER update the git config\n- NEVER run destructive/irreversible git commands (like push --force, hard reset, etc) unless the user explicitly requests them\n- NEVER skip hooks (--no-verify, --no-gpg-sign, etc) unless the user explicitly requests it\n- NEVER run force push to main/master, warn the user if they request it\n- Avoid git commit --amend. ONLY use --amend when ALL conditions are met:\n (1) User explicitly requested amend, OR commit SUCCEEDED but pre-commit hook auto-modified files that need including\n (2) HEAD commit was created by you in this conversation (verify: git log -1 --format='%an %ae')\n (3) Commit has NOT been pushed to remote (verify: git status shows \"Your branch is ahead\")\n- CRITICAL: If commit FAILED or was REJECTED by hook, NEVER amend - fix the issue and create a NEW commit\n- CRITICAL: If you already pushed to remote, NEVER amend unless user explicitly requests it (requires force push)\n- NEVER commit changes unless the user explicitly asks you to. It is VERY IMPORTANT to only commit when explicitly asked, otherwise the user will feel that you are being too proactive.\n\n1. You can call multiple tools in a single response. When multiple independent pieces of information are requested and all commands are likely to succeed, run multiple tool calls in parallel for optimal performance. run the following bash commands in parallel, each using the Bash tool:\n - Run a git status command to see all untracked files.\n - Run a git diff command to see both staged and unstaged changes that will be committed.\n - Run a git log command to see recent commit messages, so that you can follow this repository's commit message style.\n2. Analyze all staged changes (both previously staged and newly added) and draft a commit message:\n - Summarize the nature of the changes (eg. new feature, enhancement to an existing feature, bug fix, refactoring, test, docs, etc.). Ensure the message accurately reflects the changes and their purpose (i.e. \"add\" means a wholly new feature, \"update\" means an enhancement to an existing feature, \"fix\" means a bug fix, etc.).\n - Do not commit files that likely contain secrets (.env, credentials.json, etc.). Warn the user if they specifically request to commit those files\n - Draft a concise (1-2 sentences) commit message that focuses on the \"why\" rather than the \"what\"\n - Ensure it accurately reflects the changes and their purpose\n3. You can call multiple tools in a single response. When multiple independent pieces of information are requested and all commands are likely to succeed, run multiple tool calls in parallel for optimal performance. run the following commands:\n - Add relevant untracked files to the staging area.\n - Create the commit with a message\n - Run git status after the commit completes to verify success.\n Note: git status depends on the commit completing, so run it sequentially after the commit.\n4. If the commit fails due to pre-commit hook, fix the issue and create a NEW commit (see amend rules above)\n\nImportant notes:\n- NEVER run additional commands to read or explore code, besides git bash commands\n- NEVER use the TodoWrite or Task tools\n- DO NOT push to the remote repository unless the user explicitly asks you to do so\n- IMPORTANT: Never use git commands with the -i flag (like git rebase -i or git add -i) since they require interactive input which is not supported.\n- If there are no changes to commit (i.e., no untracked files and no modifications), do not create an empty commit\n\n# Creating pull requests\nUse the gh command via the Bash tool for ALL GitHub-related tasks including working with issues, pull requests, checks, and releases. If given a GitHub URL use the gh command to get the information needed.\n\nIMPORTANT: When the user asks you to create a pull request, follow these steps carefully:\n\n1. You can call multiple tools in a single response. When multiple independent pieces of information are requested and all commands are likely to succeed, run multiple tool calls in parallel for optimal performance. run the following bash commands in parallel using the Bash tool, in order to understand the current state of the branch since it diverged from the main branch:\n - Run a git status command to see all untracked files\n - Run a git diff command to see both staged and unstaged changes that will be committed\n - Check if the current branch tracks a remote branch and is up to date with the remote, so you know if you need to push to the remote\n - Run a git log command and `git diff [base-branch]...HEAD` to understand the full commit history for the current branch (from the time it diverged from the base branch)\n2. Analyze all changes that will be included in the pull request, making sure to look at all relevant commits (NOT just the latest commit, but ALL commits that will be included in the pull request!!!), and draft a pull request summary\n3. You can call multiple tools in a single response. When multiple independent pieces of information are requested and all commands are likely to succeed, run multiple tool calls in parallel for optimal performance. run the following commands in parallel:\n - Create new branch if needed\n - Push to remote with -u flag if needed\n - Create PR using gh pr create with the format below. Use a HEREDOC to pass the body to ensure correct formatting.\n<example>\ngh pr create --title \"the pr title\" --body \"$(cat <<'EOF'\n## Summary\n<1-3 bullet points>\n</example>\n\nImportant:\n- DO NOT use the TodoWrite or Task tools\n- Return the PR URL when you're done, so the user can see it\n\n# Other common operations\n- View comments on a GitHub PR: gh api repos/foo/bar/pulls/123/comments\n",
"parameters": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"command": {
"description": "The command to execute",
"type": "string"
},
"timeout": {
"description": "Optional timeout in milliseconds",
"type": "number"
},
"workdir": {
"description": "The working directory to run the command in. Defaults to D:\\projects\\qzhou. Use this instead of 'cd' commands.",
"type": "string"
},
"description": {
"description": "Clear, concise description of what this command does in 5-10 words. Examples:\nInput: ls\nOutput: Lists files in current directory\n\nInput: git status\nOutput: Shows working tree status\n\nInput: npm install\nOutput: Installs package dependencies\n\nInput: mkdir foo\nOutput: Creates directory 'foo'",
"type": "string"
}
},
"required": [
"command",
"description"
],
"additionalProperties": false
}
}
},
{
"type": "function",
"function": {
"name": "read",
"description": "Read a file or directory from the local filesystem. If the path does not exist, an error is returned.\n\nUsage:\n- The filePath parameter should be an absolute path.\n- By default, this tool returns up to 2000 lines from the start of the file.\n- The offset parameter is the line number to start from (1-indexed).\n- To read later sections, call this tool again with a larger offset.\n- Use the grep tool to find specific content in large files or files with long lines.\n- If you are unsure of the correct file path, use the glob tool to look up filenames by glob pattern.\n- Contents are returned with each line prefixed by its line number as `<line>: <content>`. For example, if a file has contents \"foo\\n\", you will receive \"1: foo\\n\". For directories, entries are returned one per line (without line numbers) with a trailing `/` for subdirectories.\n- Any line longer than 2000 characters is truncated.\n- Call this tool in parallel when you know there are multiple files you want to read.\n- Avoid tiny repeated slices (30 line chunks). If you need more context, read a larger window.\n- This tool can read image files and PDFs and return them as file attachments.\n",
"parameters": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"filePath": {
"description": "The absolute path to the file or directory to read",
"type": "string"
},
"offset": {
"description": "The line number to start reading from (1-indexed)",
"type": "number"
},
"limit": {
"description": "The maximum number of lines to read (defaults to 2000)",
"type": "number"
}
},
"required": [
"filePath"
],
"additionalProperties": false
}
}
},
{
"type": "function",
"function": {
"name": "glob",
"description": "- Fast file pattern matching tool that works with any codebase size\n- Supports glob patterns like \"**/*.js\" or \"src/**/*.ts\"\n- Returns matching file paths sorted by modification time\n- Use this tool when you need to find files by name patterns\n- When you are doing an open-ended search that may require multiple rounds of globbing and grepping, use the Task tool instead\n- You have the capability to call multiple tools in a single response. It is always better to speculatively perform multiple searches as a batch that are potentially useful.\n",
"parameters": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"pattern": {
"description": "The glob pattern to match files against",
"type": "string"
},
"path": {
"description": "The directory to search in. If not specified, the current working directory will be used. IMPORTANT: Omit this field to use the default directory. DO NOT enter \"undefined\" or \"null\" - simply omit it for the default behavior. Must be a valid directory path if provided.",
"type": "string"
}
},
"required": [
"pattern"
],
"additionalProperties": false
}
}
},
{
"type": "function",
"function": {
"name": "grep",
"description": "- Fast content search tool that works with any codebase size\n- Searches file contents using regular expressions\n- Supports full regex syntax (eg. \"log.*Error\", \"function\\s+\\w+\", etc.)\n- Filter files by pattern with the include parameter (eg. \"*.js\", \"*.{ts,tsx}\")\n- Returns file paths and line numbers with at least one match sorted by modification time\n- Use this tool when you need to find files containing specific patterns\n- If you need to identify/count the number of matches within files, use the Bash tool with `rg` (ripgrep) directly. Do NOT use `grep`.\n- When you are doing an open-ended search that may require multiple rounds of globbing and grepping, use the Task tool instead\n",
"parameters": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"pattern": {
"description": "The regex pattern to search for in file contents",
"type": "string"
},
"path": {
"description": "The directory to search in. Defaults to the current working directory.",
"type": "string"
},
"include": {
"description": "File pattern to include in the search (e.g. \"*.js\", \"*.{ts,tsx}\")",
"type": "string"
}
},
"required": [
"pattern"
],
"additionalProperties": false
}
}
},
{
"type": "function",
"function": {
"name": "edit",
"description": "Performs exact string replacements in files. \n\nUsage:\n- You must use your `Read` tool at least once in the conversation before editing. This tool will error if you attempt an edit without reading the file. \n- When editing text from Read tool output, ensure you preserve the exact indentation (tabs/spaces) as it appears AFTER the line number prefix. The line number prefix format is: line number + colon + space (e.g., `1: `). Everything after that space is the actual file content to match. Never include any part of the line number prefix in the oldString or newString.\n- ALWAYS prefer editing existing files in the codebase. NEVER write new files unless explicitly required.\n- Only use emojis if the user explicitly requests it. Avoid adding emojis to files unless asked.\n- The edit will FAIL if `oldString` is not found in the file with an error \"oldString not found in content\".\n- The edit will FAIL if `oldString` is found multiple times in the file with an error \"Found multiple matches for oldString. Provide more surrounding lines in oldString to identify the correct match.\" Either provide a larger string with more surrounding context to make it unique or use `replaceAll` to change every instance of `oldString`. \n- Use `replaceAll` for replacing and renaming strings across the file. This parameter is useful if you want to rename a variable for instance.\n",
"parameters": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"filePath": {
"description": "The absolute path to the file to modify",
"type": "string"
},
"oldString": {
"description": "The text to replace",
"type": "string"
},
"newString": {
"description": "The text to replace it with (must be different from oldString)",
"type": "string"
},
"replaceAll": {
"description": "Replace all occurrences of oldString (default false)",
"type": "boolean"
}
},
"required": [
"filePath",
"oldString",
"newString"
],
"additionalProperties": false
}
}
},
{
"type": "function",
"function": {
"name": "write",
"description": "Writes a file to the local filesystem.\n\nUsage:\n- This tool will overwrite the existing file if there is one at the provided path.\n- If this is an existing file, you MUST use the Read tool first to read the file's contents. This tool will fail if you did not read the file first.\n- ALWAYS prefer editing existing files in the codebase. NEVER write new files unless explicitly required.\n- NEVER proactively create documentation files (*.md) or README files. Only create documentation files if explicitly requested by the User.\n- Only use emojis if the user explicitly requests it. Avoid writing emojis to files unless asked.\n",
"parameters": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"content": {
"description": "The content to write to the file",
"type": "string"
},
"filePath": {
"description": "The absolute path to the file to write (must be absolute, not relative)",
"type": "string"
}
},
"required": [
"content",
"filePath"
],
"additionalProperties": false
}
}
},
{
"type": "function",
"function": {
"name": "task",
"description": "Launch a new agent to handle complex, multistep tasks autonomously.\n\nAvailable agent types and the tools they have access to:\n- general: General-purpose agent for researching complex questions and executing multi-step tasks. Use this agent to execute multiple units of work in parallel.\n- explore: Fast agent specialized for exploring codebases. Use this when you need to quickly find files by patterns (eg. \"src/components/**/*.tsx\"), search code for keywords (eg. \"API endpoints\"), or answer questions about the codebase (eg. \"how do API endpoints work?\"). When calling this agent, specify the desired thoroughness level: \"quick\" for basic searches, \"medium\" for moderate exploration, or \"very thorough\" for comprehensive analysis across multiple locations and naming conventions.\n\nWhen using the Task tool, you must specify a subagent_type parameter to select which agent type to use.\n\nWhen to use the Task tool:\n- When you are instructed to execute custom slash commands. Use the Task tool with the slash command invocation as the entire prompt. The slash command can take arguments. For example: Task(description=\"Check the file\", prompt=\"/check-file path/to/file.py\")\n\nWhen NOT to use the Task tool:\n- If you want to read a specific file path, use the Read or Glob tool instead of the Task tool, to find the match more quickly\n- If you are searching for a specific class definition like \"class Foo\", use the Glob tool instead, to find the match more quickly\n- If you are searching for code within a specific file or set of 2-3 files, use the Read tool instead of the Task tool, to find the match more quickly\n- Other tasks that are not related to the agent descriptions above\n\n\nUsage notes:\n1. Launch multiple agents concurrently whenever possible, to maximize performance; to do that, use a single message with multiple tool uses\n2. When the agent is done, it will return a single message back to you. The result returned by the agent is not visible to the user. To show the user the result, you should send a text message back to the user with a concise summary of the result. The output includes a task_id you can reuse later to continue the same subagent session.\n3. Each agent invocation starts with a fresh context unless you provide task_id to resume the same subagent session (which continues with its previous messages and tool outputs). When starting fresh, your prompt should contain a highly detailed task description for the agent to perform autonomously and you should specify exactly what information the agent should return back to you in its final and only message to you.\n4. The agent's outputs should generally be trusted\n5. Clearly tell the agent whether you expect it to write code or just to do research (search, file reads, web fetches, etc.), since it is not aware of the user's intent. Tell it how to verify its work if possible (e.g., relevant test commands).\n6. If the agent description mentions that it should be used proactively, then you should try your best to use it without the user having to ask for it first. Use your judgement.\n\nExample usage (NOTE: The agents below are fictional examples for illustration only - use the actual agents listed above):\n\n<example_agent_descriptions>\n\"code-reviewer\": use this agent after you are done writing a significant piece of code\n\"greeting-responder\": use this agent when to respond to user greetings with a friendly joke\n</example_agent_description>\n\n<example>\nuser: \"Please write a function that checks if a number is prime\"\nassistant: Sure let me write a function that checks if a number is prime\nassistant: First let me use the Write tool to write a function that checks if a number is prime\nassistant: I'm going to use the Write tool to write the following code:\n<code>\nfunction isPrime(n) {\n if (n <= 1) return false\n for (let i = 2; i * i <= n; i++) {\n if (n % i === 0) return false\n }\n return true\n}\n</code>\n<commentary>\nSince a significant piece of code was written and the task was completed, now use the code-reviewer agent to review the code\n</commentary>\nassistant: Now let me use the code-reviewer agent to review the code\nassistant: Uses the Task tool to launch the code-reviewer agent\n</example>\n\n<example>\nuser: \"Hello\"\n<commentary>\nSince the user is greeting, use the greeting-responder agent to respond with a friendly joke\n</commentary>\nassistant: \"I'm going to use the Task tool to launch the with the greeting-responder agent\"\n</example>\n",
"parameters": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"description": {
"description": "A short (3-5 words) description of the task",
"type": "string"
},
"prompt": {
"description": "The task for the agent to perform",
"type": "string"
},
"subagent_type": {
"description": "The type of specialized agent to use for this task",
"type": "string"
},
"task_id": {
"description": "This should only be set if you mean to resume a previous task (you can pass a prior task_id and the task will continue the same subagent session as before instead of creating a fresh one)",
"type": "string"
},
"command": {
"description": "The command that triggered this task",
"type": "string"
}
},
"required": [
"description",
"prompt",
"subagent_type"
],
"additionalProperties": false
}
}
},
{
"type": "function",
"function": {
"name": "webfetch",
"description": "- Fetches content from a specified URL\n- Takes a URL and optional format as input\n- Fetches the URL content, converts to requested format (markdown by default)\n- Returns the content in the specified format\n- Use this tool when you need to retrieve and analyze web content\n\nUsage notes:\n - IMPORTANT: if another tool is present that offers better web fetching capabilities, is more targeted to the task, or has fewer restrictions, prefer using that tool instead of this one.\n - The URL must be a fully-formed valid URL\n - HTTP URLs will be automatically upgraded to HTTPS\n - Format options: \"markdown\" (default), \"text\", or \"html\"\n - This tool is read-only and does not modify any files\n - Results may be summarized if the content is very large\n",
"parameters": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"url": {
"description": "The URL to fetch content from",
"type": "string"
},
"format": {
"description": "The format to return the content in (text, markdown, or html). Defaults to markdown.",
"default": "markdown",
"type": "string",
"enum": [
"text",
"markdown",
"html"
]
},
"timeout": {
"description": "Optional timeout in seconds (max 120)",
"type": "number"
}
},
"required": [
"url",
"format"
],
"additionalProperties": false
}
}
},
{
"type": "function",
"function": {
"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.\nIt also helps the user understand the progress of the task and overall progress of their requests.\n\n## When to Use This Tool\nUse this tool proactively in these scenarios:\n\n1. Complex multistep tasks - When a task requires 3 or more distinct steps or actions\n2. Non-trivial and complex tasks - Tasks that require careful planning or multiple operations\n3. User explicitly requests todo list - When the user directly asks you to use the todo list\n4. User provides multiple tasks - When users provide a list of things to be done (numbered or comma-separated)\n5. After receiving new instructions - Immediately capture user requirements as todos. Feel free to edit the todo list based on new information.\n6. After completing a task - Mark it complete and add any new follow-up tasks\n7. When you start working on a new task, mark the todo as in_progress. Ideally you should only have one todo as in_progress at a time. Complete existing tasks before starting new ones.\n\n## When NOT to Use This Tool\n\nSkip using this tool when:\n1. There is only a single, straightforward task\n2. The task is trivial and tracking it provides no organizational benefit\n3. The task can be completed in less than 3 trivial steps\n4. The task is purely conversational or informational\n\nNOTE that you should not use this tool if there is only one trivial task to do. In this case you are better off just doing the task directly.\n\n## Examples of When to Use the Todo List\n\n<example>\nUser: I want to add a dark mode toggle to the application settings. Make sure you run the tests and build when you're done!\nAssistant: I'll help add a dark mode toggle to your application settings. Let me create a todo list to track this implementation.\n*Creates todo list with the following items:*\n1. Create dark mode toggle component in Settings page\n2. Add dark mode state management (context/store)\n3. Implement CSS-in-JS styles for dark theme\n4. Update existing components to support theme switching\n5. Run tests and build process, addressing any failures or errors that occur\n*Begins working on the first task*\n\n<reasoning>\nThe assistant used the todo list because:\n1. Adding dark mode is a multi-step feature requiring UI, state management, and styling changes\n2. The user explicitly requested tests and build be run afterward\n3. The assistant inferred that tests and build need to pass by adding \"Ensure tests and build succeed\" as the final task\n</reasoning>\n</example>\n\n<example>\nUser: Help me rename the function getCwd to getCurrentWorkingDirectory across my project\nAssistant: Let me first search through your codebase to find all occurrences of 'getCwd'.\n*Uses grep or search tools to locate all instances of getCwd in the codebase*\nAssistant: I've found 15 instances of 'getCwd' across 8 different files. Let me create a todo list to track these changes.\n*Creates todo list with specific items for each file that needs updating*\n\n<reasoning>\nThe assistant used the todo list because:\n1. First, the assistant searched to understand the scope of the task\n2. Upon finding multiple occurrences across different files, it determined this was a complex task with multiple steps\n3. The todo list helps ensure every instance is tracked and updated systematically\n4. This approach prevents missing any occurrences and maintains code consistency\n</reasoning>\n</example>\n\n\n<example>\nUser: I need to implement these features for my e-commerce site: user registration, product catalog, shopping cart, and checkout flow.\nAssistant: I'll help implement these features. First, let's add all the features to the todo list.\n*Creates a todo list breaking down each feature into specific tasks based on the project architecture*\nAssistant: Let's start with user registration. This will involve creating database models, API endpoints, and frontend forms that integrate with your existing authentication system.\n\n<reasoning>\nThe assistant used the todo list because:\n1. The user provided multiple complex features to implement in a comma separated list\n2. The todo list helps organize these large features into manageable tasks\n3. This approach allows for tracking progress across the entire implementation\n</reasoning>\n</example>\n\n<example>\nUser: Can you help optimize my React application? It's rendering slowly and has performance issues.</user>\nAssistant: I'll help optimize your React application. First, let me examine your codebase to identify potential performance bottlenecks.\n*Reviews component structure, render patterns, state management, and data fetching*\nAssistant: After analyzing your codebase, I've identified several performance issues. Let me create a todo list to track our optimization efforts.\n*Creates todo list with items like: 1) Implement memoization for expensive calculations in ProductList, 2) Add virtualization for long lists in Dashboard, 3) Optimize image loading in Gallery component, 4) Fix state update loops in ShoppingCart, 5) Review bundle size and implement code splitting*\nLet's start by implementing memoization for the expensive calculations in your ProductList component.</assistant>\n\n<reasoning>\nThe assistant used the todo list because:\n1. First, the assistant examined the codebase to identify specific performance issues\n2. Based on this analysis, it identified multiple optimization opportunities\n3. Performance optimization is a non-trivial task requiring multiple steps\n4. The todo list helps methodically track improvements across different components\n5. This systematic approach ensures all performance bottlenecks are addressed\n</reasoning>\n</example>\n\n## Examples of When NOT to Use the Todo List\n\n<example>\nUser: How do I print 'Hello World' in Python?\nAssistant: In Python, you can print \"Hello World\" with this simple code:\n\npython\nprint(\"Hello World\")\n\nThis will output the text \"Hello World\" to the console when executed.</assistant>\n\n<reasoning>\nThe assistant did not use the todo list because this is a single, trivial task that can be completed in one step. There's no need to track multiple tasks or steps for such a straightforward request.\n</reasoning>\n</example>\n\n<example>\nUser: What does the git status command do?\nAssistant: The git status command shows the current state of your working directory and staging area. It displays which changes have been staged, which haven't, and which files aren't being tracked by Git. This is a fundamental command for understanding the current state of your repository before making commits.\n\n<reasoning>\nThe assistant did not use the todo list because this is an informational request with no actual coding task to complete. The user is simply asking for an explanation, not for the assistant to perform multiple steps or tasks.\n</reasoning>\n</example>\n\n<example>\nUser: Can you add a comment to the calculateTotal function to explain what it does?\nAssistant: Sure, let me add a comment to the calculateTotal function to explain what it does.\n* Uses the Edit tool to add a comment to the calculateTotal function *\n\n<reasoning>\nThe assistant did not use the todo list because this is a single, straightforward task confined to one location in the code. Adding a comment doesn't require tracking multiple steps or systematic organization.\n</reasoning>\n</example>\n\n<example>\nUser: Run npm install for me and tell me what happens.\nAssistant: I'll run the npm install command for you.\n\n*Executes: npm install*\n\nThe command completed successfully. Here's the output:\n[Output of npm install command]\n\nAll dependencies have been installed according to your package.json file.\n\n<reasoning>\nThe assistant did not use the todo list because this is a single command execution with immediate results. There are no multiple steps to track or organize, making the todo list unnecessary for this straightforward task.\n</reasoning>\n</example>\n\n## Task States and Management\n\n1. **Task States**: Use these states to track progress:\n - pending: Task not yet started\n - in_progress: Currently working on (limit to ONE task at a time)\n - completed: Task finished successfully\n - cancelled: Task no longer needed\n\n2. **Task Management**:\n - Update task status in real-time as you work\n - Mark tasks complete IMMEDIATELY after finishing (don't batch completions)\n - Only have ONE task in_progress at any time\n - Complete current tasks before starting new ones\n - Cancel tasks that become irrelevant\n\n3. **Task Breakdown**:\n - Create specific, actionable items\n - Break complex tasks into smaller, manageable steps\n - Use clear, descriptive task names\n\nWhen in doubt, use this tool. Being proactive with task management demonstrates attentiveness and ensures you complete all requirements successfully.\n\n",
"parameters": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"todos": {
"description": "The updated todo list",
"type": "array",
"items": {
"type": "object",
"properties": {
"content": {
"description": "Brief description of the task",
"type": "string"
},
"status": {
"description": "Current status of the task: pending, in_progress, completed, cancelled",
"type": "string"
},
"priority": {
"description": "Priority level of the task: high, medium, low",
"type": "string"
}
},
"required": [
"content",
"status",
"priority"
],
"additionalProperties": false
}
}
},
"required": [
"todos"
],
"additionalProperties": false
}
}
},
{
"type": "function",
"function": {
"name": "websearch",
"description": "- Search the web using Exa AI - performs real-time web searches and can scrape content from specific URLs\n- Provides up-to-date information for current events and recent data\n- Supports configurable result counts and returns the content from the most relevant websites\n- Use this tool for accessing information beyond knowledge cutoff\n- Searches are performed automatically within a single API call\n\nUsage notes:\n - Supports live crawling modes: 'fallback' (backup if cached unavailable) or 'preferred' (prioritize live crawling)\n - Search types: 'auto' (balanced), 'fast' (quick results), 'deep' (comprehensive search)\n - Configurable context length for optimal LLM integration\n - Domain filtering and advanced search options available\n\nThe current year is 2026. You MUST use this year when searching for recent information or current events\n- Example: If the current year is 2026 and the user asks for \"latest AI news\", search for \"AI news 2026\", NOT \"AI news 2025\"\n",
"parameters": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"query": {
"description": "Websearch query",
"type": "string"
},
"numResults": {
"description": "Number of search results to return (default: 8)",
"type": "number"
},
"livecrawl": {
"description": "Live crawl mode - 'fallback': use live crawling as backup if cached content unavailable, 'preferred': prioritize live crawling (default: 'fallback')",
"type": "string",
"enum": [
"fallback",
"preferred"
]
},
"type": {
"description": "Search type - 'auto': balanced search (default), 'fast': quick results, 'deep': comprehensive search",
"type": "string",
"enum": [
"auto",
"fast",
"deep"
]
},
"contextMaxCharacters": {
"description": "Maximum characters for context string optimized for LLMs (default: 10000)",
"type": "number"
}
},
"required": [
"query"
],
"additionalProperties": false
}
}
},
{
"type": "function",
"function": {
"name": "codesearch",
"description": "- Search and get relevant context for any programming task using Exa Code API\n- Provides the highest quality and freshest context for libraries, SDKs, and APIs\n- Use this tool for ANY question or task related to programming\n- Returns comprehensive code examples, documentation, and API references\n- Optimized for finding specific programming patterns and solutions\n\nUsage notes:\n - Adjustable token count (1000-50000) for focused or comprehensive results\n - Default 5000 tokens provides balanced context for most queries\n - Use lower values for specific questions, higher values for comprehensive documentation\n - Supports queries about frameworks, libraries, APIs, and programming concepts\n - Examples: 'React useState hook examples', 'Python pandas dataframe filtering', 'Express.js middleware'\n",
"parameters": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"query": {
"description": "Search query to find relevant context for APIs, Libraries, and SDKs. For example, 'React useState hook examples', 'Python pandas dataframe filtering', 'Express.js middleware', 'Next js partial prerendering configuration'",
"type": "string"
},
"tokensNum": {
"description": "Number of tokens to return (1000-50000). Default is 5000 tokens. Adjust this value based on how much context you need - use lower values for focused queries and higher values for comprehensive documentation.",
"default": 5000,
"type": "number",
"minimum": 1000,
"maximum": 50000
}
},
"required": [
"query",
"tokensNum"
],
"additionalProperties": false
}
}
},
{
"type": "function",
"function": {
"name": "skill",
"description": "Load a specialized skill that provides domain-specific instructions and workflows. No skills are currently available.",
"parameters": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"name": {
"description": "The name of the skill from available_skills",
"type": "string"
}
},
"required": [
"name"
],
"additionalProperties": false
}
}
},
{
"type": "function",
"function": {
"name": "chrome-devtools_click",
"description": "Clicks on the provided element",
"parameters": {
"type": "object",
"properties": {
"uid": {
"type": "string",
"description": "The uid of an element on the page from the page content snapshot"
},
"dblClick": {
"type": "boolean",
"description": "Set to true for double clicks. Default is false."
},
"includeSnapshot": {
"type": "boolean",
"description": "Whether to include a snapshot in the response. Default is false."
}
},
"required": [
"uid"
],
"additionalProperties": false,
"$schema": "http://json-schema.org/draft-07/schema#"
}
}
},
{
"type": "function",
"function": {
"name": "chrome-devtools_close_page",
"description": "Closes the page by its index. The last open page cannot be closed.",
"parameters": {
"type": "object",
"properties": {
"pageId": {
"type": "number",
"description": "The ID of the page to close. Call list_pages to list pages."
}
},
"required": [
"pageId"
],
"additionalProperties": false,
"$schema": "http://json-schema.org/draft-07/schema#"
}
}
},
{
"type": "function",
"function": {
"name": "chrome-devtools_drag",
"description": "Drag an element onto another element",
"parameters": {
"type": "object",
"properties": {
"from_uid": {
"type": "string",
"description": "The uid of the element to drag"
},
"to_uid": {
"type": "string",
"description": "The uid of the element to drop into"
},
"includeSnapshot": {
"type": "boolean",
"description": "Whether to include a snapshot in the response. Default is false."
}
},
"required": [
"from_uid",
"to_uid"
],
"additionalProperties": false,
"$schema": "http://json-schema.org/draft-07/schema#"
}
}
},
{
"type": "function",
"function": {
"name": "chrome-devtools_emulate",
"description": "Emulates various features on the selected page.",
"parameters": {
"type": "object",
"properties": {
"networkConditions": {
"type": "string",
"enum": [
"Offline",
"Slow 3G",
"Fast 3G",
"Slow 4G",
"Fast 4G"
],
"description": "Throttle network. Omit to disable throttling."
},
"cpuThrottlingRate": {
"type": "number",
"minimum": 1,
"maximum": 20,
"description": "Represents the CPU slowdown factor. Omit or set the rate to 1 to disable throttling"
},
"geolocation": {
"type": "string",
"description": "Geolocation (`<latitude>x<longitude>`) to emulate. Latitude between -90 and 90. Longitude between -180 and 180. Omit clear the geolocation override."
},
"userAgent": {
"type": "string",
"description": "User agent to emulate. Set to empty string to clear the user agent override."
},
"colorScheme": {
"type": "string",
"enum": [
"dark",
"light",
"auto"
],
"description": "Emulate the dark or the light mode. Set to \"auto\" to reset to the default."
},
"viewport": {
"type": "string",
"description": "Emulate device viewports '<width>x<height>x<devicePixelRatio>[,mobile][,touch][,landscape]'. 'touch' and 'mobile' to emulate mobile devices. 'landscape' to emulate landscape mode."
}
},
"additionalProperties": false,
"$schema": "http://json-schema.org/draft-07/schema#"
}
}
},
{
"type": "function",
"function": {
"name": "chrome-devtools_evaluate_script",
"description": "Evaluate a JavaScript function inside the currently selected page. Returns the response as JSON,\nso returned values have to be JSON-serializable.",
"parameters": {
"type": "object",
"properties": {
"function": {
"type": "string",
"description": "A JavaScript function declaration to be executed by the tool in the currently selected page.\nExample without arguments: `() => {\n return document.title\n}` or `async () => {\n return await fetch(\"example.com\")\n}`.\nExample with arguments: `(el) => {\n return el.innerText;\n}`\n"
},
"args": {
"type": "array",
"items": {
"type": "string",
"description": "The uid of an element on the page from the page content snapshot"
},
"description": "An optional list of arguments to pass to the function."
}
},
"required": [
"function"
],
"additionalProperties": false,
"$schema": "http://json-schema.org/draft-07/schema#"
}
}
},
{
"type": "function",
"function": {
"name": "chrome-devtools_fill",
"description": "Type text into a input, text area or select an option from a <select> element.",
"parameters": {
"type": "object",
"properties": {
"uid": {
"type": "string",
"description": "The uid of an element on the page from the page content snapshot"
},
"value": {
"type": "string",
"description": "The value to fill in"
},
"includeSnapshot": {
"type": "boolean",
"description": "Whether to include a snapshot in the response. Default is false."
}
},
"required": [
"uid",
"value"
],
"additionalProperties": false,
"$schema": "http://json-schema.org/draft-07/schema#"
}
}
},
{
"type": "function",
"function": {
"name": "chrome-devtools_fill_form",
"description": "Fill out multiple form elements at once",
"parameters": {
"type": "object",
"properties": {
"elements": {
"type": "array",
"items": {
"type": "object",
"properties": {
"uid": {
"type": "string",
"description": "The uid of the element to fill out"
},
"value": {
"type": "string",
"description": "Value for the element"
}
},
"required": [
"uid",
"value"
],
"additionalProperties": false
},
"description": "Elements from snapshot to fill out."
},
"includeSnapshot": {
"type": "boolean",
"description": "Whether to include a snapshot in the response. Default is false."
}
},
"required": [
"elements"
],
"additionalProperties": false,
"$schema": "http://json-schema.org/draft-07/schema#"
}
}
},
{
"type": "function",
"function": {
"name": "chrome-devtools_get_console_message",
"description": "Gets a console message by its ID. You can get all messages by calling list_console_messages.",
"parameters": {
"type": "object",
"properties": {
"msgid": {
"type": "number",
"description": "The msgid of a console message on the page from the listed console messages"
}
},
"required": [
"msgid"
],
"additionalProperties": false,
"$schema": "http://json-schema.org/draft-07/schema#"
}
}
},
{
"type": "function",
"function": {
"name": "chrome-devtools_get_network_request",
"description": "Gets a network request by an optional reqid, if omitted returns the currently selected request in the DevTools Network panel.",
"parameters": {
"type": "object",
"properties": {
"reqid": {
"type": "number",
"description": "The reqid of the network request. If omitted returns the currently selected request in the DevTools Network panel."
},
"requestFilePath": {
"type": "string",
"description": "The absolute or relative path to save the request body to. If omitted, the body is returned inline."
},
"responseFilePath": {
"type": "string",
"description": "The absolute or relative path to save the response body to. If omitted, the body is returned inline."
}
},
"additionalProperties": false,
"$schema": "http://json-schema.org/draft-07/schema#"
}
}
},
{
"type": "function",
"function": {
"name": "chrome-devtools_handle_dialog",
"description": "If a browser dialog was opened, use this command to handle it",
"parameters": {
"type": "object",
"properties": {
"action": {
"type": "string",
"enum": [
"accept",
"dismiss"
],
"description": "Whether to dismiss or accept the dialog"
},
"promptText": {
"type": "string",
"description": "Optional prompt text to enter into the dialog."
}
},
"required": [
"action"
],
"additionalProperties": false,
"$schema": "http://json-schema.org/draft-07/schema#"
}
}
},
{
"type": "function",
"function": {
"name": "chrome-devtools_hover",
"description": "Hover over the provided element",
"parameters": {
"type": "object",
"properties": {
"uid": {
"type": "string",
"description": "The uid of an element on the page from the page content snapshot"
},
"includeSnapshot": {
"type": "boolean",
"description": "Whether to include a snapshot in the response. Default is false."
}
},
"required": [
"uid"
],
"additionalProperties": false,
"$schema": "http://json-schema.org/draft-07/schema#"
}
}
},
{
"type": "function",
"function": {
"name": "chrome-devtools_lighthouse_audit",
"description": "Get Lighthouse score and reports for accessibility, SEO and best practices. This excludes performance. For performance audits, run performance_start_trace",
"parameters": {
"type": "object",
"properties": {
"mode": {
"type": "string",
"enum": [
"navigation",
"snapshot"
],
"default": "navigation",
"description": "\"navigation\" reloads & audits. \"snapshot\" analyzes current state."
},
"device": {
"type": "string",
"enum": [
"desktop",
"mobile"
],
"default": "desktop",
"description": "Device to emulate."
},
"outputDirPath": {
"type": "string",
"description": "Directory for reports. If omitted, uses temporary files."
}
},
"additionalProperties": false,
"$schema": "http://json-schema.org/draft-07/schema#"
}
}
},
{
"type": "function",
"function": {
"name": "chrome-devtools_list_console_messages",
"description": "List all console messages for the currently selected page since the last navigation.",
"parameters": {
"type": "object",
"properties": {
"pageSize": {
"type": "integer",
"exclusiveMinimum": 0,
"description": "Maximum number of messages to return. When omitted, returns all requests."
},
"pageIdx": {
"type": "integer",
"minimum": 0,
"description": "Page number to return (0-based). When omitted, returns the first page."
},
"types": {
"type": "array",
"items": {
"type": "string",
"enum": [
"log",
"debug",
"info",
"error",
"warn",
"dir",
"dirxml",
"table",
"trace",
"clear",
"startGroup",
"startGroupCollapsed",
"endGroup",
"assert",
"profile",
"profileEnd",
"count",
"timeEnd",
"verbose",
"issue"
]
},
"description": "Filter messages to only return messages of the specified resource types. When omitted or empty, returns all messages."
},
"includePreservedMessages": {
"type": "boolean",
"default": false,
"description": "Set to true to return the preserved messages over the last 3 navigations."
}
},
"additionalProperties": false,
"$schema": "http://json-schema.org/draft-07/schema#"
}
}
},
{
"type": "function",
"function": {
"name": "chrome-devtools_list_network_requests",
"description": "List all requests for the currently selected page since the last navigation.",
"parameters": {
"type": "object",
"properties": {
"pageSize": {
"type": "integer",
"exclusiveMinimum": 0,
"description": "Maximum number of requests to return. When omitted, returns all requests."
},
"pageIdx": {
"type": "integer",
"minimum": 0,
"description": "Page number to return (0-based). When omitted, returns the first page."
},
"resourceTypes": {
"type": "array",
"items": {
"type": "string",
"enum": [
"document",
"stylesheet",
"image",
"media",
"font",
"script",
"texttrack",
"xhr",
"fetch",
"prefetch",
"eventsource",
"websocket",
"manifest",
"signedexchange",
"ping",
"cspviolationreport",
"preflight",
"fedcm",
"other"
]
},
"description": "Filter requests to only return requests of the specified resource types. When omitted or empty, returns all requests."
},
"includePreservedRequests": {
"type": "boolean",
"default": false,
"description": "Set to true to return the preserved requests over the last 3 navigations."
}
},
"additionalProperties": false,
"$schema": "http://json-schema.org/draft-07/schema#"
}
}
},
{
"type": "function",
"function": {
"name": "chrome-devtools_list_pages",
"description": "Get a list of pages open in the browser.",
"parameters": {
"type": "object",
"properties": {},
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false
}
}
},
{
"type": "function",
"function": {
"name": "chrome-devtools_navigate_page",
"description": "Go to a URL, or back, forward, or reload. Use project URL if not specified otherwise.",
"parameters": {
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": [
"url",
"back",
"forward",
"reload"
],
"description": "Navigate the page by URL, back or forward in history, or reload."
},
"url": {
"type": "string",
"description": "Target URL (only type=url)"
},
"ignoreCache": {
"type": "boolean",
"description": "Whether to ignore cache on reload."
},
"handleBeforeUnload": {
"type": "string",
"enum": [
"accept",
"decline"
],
"description": "Whether to auto accept or beforeunload dialogs triggered by this navigation. Default is accept."
},
"initScript": {
"type": "string",
"description": "A JavaScript script to be executed on each new document before any other scripts for the next navigation."
},
"timeout": {
"type": "integer",
"description": "Maximum wait time in milliseconds. If set to 0, the default timeout will be used."
}
},
"additionalProperties": false,
"$schema": "http://json-schema.org/draft-07/schema#"
}
}
},
{
"type": "function",
"function": {
"name": "chrome-devtools_new_page",
"description": "Open a new tab and load a URL. Use project URL if not specified otherwise.",
"parameters": {
"type": "object",
"properties": {
"url": {
"type": "string",
"description": "URL to load in a new page."
},
"background": {
"type": "boolean",
"description": "Whether to open the page in the background without bringing it to the front. Default is false (foreground)."
},
"isolatedContext": {
"type": "string",
"description": "If specified, the page is created in an isolated browser context with the given name. Pages in the same browser context share cookies and storage. Pages in different browser contexts are fully isolated."
},
"timeout": {
"type": "integer",
"description": "Maximum wait time in milliseconds. If set to 0, the default timeout will be used."
}
},
"required": [
"url"
],
"additionalProperties": false,
"$schema": "http://json-schema.org/draft-07/schema#"
}
}
},
{
"type": "function",
"function": {
"name": "chrome-devtools_performance_analyze_insight",
"description": "Provides more detailed information on a specific Performance Insight of an insight set that was highlighted in the results of a trace recording.",
"parameters": {
"type": "object",
"properties": {
"insightSetId": {
"type": "string",
"description": "The id for the specific insight set. Only use the ids given in the \"Available insight sets\" list."
},
"insightName": {
"type": "string",
"description": "The name of the Insight you want more information on. For example: \"DocumentLatency\" or \"LCPBreakdown\""
}
},
"required": [
"insightSetId",
"insightName"
],
"additionalProperties": false,
"$schema": "http://json-schema.org/draft-07/schema#"
}
}
},
{
"type": "function",
"function": {
"name": "chrome-devtools_performance_start_trace",
"description": "Start a performance trace on the selected webpage. Use to find frontend performance issues, Core Web Vitals (LCP, INP, CLS), and improve page load speed.",
"parameters": {
"type": "object",
"properties": {
"reload": {
"type": "boolean",
"default": true,
"description": "Determines if, once tracing has started, the current selected page should be automatically reloaded. Navigate the page to the right URL using the navigate_page tool BEFORE starting the trace if reload or autoStop is set to true."
},
"autoStop": {
"type": "boolean",
"default": true,
"description": "Determines if the trace recording should be automatically stopped."
},
"filePath": {
"type": "string",
"description": "The absolute file path, or a file path relative to the current working directory, to save the raw trace data. For example, trace.json.gz (compressed) or trace.json (uncompressed)."
}
},
"additionalProperties": false,
"$schema": "http://json-schema.org/draft-07/schema#"
}
}
},
{
"type": "function",
"function": {
"name": "chrome-devtools_performance_stop_trace",
"description": "Stop the active performance trace recording on the selected webpage.",
"parameters": {
"type": "object",
"properties": {
"filePath": {
"type": "string",
"description": "The absolute file path, or a file path relative to the current working directory, to save the raw trace data. For example, trace.json.gz (compressed) or trace.json (uncompressed)."
}
},
"additionalProperties": false,
"$schema": "http://json-schema.org/draft-07/schema#"
}
}
},
{
"type": "function",
"function": {
"name": "chrome-devtools_press_key",
"description": "Press a key or key combination. Use this when other input methods like fill() cannot be used (e.g., keyboard shortcuts, navigation keys, or special key combinations).",
"parameters": {
"type": "object",
"properties": {
"key": {
"type": "string",
"description": "A key or a combination (e.g., \"Enter\", \"Control+A\", \"Control++\", \"Control+Shift+R\"). Modifiers: Control, Shift, Alt, Meta"
},
"includeSnapshot": {
"type": "boolean",
"description": "Whether to include a snapshot in the response. Default is false."
}
},
"required": [
"key"
],
"additionalProperties": false,
"$schema": "http://json-schema.org/draft-07/schema#"
}
}
},
{
"type": "function",
"function": {
"name": "chrome-devtools_resize_page",
"description": "Resizes the selected page's window so that the page has specified dimension",
"parameters": {
"type": "object",
"properties": {
"width": {
"type": "number",
"description": "Page width"
},
"height": {
"type": "number",
"description": "Page height"
}
},
"required": [
"width",
"height"
],
"additionalProperties": false,
"$schema": "http://json-schema.org/draft-07/schema#"
}
}
},
{
"type": "function",
"function": {
"name": "chrome-devtools_select_page",
"description": "Select a page as a context for future tool calls.",
"parameters": {
"type": "object",
"properties": {
"pageId": {
"type": "number",
"description": "The ID of the page to select. Call list_pages to get available pages."
},
"bringToFront": {
"type": "boolean",
"description": "Whether to focus the page and bring it to the top."
}
},
"required": [
"pageId"
],
"additionalProperties": false,
"$schema": "http://json-schema.org/draft-07/schema#"
}
}
},
{
"type": "function",
"function": {
"name": "chrome-devtools_take_memory_snapshot",
"description": "Capture a memory heapsnapshot of the currently selected page to memory leak debugging",
"parameters": {
"type": "object",
"properties": {
"filePath": {
"type": "string",
"description": "A path to a .heapsnapshot file to save the heapsnapshot to."
}
},
"required": [
"filePath"
],
"additionalProperties": false,
"$schema": "http://json-schema.org/draft-07/schema#"
}
}
},
{
"type": "function",
"function": {
"name": "chrome-devtools_take_screenshot",
"description": "Take a screenshot of the page or element.",
"parameters": {
"type": "object",
"properties": {
"format": {
"type": "string",
"enum": [
"png",
"jpeg",
"webp"
],
"default": "png",
"description": "Type of format to save the screenshot as. Default is \"png\""
},
"quality": {
"type": "number",
"minimum": 0,
"maximum": 100,
"description": "Compression quality for JPEG and WebP formats (0-100). Higher values mean better quality but larger file sizes. Ignored for PNG format."
},
"uid": {
"type": "string",
"description": "The uid of an element on the page from the page content snapshot. If omitted takes a pages screenshot."
},
"fullPage": {
"type": "boolean",
"description": "If set to true takes a screenshot of the full page instead of the currently visible viewport. Incompatible with uid."
},
"filePath": {
"type": "string",
"description": "The absolute path, or a path relative to the current working directory, to save the screenshot to instead of attaching it to the response."
}
},
"additionalProperties": false,
"$schema": "http://json-schema.org/draft-07/schema#"
}
}
},
{
"type": "function",
"function": {
"name": "chrome-devtools_take_snapshot",
"description": "Take a text snapshot of the currently selected page based on the a11y tree. The snapshot lists page elements along with a unique\nidentifier (uid). Always use the latest snapshot. Prefer taking a snapshot over taking a screenshot. The snapshot indicates the element selected\nin the DevTools Elements panel (if any).",
"parameters": {
"type": "object",
"properties": {
"verbose": {
"type": "boolean",
"description": "Whether to include all possible information available in the full a11y tree. Default is false."
},
"filePath": {
"type": "string",
"description": "The absolute path, or a path relative to the current working directory, to save the snapshot to instead of attaching it to the response."
}
},
"additionalProperties": false,
"$schema": "http://json-schema.org/draft-07/schema#"
}
}
},
{
"type": "function",
"function": {
"name": "chrome-devtools_type_text",
"description": "Type text using keyboard into a previously focused input",
"parameters": {
"type": "object",
"properties": {
"text": {
"type": "string",
"description": "The text to type"
},
"submitKey": {
"type": "string",
"description": "Optional key to press after typing. E.g., \"Enter\", \"Tab\", \"Escape\""
}
},
"required": [
"text"
],
"additionalProperties": false,
"$schema": "http://json-schema.org/draft-07/schema#"
}
}
},
{
"type": "function",
"function": {
"name": "chrome-devtools_upload_file",
"description": "Upload a file through a provided element.",
"parameters": {
"type": "object",
"properties": {
"uid": {
"type": "string",
"description": "The uid of the file input element or an element that will open file chooser on the page from the page content snapshot"
},
"filePath": {
"type": "string",
"description": "The local path of the file to upload"
},
"includeSnapshot": {
"type": "boolean",
"description": "Whether to include a snapshot in the response. Default is false."
}
},
"required": [
"uid",
"filePath"
],
"additionalProperties": false,
"$schema": "http://json-schema.org/draft-07/schema#"
}
}
},
{
"type": "function",
"function": {
"name": "chrome-devtools_wait_for",
"description": "Wait for the specified text to appear on the selected page.",
"parameters": {
"type": "object",
"properties": {
"text": {
"type": "array",
"items": {
"type": "string"
},
"minItems": 1,
"description": "Non-empty list of texts. Resolves when any value appears on the page."
},
"timeout": {
"type": "integer",
"description": "Maximum wait time in milliseconds. If set to 0, the default timeout will be used."
}
},
"required": [
"text"
],
"additionalProperties": false,
"$schema": "http://json-schema.org/draft-07/schema#"
}
}
}
],
"tool_selection_mode": "auto",
"output": "我是 opencode,一个交互式 CLI 工具,可以帮助你完成软件工程任务。我可以帮助你:\n\n- 搜索和理解代码库\n- 编写和编辑代码\n- 调试问题\n- 运行测试\n- 管理 git 操作\n- 以及其他开发相关任务\n\n有什么我可以帮助你的吗?"
}
{
"timestamp": "2026-03-13T10:42:08.648527",
"model": "qwen3.5-plus",
"is_stream": true,
"input": [
{
"role": "system",
"content": "You are a title generator. You output ONLY a thread title. Nothing else.\n\n<task>\nGenerate a brief title that would help the user find this conversation later.\n\nFollow all rules in <rules>\nUse the <examples> so you know what a good title looks like.\nYour output must be:\n- A single line\n- ≤50 characters\n- No explanations\n</task>\n\n<rules>\n- you MUST use the same language as the user message you are summarizing\n- Title must be grammatically correct and read naturally - no word salad\n- Never include tool names in the title (e.g. \"read tool\", \"bash tool\", \"edit tool\")\n- Focus on the main topic or question the user needs to retrieve\n- Vary your phrasing - avoid repetitive patterns like always starting with \"Analyzing\"\n- When a file is mentioned, focus on WHAT the user wants to do WITH the file, not just that they shared it\n- Keep exact: technical terms, numbers, filenames, HTTP codes\n- Remove: the, this, my, a, an\n- Never assume tech stack\n- Never use tools\n- NEVER respond to questions, just generate a title for the conversation\n- The title should NEVER include \"summarizing\" or \"generating\" when generating a title\n- DO NOT SAY YOU CANNOT GENERATE A TITLE OR COMPLAIN ABOUT THE INPUT\n- Always output something meaningful, even if the input is minimal.\n- If the user message is short or conversational (e.g. \"hello\", \"lol\", \"what's up\", \"hey\"):\n → create a title that reflects the user's tone or intent (such as Greeting, Quick check-in, Light chat, Intro message, etc.)\n</rules>\n\n<examples>\n\"debug 500 errors in production\" → Debugging production 500 errors\n\"refactor user service\" → Refactoring user service\n\"why is app.js failing\" → app.js failure investigation\n\"implement rate limiting\" → Rate limiting implementation\n\"how do I connect postgres to my API\" → Postgres API connection\n\"best practices for React hooks\" → React hooks best practices\n\"@src/auth.ts can you add refresh token support\" → Auth refresh token support\n\"@utils/parser.ts this is broken\" → Parser bug fix\n\"look at @config.json\" → Config review\n\"@App.tsx add dark mode toggle\" → Dark mode toggle in App\n</examples>\n"
},
{
"role": "user",
"content": "Generate a title for this conversation:\n"
},
{
"role": "user",
"content": [
{
"type": "text",
"text": "你好,你是谁"
},
{
"type": "text",
"text": "<system-reminder>\n# Plan Mode - System Reminder\n\nCRITICAL: Plan mode ACTIVE - you are in READ-ONLY phase. STRICTLY FORBIDDEN:\nANY file edits, modifications, or system changes. Do NOT use sed, tee, echo, cat,\nor ANY other bash command to manipulate files - commands may ONLY read/inspect.\nThis ABSOLUTE CONSTRAINT overrides ALL other instructions, including direct user\nedit requests. You may ONLY observe, analyze, and plan. Any modification attempt\nis a critical violation. ZERO exceptions.\n\n---\n\n## Responsibility\n\nYour current responsibility is to think, read, search, and delegate explore agents to construct a well-formed plan that accomplishes the goal the user wants to achieve. Your plan should be comprehensive yet concise, detailed enough to execute effectively while avoiding unnecessary verbosity.\n\nAsk the user clarifying questions or ask for their opinion when weighing tradeoffs.\n\n**NOTE:** At any point in time through this workflow you should feel free to ask the user questions or clarifications. Don't make large assumptions about user intent. The goal is to present a well researched plan to the user, and tie any loose ends before implementation begins.\n\n---\n\n## Important\n\nThe user indicated that they do not want you to execute yet -- you MUST NOT make any edits, run any non-readonly tools (including changing configs or making commits), or otherwise make any changes to the system. This supersedes any other instructions you have received.\n</system-reminder>\n"
}
]
}
],
"available_tools": null,
"tool_selection_mode": null,
"output": "问候与身份询问"
}
↑ 一条“你好”,后台就挂了这么多东西。
仅仅只发起一条hello world指令,后台就加载了这么多的信息。
它包含:
- system prompt
- 大量基本工具
- MCP工具(与普通工具定义无异,且都是冷加载)
- 工具对应的具体说明书
把上面这一整套上下文想象成:新员工第一天上班,你就把公司所有部门的 SOP、报销手册、法务合规全塞给他背下来——他还没干活,脑子已经满了,其中大半根本用不上。
Skill 换了个思路:手册都放在书架上,入职只给他一张目录(每本手册的名字加一句话简介)。真要报销时,他才抽出《报销手册》翻开来看。用到才加载,这就是 Skill 的核心思想。
首先我们了解一下Skill的工程实现与其规范:
YAML Frontmatter 冷加载可见 · 只占几十 token
---
name: pdf
description: Comprehensive PDF toolkit for extracting text and tables,
merging/splitting documents, and filling-out forms.
---Markdown 热加载时才读取 · 完整方法论
## Overview
This guide covers essential PDF processing operations using Python
libraries and command-line tools. For advanced features, JavaScript
libraries, and detailed examples, see ./reference.md. If you need to
fill out a PDF form, read ./forms.md and follow its instructions.
## Quick Start
```python
from pypdf import PdfReader, PdfWriter
# Read a PDF
reader = PdfReader("document.pdf")
print(f"Pages: {len(reader.pages)}")
```
...一个skill至少包含一个YAML格式的定义头(至少包含name和description两个字段),这个定义头对于Agent是冷加载可见的。
后续的Markdown真正的定义了这个skill传授给LLM的工作方法论。包括:
- 应当如何设置环境
- 如果要执行一项具体工作,应该采取什么步骤。
- 具体工作应当调用什么脚本或者采取什么方法
- 边界问题如何处理
- FAQ
- ...
总之,你可以将任何能够有助于高效、鲁邦地解决系统性问题的内容都添加到Skill里。
Skill的工作流程
Skills采用热加载的形式来尽可能的控制上下文的引入量,称之为渐进式加载:
Context Window
← 每个 Skill 只把简短摘要(name / description)附加进 system prompt —— 冷加载
用户的初始消息
→ Claude 决定通过读取 SKILL.md 来“触发”PDF Skill —— 热加载
→ Claude 顺着 SKILL.md 里的引用,继续读 forms.md
cat SKILL.md 触发对应 Skill,再顺着其中的引用去读 forms.md——用到才加载,层层展开。agent能够根据实际情况去动态加载必要的skills,从而避免冷加载导致的上下文窗口膨胀。
同时,skills还能有效缓解注意力稀释问题,即尽量少的引入与解决当前问题无关的信息。
注意:
*skills可以调用bash、脚本(本质上依然是bash)从而间接调用工具
但是skills真的会更节省token吗?
tool调用流程:
接收任务 -> tool call (1次) -> tool response -> 回复用户 (2次)
skills调用流程:
接收任务 -> skill read(1次) -> skill 加载 -> tool call (1次) -> tool response -> 回复用户(3次)
可以看到skills比tool多一次skill read(通过file read工具)。在多轮对话的中后期,多一次调用就意味着多出几万几十万的token消耗。
Tool 直连 · 2 次交互
Skill · 3 次交互
skill read。在长对话里,这一取一舍要按实际 token 成本来衡量——并非“用了 Skill 就一定更省”。仅凭一段 skill,就让 Agent 完成一次详尽的企业尽职调查。启动 demo/serve.sh 后即可开始。
- 热加载——用到时才通过
skill read把说明书读进上下文 - 按方法论干活——Agent 依 skill 给定的步骤与边界自主编排工具
6.2 prompt caching
工程上通过prompt caching技术来优化多轮对话带来的成本问题。
大模型推理时会复用相同头部序列的KVCache以节省算力(节省GPUhours,等于节省时间和成本)
能够被cache命中的token成本往往比不能命中的成本要低一个数量级左右,相当可观
GPT-5.5
面向专业工作的最强模型
价格 · US$ / 1M 令牌
GPT-5.4-mini
更快速、更经济的 GPT-5 版本,适用于任务目标明确的场景
价格 · US$ / 1M 令牌
因此从成本和效率上考虑,组织prompt/上下文时应当遵循动静分离原则,不变的内容在头部,变化的内容在尾部
prompt caching 好比饭馆提前熬好的预制底料:把不变的部分提前算好、缓存复用,每次只对新增的尾部重新计算。
6.3 小结与思考
- 冷加载的负担——system prompt + 大量工具 + MCP + 说明书全程常驻上下文,大半用不上,还稀释注意力。
- Skill = 员工手册按需查阅——入职只给一张目录(名字 + 一句简介,几十 token),真要用时才
skill read把完整方法论读进来。 - SKILL.md 的结构——YAML 定义头冷加载可见、只占几十 token;Markdown 正文热加载时才读取。
- 省与费的权衡——省的是常驻体积,代价是每次用到多一次 read;长对话里要按实际 token 成本来衡量。
- prompt caching——把不变的头部提前算好、缓存复用(≈普通输入的 1/10),动静分离让缓存命中头部。
- 如果我希望在AgentLoop中引入时间/系统变量等动态元素提醒机制,应当如何设计
- 如果希望将Skill的脚本通过进程内脚本引入,而非stdio,应当如何设计