You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/users/extension/getting-started-extensions.md
+92-6Lines changed: 92 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -148,22 +148,107 @@ Custom commands provide a way to create shortcuts for complex prompts. Let's add
148
148
mkdir -p commands/fs
149
149
```
150
150
151
-
2. Create a file named `commands/fs/grep-code.toml`:
151
+
2. Create a file named `commands/fs/grep-code.md`:
152
+
153
+
```markdown
154
+
---
155
+
description: Search fora patternin code and summarize findings
156
+
---
152
157
153
-
```toml
154
-
prompt = """
155
158
Please summarize the findings for the pattern `{{args}}`.
156
159
157
160
Search Results:
158
161
!{grep -r {{args}} .}
159
-
"""
160
162
```
161
163
162
164
This command, `/fs:grep-code`, will take an argument, run the `grep` shell command with it, and pipe the results into a prompt for summarization.
163
165
166
+
>**Note:** Commands use Markdown format with optional YAML frontmatter. TOML format is deprecated but still supported for backwards compatibility.
167
+
164
168
After saving the file, restart the Qwen Code. You can now run `/fs:grep-code "some pattern"` to use your new command.
165
169
166
-
## Step 5: Add a Custom `QWEN.md`
170
+
## Step 5: Add Custom Skills and Subagents (Optional)
171
+
172
+
Extensions can also provide custom skills and subagents to extend Qwen Code's capabilities.
173
+
174
+
### Adding a Custom Skill
175
+
176
+
Skills are model-invoked capabilities that the AI can automatically use when relevant.
177
+
178
+
1. Create a `skills` directory with a skill subdirectory:
179
+
180
+
```bash
181
+
mkdir -p skills/code-analyzer
182
+
```
183
+
184
+
2. Create a `skills/code-analyzer/SKILL.md` file:
185
+
186
+
```markdown
187
+
---
188
+
name: code-analyzer
189
+
description: Analyzes code structure and provides insights about complexity, dependencies, and potential improvements
190
+
---
191
+
192
+
# Code Analyzer
193
+
194
+
## Instructions
195
+
196
+
When analyzing code, focus on:
197
+
198
+
- Code complexity and maintainability
199
+
- Dependencies and coupling
200
+
- Potential performance issues
201
+
- Suggestions for improvements
202
+
203
+
## Examples
204
+
205
+
- "Analyze the complexity of this function"
206
+
- "What are the dependencies of this module?"
207
+
```
208
+
209
+
### Adding a Custom Subagent
210
+
211
+
Subagents are specialized AI assistants for specific tasks.
212
+
213
+
1. Create an `agents` directory:
214
+
215
+
```bash
216
+
mkdir -p agents
217
+
```
218
+
219
+
2. Create an `agents/refactoring-expert.md` file:
220
+
221
+
```markdown
222
+
---
223
+
name: refactoring-expert
224
+
description: Specialized in code refactoring, improving code structure and maintainability
225
+
tools:
226
+
- read_file
227
+
- write_file
228
+
- read_many_files
229
+
---
230
+
231
+
You are a refactoring specialist focused on improving code quality.
232
+
233
+
Your expertise includes:
234
+
235
+
- Identifying code smells and anti-patterns
236
+
- Applying SOLID principles
237
+
- Improving code readability and maintainability
238
+
- Safe refactoring with minimal risk
239
+
240
+
For each refactoring task:
241
+
242
+
1. Analyze the current code structure
243
+
2. Identify areas for improvement
244
+
3. Propose refactoring steps
245
+
4. Implement changes incrementally
246
+
5. Verify functionality is preserved
247
+
```
248
+
249
+
After restarting Qwen Code, your custom skills will be available via `/skills` and subagents via `/agents manage`.
250
+
251
+
## Step 6: Add a Custom `QWEN.md`
167
252
168
253
You can provide persistent context to the model by adding a `QWEN.md` file to your extension. This is useful for giving the model instructions on how to behave or information about your extension's tools. Note that you may not always need this for extensions built to expose commands and prompts.
169
254
@@ -194,7 +279,7 @@ You can provide persistent context to the model by adding a `QWEN.md` file to yo
194
279
195
280
Restart the CLI again. The model will now have the context from your `QWEN.md` file in every session where the extension is active.
196
281
197
-
## Step 6: Releasing Your Extension
282
+
## Step 7: Releasing Your Extension
198
283
199
284
Once you are happy with your extension, you can share it with others. The two primary ways of releasing extensions are via a Git repository or through GitHub Releases. Using a public Git repository is the simplest method.
200
285
@@ -207,6 +292,7 @@ You've successfully created a Qwen Code extension! You learned how to:
0 commit comments