@protolabsai/proto 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +203 -0
- package/README.md +286 -0
- package/dist/bundled/adversarial-verification/SKILL.md +98 -0
- package/dist/bundled/brainstorming/SKILL.md +171 -0
- package/dist/bundled/coding-agent-standards/SKILL.md +67 -0
- package/dist/bundled/dispatching-parallel-agents/SKILL.md +193 -0
- package/dist/bundled/executing-plans/SKILL.md +77 -0
- package/dist/bundled/finishing-a-development-branch/SKILL.md +213 -0
- package/dist/bundled/loop/SKILL.md +61 -0
- package/dist/bundled/qc-helper/SKILL.md +151 -0
- package/dist/bundled/qc-helper/docs/_meta.ts +30 -0
- package/dist/bundled/qc-helper/docs/common-workflow.md +571 -0
- package/dist/bundled/qc-helper/docs/configuration/_meta.ts +10 -0
- package/dist/bundled/qc-helper/docs/configuration/auth.md +366 -0
- package/dist/bundled/qc-helper/docs/configuration/memory.md +0 -0
- package/dist/bundled/qc-helper/docs/configuration/model-providers.md +542 -0
- package/dist/bundled/qc-helper/docs/configuration/qwen-ignore.md +55 -0
- package/dist/bundled/qc-helper/docs/configuration/settings.md +652 -0
- package/dist/bundled/qc-helper/docs/configuration/themes.md +160 -0
- package/dist/bundled/qc-helper/docs/configuration/trusted-folders.md +61 -0
- package/dist/bundled/qc-helper/docs/extension/_meta.ts +9 -0
- package/dist/bundled/qc-helper/docs/extension/extension-releasing.md +121 -0
- package/dist/bundled/qc-helper/docs/extension/getting-started-extensions.md +299 -0
- package/dist/bundled/qc-helper/docs/extension/introduction.md +303 -0
- package/dist/bundled/qc-helper/docs/features/_meta.ts +18 -0
- package/dist/bundled/qc-helper/docs/features/approval-mode.md +263 -0
- package/dist/bundled/qc-helper/docs/features/arena.md +218 -0
- package/dist/bundled/qc-helper/docs/features/checkpointing.md +77 -0
- package/dist/bundled/qc-helper/docs/features/commands.md +312 -0
- package/dist/bundled/qc-helper/docs/features/headless.md +318 -0
- package/dist/bundled/qc-helper/docs/features/hooks.md +343 -0
- package/dist/bundled/qc-helper/docs/features/language.md +139 -0
- package/dist/bundled/qc-helper/docs/features/lsp.md +453 -0
- package/dist/bundled/qc-helper/docs/features/mcp.md +281 -0
- package/dist/bundled/qc-helper/docs/features/sandbox.md +241 -0
- package/dist/bundled/qc-helper/docs/features/scheduled-tasks.md +139 -0
- package/dist/bundled/qc-helper/docs/features/skills.md +289 -0
- package/dist/bundled/qc-helper/docs/features/sub-agents.md +307 -0
- package/dist/bundled/qc-helper/docs/features/token-caching.md +29 -0
- package/dist/bundled/qc-helper/docs/ide-integration/_meta.ts +4 -0
- package/dist/bundled/qc-helper/docs/ide-integration/ide-companion-spec.md +182 -0
- package/dist/bundled/qc-helper/docs/ide-integration/ide-integration.md +144 -0
- package/dist/bundled/qc-helper/docs/integration-github-action.md +241 -0
- package/dist/bundled/qc-helper/docs/integration-jetbrains.md +81 -0
- package/dist/bundled/qc-helper/docs/integration-vscode.md +39 -0
- package/dist/bundled/qc-helper/docs/integration-zed.md +72 -0
- package/dist/bundled/qc-helper/docs/overview.md +64 -0
- package/dist/bundled/qc-helper/docs/quickstart.md +273 -0
- package/dist/bundled/qc-helper/docs/reference/_meta.ts +4 -0
- package/dist/bundled/qc-helper/docs/reference/keyboard-shortcuts.md +72 -0
- package/dist/bundled/qc-helper/docs/reference/sdk-api.md +524 -0
- package/dist/bundled/qc-helper/docs/support/Uninstall.md +42 -0
- package/dist/bundled/qc-helper/docs/support/_meta.ts +6 -0
- package/dist/bundled/qc-helper/docs/support/tos-privacy.md +112 -0
- package/dist/bundled/qc-helper/docs/support/troubleshooting.md +123 -0
- package/dist/bundled/receiving-code-review/SKILL.md +226 -0
- package/dist/bundled/requesting-code-review/SKILL.md +115 -0
- package/dist/bundled/review/SKILL.md +123 -0
- package/dist/bundled/subagent-driven-development/SKILL.md +292 -0
- package/dist/bundled/subagent-driven-development/code-quality-reviewer-prompt.md +27 -0
- package/dist/bundled/subagent-driven-development/implementer-prompt.md +113 -0
- package/dist/bundled/subagent-driven-development/spec-reviewer-prompt.md +61 -0
- package/dist/bundled/systematic-debugging/SKILL.md +305 -0
- package/dist/bundled/test-driven-development/SKILL.md +396 -0
- package/dist/bundled/using-git-worktrees/SKILL.md +223 -0
- package/dist/bundled/using-superpowers/SKILL.md +117 -0
- package/dist/bundled/verification-before-completion/SKILL.md +147 -0
- package/dist/bundled/writing-plans/SKILL.md +159 -0
- package/dist/bundled/writing-skills/SKILL.md +716 -0
- package/dist/cli.js +483432 -0
- package/dist/sandbox-macos-permissive-closed.sb +32 -0
- package/dist/sandbox-macos-permissive-open.sb +27 -0
- package/dist/sandbox-macos-permissive-proxied.sb +37 -0
- package/dist/sandbox-macos-restrictive-closed.sb +93 -0
- package/dist/sandbox-macos-restrictive-open.sb +96 -0
- package/dist/sandbox-macos-restrictive-proxied.sb +98 -0
- package/dist/vendor/ripgrep/COPYING +3 -0
- package/dist/vendor/ripgrep/arm64-darwin/rg +0 -0
- package/dist/vendor/ripgrep/arm64-linux/rg +0 -0
- package/dist/vendor/ripgrep/x64-darwin/rg +0 -0
- package/dist/vendor/ripgrep/x64-linux/rg +0 -0
- package/dist/vendor/ripgrep/x64-win32/rg.exe +0 -0
- package/dist/vendor/tree-sitter/tree-sitter-bash.wasm +0 -0
- package/dist/vendor/tree-sitter/tree-sitter.wasm +0 -0
- package/package.json +143 -0
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
# Agent Skills
|
|
2
|
+
|
|
3
|
+
> Create, manage, and share Skills to extend Qwen Code's capabilities.
|
|
4
|
+
|
|
5
|
+
This guide shows you how to create, use, and manage Agent Skills in **Qwen Code**. Skills are modular capabilities that extend the model's effectiveness through organized folders containing instructions (and optionally scripts/resources).
|
|
6
|
+
|
|
7
|
+
## Prerequisites
|
|
8
|
+
|
|
9
|
+
- Qwen Code (recent version)
|
|
10
|
+
- Basic familiarity with Qwen Code ([Quickstart](../quickstart.md))
|
|
11
|
+
|
|
12
|
+
## What are Agent Skills?
|
|
13
|
+
|
|
14
|
+
Agent Skills package expertise into discoverable capabilities. Each Skill consists of a `SKILL.md` file with instructions that the model can load when relevant, plus optional supporting files like scripts and templates.
|
|
15
|
+
|
|
16
|
+
### How Skills are invoked
|
|
17
|
+
|
|
18
|
+
Skills are **model-invoked** — the model autonomously decides when to use them based on your request and the Skill's description. This is different from slash commands, which are **user-invoked** (you explicitly type `/command`).
|
|
19
|
+
|
|
20
|
+
If you want to invoke a Skill explicitly, use the `/skills` slash command:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
/skills <skill-name>
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Use autocomplete to browse available Skills and descriptions.
|
|
27
|
+
|
|
28
|
+
### Benefits
|
|
29
|
+
|
|
30
|
+
- Extend Qwen Code for your workflows
|
|
31
|
+
- Share expertise across your team via git
|
|
32
|
+
- Reduce repetitive prompting
|
|
33
|
+
- Compose multiple Skills for complex tasks
|
|
34
|
+
|
|
35
|
+
## Create a Skill
|
|
36
|
+
|
|
37
|
+
Skills are stored as directories containing a `SKILL.md` file.
|
|
38
|
+
|
|
39
|
+
### Personal Skills
|
|
40
|
+
|
|
41
|
+
Personal Skills are available across all your projects. Store them in `~/.qwen/skills/`:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
mkdir -p ~/.qwen/skills/my-skill-name
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Use personal Skills for:
|
|
48
|
+
|
|
49
|
+
- Your individual workflows and preferences
|
|
50
|
+
- Skills you're developing
|
|
51
|
+
- Personal productivity helpers
|
|
52
|
+
|
|
53
|
+
### Project Skills
|
|
54
|
+
|
|
55
|
+
Project Skills are shared with your team. Store them in `.qwen/skills/` within your project:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
mkdir -p .qwen/skills/my-skill-name
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Use project Skills for:
|
|
62
|
+
|
|
63
|
+
- Team workflows and conventions
|
|
64
|
+
- Project-specific expertise
|
|
65
|
+
- Shared utilities and scripts
|
|
66
|
+
|
|
67
|
+
Project Skills can be checked into git and automatically become available to teammates.
|
|
68
|
+
|
|
69
|
+
## Write `SKILL.md`
|
|
70
|
+
|
|
71
|
+
Create a `SKILL.md` file with YAML frontmatter and Markdown content:
|
|
72
|
+
|
|
73
|
+
```yaml
|
|
74
|
+
---
|
|
75
|
+
name: your-skill-name
|
|
76
|
+
description: Brief description of what this Skill does and when to use it
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
# Your Skill Name
|
|
80
|
+
|
|
81
|
+
## Instructions
|
|
82
|
+
Provide clear, step-by-step guidance for Qwen Code.
|
|
83
|
+
|
|
84
|
+
## Examples
|
|
85
|
+
Show concrete examples of using this Skill.
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Field requirements
|
|
89
|
+
|
|
90
|
+
Qwen Code currently validates that:
|
|
91
|
+
|
|
92
|
+
- `name` is a non-empty string
|
|
93
|
+
- `description` is a non-empty string
|
|
94
|
+
|
|
95
|
+
Recommended conventions (not strictly enforced yet):
|
|
96
|
+
|
|
97
|
+
- Use lowercase letters, numbers, and hyphens in `name`
|
|
98
|
+
- Make `description` specific: include both **what** the Skill does and **when** to use it (key words users will naturally mention)
|
|
99
|
+
|
|
100
|
+
## Add supporting files
|
|
101
|
+
|
|
102
|
+
Create additional files alongside `SKILL.md`:
|
|
103
|
+
|
|
104
|
+
```text
|
|
105
|
+
my-skill/
|
|
106
|
+
├── SKILL.md (required)
|
|
107
|
+
├── reference.md (optional documentation)
|
|
108
|
+
├── examples.md (optional examples)
|
|
109
|
+
├── scripts/
|
|
110
|
+
│ └── helper.py (optional utility)
|
|
111
|
+
└── templates/
|
|
112
|
+
└── template.txt (optional template)
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
Reference these files from `SKILL.md`:
|
|
116
|
+
|
|
117
|
+
````markdown
|
|
118
|
+
For advanced usage, see [reference.md](reference.md).
|
|
119
|
+
|
|
120
|
+
Run the helper script:
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
python scripts/helper.py input.txt
|
|
124
|
+
```
|
|
125
|
+
````
|
|
126
|
+
|
|
127
|
+
## View available Skills
|
|
128
|
+
|
|
129
|
+
Qwen Code discovers Skills from:
|
|
130
|
+
|
|
131
|
+
- Personal Skills: `~/.qwen/skills/`
|
|
132
|
+
- Project Skills: `.qwen/skills/`
|
|
133
|
+
- Extension Skills: Skills provided by installed extensions
|
|
134
|
+
|
|
135
|
+
### Extension Skills
|
|
136
|
+
|
|
137
|
+
Extensions can provide custom skills that become available when the extension is enabled. These skills are stored in the extension's `skills/` directory and follow the same format as personal and project skills.
|
|
138
|
+
|
|
139
|
+
Extension skills are automatically discovered and loaded when the extension is installed and enabled.
|
|
140
|
+
|
|
141
|
+
To see which extensions provide skills, check the extension's `qwen-extension.json` file for a `skills` field.
|
|
142
|
+
|
|
143
|
+
To view available Skills, ask Qwen Code directly:
|
|
144
|
+
|
|
145
|
+
```text
|
|
146
|
+
What Skills are available?
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
Or inspect the filesystem:
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
# List personal Skills
|
|
153
|
+
ls ~/.qwen/skills/
|
|
154
|
+
|
|
155
|
+
# List project Skills (if in a project directory)
|
|
156
|
+
ls .qwen/skills/
|
|
157
|
+
|
|
158
|
+
# View a specific Skill's content
|
|
159
|
+
cat ~/.qwen/skills/my-skill/SKILL.md
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
## Test a Skill
|
|
163
|
+
|
|
164
|
+
After creating a Skill, test it by asking questions that match your description.
|
|
165
|
+
|
|
166
|
+
Example: if your description mentions "PDF files":
|
|
167
|
+
|
|
168
|
+
```text
|
|
169
|
+
Can you help me extract text from this PDF?
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
The model autonomously decides to use your Skill if it matches the request — you don't need to explicitly invoke it.
|
|
173
|
+
|
|
174
|
+
## Debug a Skill
|
|
175
|
+
|
|
176
|
+
If Qwen Code doesn't use your Skill, check these common issues:
|
|
177
|
+
|
|
178
|
+
### Make the description specific
|
|
179
|
+
|
|
180
|
+
Too vague:
|
|
181
|
+
|
|
182
|
+
```yaml
|
|
183
|
+
description: Helps with documents
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
Specific:
|
|
187
|
+
|
|
188
|
+
```yaml
|
|
189
|
+
description: Extract text and tables from PDF files, fill forms, merge documents. Use when working with PDFs, forms, or document extraction.
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
### Verify file path
|
|
193
|
+
|
|
194
|
+
- Personal Skills: `~/.qwen/skills/<skill-name>/SKILL.md`
|
|
195
|
+
- Project Skills: `.qwen/skills/<skill-name>/SKILL.md`
|
|
196
|
+
|
|
197
|
+
```bash
|
|
198
|
+
# Personal
|
|
199
|
+
ls ~/.qwen/skills/my-skill/SKILL.md
|
|
200
|
+
|
|
201
|
+
# Project
|
|
202
|
+
ls .qwen/skills/my-skill/SKILL.md
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
### Check YAML syntax
|
|
206
|
+
|
|
207
|
+
Invalid YAML prevents the Skill metadata from loading correctly.
|
|
208
|
+
|
|
209
|
+
```bash
|
|
210
|
+
cat SKILL.md | head -n 15
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
Ensure:
|
|
214
|
+
|
|
215
|
+
- Opening `---` on line 1
|
|
216
|
+
- Closing `---` before Markdown content
|
|
217
|
+
- Valid YAML syntax (no tabs, correct indentation)
|
|
218
|
+
|
|
219
|
+
### View errors
|
|
220
|
+
|
|
221
|
+
Run Qwen Code with debug mode to see Skill loading errors:
|
|
222
|
+
|
|
223
|
+
```bash
|
|
224
|
+
qwen --debug
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
## Share Skills with your team
|
|
228
|
+
|
|
229
|
+
You can share Skills through project repositories:
|
|
230
|
+
|
|
231
|
+
1. Add the Skill under `.qwen/skills/`
|
|
232
|
+
2. Commit and push
|
|
233
|
+
3. Teammates pull the changes
|
|
234
|
+
|
|
235
|
+
```bash
|
|
236
|
+
git add .qwen/skills/
|
|
237
|
+
git commit -m "Add team Skill for PDF processing"
|
|
238
|
+
git push
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
## Update a Skill
|
|
242
|
+
|
|
243
|
+
Edit `SKILL.md` directly:
|
|
244
|
+
|
|
245
|
+
```bash
|
|
246
|
+
# Personal Skill
|
|
247
|
+
code ~/.qwen/skills/my-skill/SKILL.md
|
|
248
|
+
|
|
249
|
+
# Project Skill
|
|
250
|
+
code .qwen/skills/my-skill/SKILL.md
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
Changes take effect the next time you start Qwen Code. If Qwen Code is already running, restart it to load the updates.
|
|
254
|
+
|
|
255
|
+
## Remove a Skill
|
|
256
|
+
|
|
257
|
+
Delete the Skill directory:
|
|
258
|
+
|
|
259
|
+
```bash
|
|
260
|
+
# Personal
|
|
261
|
+
rm -rf ~/.qwen/skills/my-skill
|
|
262
|
+
|
|
263
|
+
# Project
|
|
264
|
+
rm -rf .qwen/skills/my-skill
|
|
265
|
+
git commit -m "Remove unused Skill"
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
## Best practices
|
|
269
|
+
|
|
270
|
+
### Keep Skills focused
|
|
271
|
+
|
|
272
|
+
One Skill should address one capability:
|
|
273
|
+
|
|
274
|
+
- Focused: "PDF form filling", "Excel analysis", "Git commit messages"
|
|
275
|
+
- Too broad: "Document processing" (split into smaller Skills)
|
|
276
|
+
|
|
277
|
+
### Write clear descriptions
|
|
278
|
+
|
|
279
|
+
Help the model discover when to use Skills by including specific triggers:
|
|
280
|
+
|
|
281
|
+
```yaml
|
|
282
|
+
description: Analyze Excel spreadsheets, create pivot tables, and generate charts. Use when working with Excel files, spreadsheets, or .xlsx data.
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
### Test with your team
|
|
286
|
+
|
|
287
|
+
- Does the Skill activate when expected?
|
|
288
|
+
- Are the instructions clear?
|
|
289
|
+
- Are there missing examples or edge cases?
|
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
# Sub-Agents
|
|
2
|
+
|
|
3
|
+
Delegate focused tasks to specialized AI agents with their own system prompts, tool restrictions, and model selection.
|
|
4
|
+
|
|
5
|
+
This page covers how to create and use sub-agents, the configuration format, built-in agents, and multi-agent team coordination.
|
|
6
|
+
|
|
7
|
+
## Create a sub-agent
|
|
8
|
+
|
|
9
|
+
Sub-agents are Markdown files with YAML frontmatter stored in `.proto/agents/` (project) or `~/.proto/agents/` (global). Project agents take precedence over global agents with the same name.
|
|
10
|
+
|
|
11
|
+
### Minimal example
|
|
12
|
+
|
|
13
|
+
Create `.proto/agents/code-reviewer.md`:
|
|
14
|
+
|
|
15
|
+
```markdown
|
|
16
|
+
---
|
|
17
|
+
name: code-reviewer
|
|
18
|
+
description: Reviews code for quality, security, and maintainability
|
|
19
|
+
tools:
|
|
20
|
+
- read_file
|
|
21
|
+
- grep_search
|
|
22
|
+
- glob
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
You are a code reviewer. Analyze code for:
|
|
26
|
+
|
|
27
|
+
- Security vulnerabilities
|
|
28
|
+
- Performance issues
|
|
29
|
+
- Maintainability concerns
|
|
30
|
+
|
|
31
|
+
Provide specific, actionable feedback with file paths and line numbers.
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Use the agent
|
|
35
|
+
|
|
36
|
+
Ask the model naturally and it will delegate based on the `description` field:
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
Review the authentication module for security issues
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Or invoke explicitly:
|
|
43
|
+
|
|
44
|
+
```
|
|
45
|
+
Use the code-reviewer agent to check my recent changes
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Management commands
|
|
49
|
+
|
|
50
|
+
| Command | Purpose |
|
|
51
|
+
| ---------------- | ---------------------------------- |
|
|
52
|
+
| `/agents create` | Guided agent creation wizard |
|
|
53
|
+
| `/agents manage` | View, edit, delete existing agents |
|
|
54
|
+
|
|
55
|
+
## Configuration reference
|
|
56
|
+
|
|
57
|
+
### Frontmatter fields
|
|
58
|
+
|
|
59
|
+
| Field | Required | Description |
|
|
60
|
+
| ---------------------------- | -------- | -------------------------------------------------- |
|
|
61
|
+
| `name` | Yes | Unique identifier (lowercase, hyphens, 2-50 chars) |
|
|
62
|
+
| `description` | Yes | When to delegate to this agent |
|
|
63
|
+
| `tools` | No | Allowlist of permitted tools. Omit to inherit all. |
|
|
64
|
+
| `disallowedTools` | No | Denylist of tools to exclude from inherited set |
|
|
65
|
+
| `permissionMode` | No | `default`, `plan`, `autoEdit`, `yolo` |
|
|
66
|
+
| `modelConfig.model` | No | `haiku`, `sonnet`, `opus`, or full model ID |
|
|
67
|
+
| `modelConfig.temp` | No | Temperature (0-2) |
|
|
68
|
+
| `runConfig.max_turns` | No | Maximum agentic turns |
|
|
69
|
+
| `runConfig.max_time_minutes` | No | Maximum execution time |
|
|
70
|
+
| `color` | No | Display color for UI |
|
|
71
|
+
|
|
72
|
+
### Tool restrictions
|
|
73
|
+
|
|
74
|
+
Two mechanisms control which tools an agent can use:
|
|
75
|
+
|
|
76
|
+
**Allowlist (`tools`)** — Only these tools are available:
|
|
77
|
+
|
|
78
|
+
```yaml
|
|
79
|
+
tools:
|
|
80
|
+
- read_file
|
|
81
|
+
- grep_search
|
|
82
|
+
- glob
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
**Denylist (`disallowedTools`)** — Remove these from the inherited set:
|
|
86
|
+
|
|
87
|
+
```yaml
|
|
88
|
+
disallowedTools:
|
|
89
|
+
- write_file
|
|
90
|
+
- edit
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
When both are specified, `disallowedTools` is applied first, then `tools` filters the remainder.
|
|
94
|
+
|
|
95
|
+
### Permission mode
|
|
96
|
+
|
|
97
|
+
Override the session's permission mode for a specific agent:
|
|
98
|
+
|
|
99
|
+
| Mode | Behavior |
|
|
100
|
+
| ---------- | -------------------------------- |
|
|
101
|
+
| `default` | Standard confirmation prompts |
|
|
102
|
+
| `plan` | Read-only, no file modifications |
|
|
103
|
+
| `autoEdit` | Auto-approve file edits |
|
|
104
|
+
| `yolo` | Auto-approve everything |
|
|
105
|
+
|
|
106
|
+
If the parent session uses bypass permissions, it takes precedence.
|
|
107
|
+
|
|
108
|
+
### Template variables
|
|
109
|
+
|
|
110
|
+
System prompts support `${variable}` syntax. Variables are resolved from `ContextState` at runtime.
|
|
111
|
+
|
|
112
|
+
### Storage hierarchy
|
|
113
|
+
|
|
114
|
+
| Level | Location | Priority |
|
|
115
|
+
| --------- | ------------------------------- | -------- |
|
|
116
|
+
| Session | Passed via SDK at runtime | Highest |
|
|
117
|
+
| Project | `.proto/agents/` | 2 |
|
|
118
|
+
| User | `~/.proto/agents/` | 3 |
|
|
119
|
+
| Extension | Installed extension's `agents/` | 4 |
|
|
120
|
+
| Built-in | Embedded in proto | Lowest |
|
|
121
|
+
|
|
122
|
+
When multiple agents share the same name, higher-priority location wins.
|
|
123
|
+
|
|
124
|
+
## Built-in agents
|
|
125
|
+
|
|
126
|
+
Four agents are always available:
|
|
127
|
+
|
|
128
|
+
| Agent | Purpose | Tools |
|
|
129
|
+
| ----------------- | ---------------------------------------------------- | ------------------ |
|
|
130
|
+
| `general-purpose` | Complex multi-step tasks, code search | All (except Agent) |
|
|
131
|
+
| `Explore` | Fast codebase search and analysis | Read-only |
|
|
132
|
+
| `verify` | Review changes for correctness before finalizing | Read-only |
|
|
133
|
+
| `coordinator` | Orchestrate multi-agent work with task decomposition | All + Agent |
|
|
134
|
+
|
|
135
|
+
## Background execution
|
|
136
|
+
|
|
137
|
+
Agents can run in the background using `run_in_background: true` in the Agent tool call:
|
|
138
|
+
|
|
139
|
+
- Returns immediately with an agent ID
|
|
140
|
+
- Runs concurrently while the main conversation continues
|
|
141
|
+
- Completion notification is injected at the next tool boundary
|
|
142
|
+
- Results appear alongside tool results via mid-turn injection
|
|
143
|
+
|
|
144
|
+
The `coordinator` agent uses this to delegate subtasks in parallel.
|
|
145
|
+
|
|
146
|
+
## Agent teams
|
|
147
|
+
|
|
148
|
+
Teams enable coordinated multi-agent work with shared task visibility and messaging.
|
|
149
|
+
|
|
150
|
+
### Team commands
|
|
151
|
+
|
|
152
|
+
| Command | Description |
|
|
153
|
+
| -------------------------------------- | ------------------------- |
|
|
154
|
+
| `/team list` | List all configured teams |
|
|
155
|
+
| `/team start <name> [member:type ...]` | Create and start a team |
|
|
156
|
+
| `/team status <name>` | Show team member status |
|
|
157
|
+
| `/team stop <name>` | Stop a running team |
|
|
158
|
+
| `/team delete <name>` | Delete a team config |
|
|
159
|
+
|
|
160
|
+
### Start a team
|
|
161
|
+
|
|
162
|
+
```
|
|
163
|
+
/team start research researcher:Explore implementer:general-purpose
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
Default (no members specified): `lead` (coordinator) + `scout` (Explore).
|
|
167
|
+
|
|
168
|
+
Team config is stored at `.proto/teams/{name}/config.json`.
|
|
169
|
+
|
|
170
|
+
### Shared task list
|
|
171
|
+
|
|
172
|
+
Teammates share task visibility through the task system:
|
|
173
|
+
|
|
174
|
+
- **Claim a task**: `claimTask(id, agentId)` atomically assigns and starts it
|
|
175
|
+
- **Find available work**: `getUnclaimedTasks()` returns pending tasks with no assignee
|
|
176
|
+
- Tasks track their `assignee` for ownership
|
|
177
|
+
|
|
178
|
+
### Inter-agent messaging
|
|
179
|
+
|
|
180
|
+
`TeamMailbox` enables direct communication:
|
|
181
|
+
|
|
182
|
+
| Method | Purpose |
|
|
183
|
+
| -------------------------- | ----------------------------------- |
|
|
184
|
+
| `send(from, to, message)` | Direct message to a teammate |
|
|
185
|
+
| `broadcast(from, message)` | Message all teammates except sender |
|
|
186
|
+
| `receive(agentId)` | Drain unread messages |
|
|
187
|
+
| `peek(agentId)` | Read without draining |
|
|
188
|
+
|
|
189
|
+
### Team lifecycle hooks
|
|
190
|
+
|
|
191
|
+
Three hook events fire during team coordination:
|
|
192
|
+
|
|
193
|
+
| Hook | When it fires |
|
|
194
|
+
| --------------- | ---------------------------------------------------------- |
|
|
195
|
+
| `TeammateIdle` | Background agent finishes (exit 2 = reject, send feedback) |
|
|
196
|
+
| `TaskCreated` | Task added to shared list |
|
|
197
|
+
| `TaskCompleted` | Task marked done |
|
|
198
|
+
|
|
199
|
+
See [Hooks](./hooks.md#team-events) for configuration details.
|
|
200
|
+
|
|
201
|
+
## Design guidelines
|
|
202
|
+
|
|
203
|
+
### Single responsibility
|
|
204
|
+
|
|
205
|
+
Each agent should have one clear purpose.
|
|
206
|
+
|
|
207
|
+
```yaml
|
|
208
|
+
# Focused
|
|
209
|
+
name: testing-expert
|
|
210
|
+
description: Writes comprehensive unit and integration tests
|
|
211
|
+
|
|
212
|
+
# Too broad
|
|
213
|
+
name: general-helper
|
|
214
|
+
description: Helps with testing, documentation, review, and deployment
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
### Actionable descriptions
|
|
218
|
+
|
|
219
|
+
Write descriptions that clearly indicate when to delegate:
|
|
220
|
+
|
|
221
|
+
```yaml
|
|
222
|
+
# Clear trigger
|
|
223
|
+
description: Reviews code for security vulnerabilities, performance issues, and maintainability
|
|
224
|
+
|
|
225
|
+
# Vague
|
|
226
|
+
description: A helpful code reviewer
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
### Minimal tool access
|
|
230
|
+
|
|
231
|
+
Grant only the tools the agent needs. Read-only agents should not have `write_file` or `edit`.
|
|
232
|
+
|
|
233
|
+
### Proactive delegation
|
|
234
|
+
|
|
235
|
+
Include "use proactively" in the description to encourage automatic delegation without explicit user request.
|
|
236
|
+
|
|
237
|
+
## SDK subagent configuration
|
|
238
|
+
|
|
239
|
+
When using the [TypeScript SDK](../reference/sdk-api.md), pass subagent configurations directly via the `agents` option. The primary agent decides when to invoke each subagent based on its `description`.
|
|
240
|
+
|
|
241
|
+
```typescript
|
|
242
|
+
import { query, type SubagentConfig } from '@qwen-code/sdk';
|
|
243
|
+
|
|
244
|
+
const reviewer: SubagentConfig = {
|
|
245
|
+
name: 'code-reviewer',
|
|
246
|
+
description:
|
|
247
|
+
'Reviews code for bugs, security issues, and performance problems',
|
|
248
|
+
systemPrompt: `You are a code reviewer. Review diffs for:
|
|
249
|
+
- Logic errors and edge cases
|
|
250
|
+
- Security vulnerabilities
|
|
251
|
+
- Performance regressions
|
|
252
|
+
Output a structured review with severity levels.`,
|
|
253
|
+
level: 'session',
|
|
254
|
+
tools: ['Read', 'Glob', 'Grep', 'Bash'],
|
|
255
|
+
modelConfig: { model: 'claude-sonnet-4-6' },
|
|
256
|
+
};
|
|
257
|
+
|
|
258
|
+
const conversation = query({
|
|
259
|
+
prompt: 'Review the changes in the current branch',
|
|
260
|
+
options: { agents: [reviewer] },
|
|
261
|
+
});
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
### SubagentConfig fields
|
|
265
|
+
|
|
266
|
+
| Field | Required | Type | Description |
|
|
267
|
+
| ---------------------------- | -------- | ----------- | -------------------------------------------------- |
|
|
268
|
+
| `name` | Yes | `string` | Unique identifier |
|
|
269
|
+
| `description` | Yes | `string` | When to delegate to this agent |
|
|
270
|
+
| `systemPrompt` | Yes | `string` | System prompt for the subagent |
|
|
271
|
+
| `level` | Yes | `'session'` | Subagent scope (currently only `'session'`) |
|
|
272
|
+
| `tools` | No | `string[]` | Allowlist of permitted tools. Omit to inherit all. |
|
|
273
|
+
| `modelConfig.model` | No | `string` | Model ID or alias (`haiku`, `sonnet`, `opus`) |
|
|
274
|
+
| `modelConfig.temp` | No | `number` | Temperature (0-2) |
|
|
275
|
+
| `runConfig.max_turns` | No | `number` | Maximum agentic turns |
|
|
276
|
+
| `runConfig.max_time_minutes` | No | `number` | Maximum execution time in minutes |
|
|
277
|
+
| `color` | No | `string` | Display color |
|
|
278
|
+
|
|
279
|
+
### Multiple subagents with different models
|
|
280
|
+
|
|
281
|
+
```typescript
|
|
282
|
+
const architect: SubagentConfig = {
|
|
283
|
+
name: 'architect',
|
|
284
|
+
description: 'Designs system architecture and makes high-level decisions',
|
|
285
|
+
systemPrompt: 'You are a senior architect...',
|
|
286
|
+
level: 'session',
|
|
287
|
+
modelConfig: { model: 'claude-opus-4-6' },
|
|
288
|
+
};
|
|
289
|
+
|
|
290
|
+
const implementer: SubagentConfig = {
|
|
291
|
+
name: 'implementer',
|
|
292
|
+
description: 'Implements code changes based on specifications',
|
|
293
|
+
systemPrompt: 'You implement code changes...',
|
|
294
|
+
level: 'session',
|
|
295
|
+
tools: ['Read', 'Write', 'Edit', 'Glob', 'Grep', 'Bash'],
|
|
296
|
+
modelConfig: { model: 'claude-sonnet-4-6' },
|
|
297
|
+
};
|
|
298
|
+
|
|
299
|
+
const conversation = query({
|
|
300
|
+
prompt: 'Design and implement the caching layer',
|
|
301
|
+
options: { agents: [architect, implementer] },
|
|
302
|
+
});
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
SDK-configured subagents have the highest priority in the [storage hierarchy](#storage-hierarchy) (session level). They override project or user agents with the same name.
|
|
306
|
+
|
|
307
|
+
See the [SDK subagent examples](../../developers/examples/sdk-agents.md) for more patterns.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Token Caching and Cost Optimization
|
|
2
|
+
|
|
3
|
+
Qwen Code automatically optimizes API costs through token caching when using API key authentication. This feature stores frequently used content like system instructions and conversation history to reduce the number of tokens processed in subsequent requests.
|
|
4
|
+
|
|
5
|
+
## How It Benefits You
|
|
6
|
+
|
|
7
|
+
- **Cost reduction**: Less tokens mean lower API costs
|
|
8
|
+
- **Faster responses**: Cached content is retrieved more quickly
|
|
9
|
+
- **Automatic optimization**: No configuration needed - it works behind the scenes
|
|
10
|
+
|
|
11
|
+
## Token caching is available for
|
|
12
|
+
|
|
13
|
+
- API key users (Qwen API key, OpenAI-compatible providers)
|
|
14
|
+
|
|
15
|
+
## Monitoring Your Savings
|
|
16
|
+
|
|
17
|
+
Use the `/stats` command to see your cached token savings:
|
|
18
|
+
|
|
19
|
+
- When active, the stats display shows how many tokens were served from cache
|
|
20
|
+
- You'll see both the absolute number and percentage of cached tokens
|
|
21
|
+
- Example: "10,500 (90.4%) of input tokens were served from the cache, reducing costs."
|
|
22
|
+
|
|
23
|
+
This information is only displayed when cached tokens are being used, which occurs with API key authentication but not with OAuth authentication.
|
|
24
|
+
|
|
25
|
+
## Example Stats Display
|
|
26
|
+
|
|
27
|
+

|
|
28
|
+
|
|
29
|
+
The above image shows an example of the `/stats` command output, highlighting the cached token savings information.
|