con un clic
batch
// Execute batch operations on multiple files in parallel. Automatically discovers files, splits into chunks, and processes with parallel worker agents. Use `/batch` followed by operation and file pattern.
// Execute batch operations on multiple files in parallel. Automatically discovers files, splits into chunks, and processes with parallel worker agents. Use `/batch` followed by operation and file pattern.
| name | batch |
| description | Execute batch operations on multiple files in parallel. Automatically discovers files, splits into chunks, and processes with parallel worker agents. Use `/batch` followed by operation and file pattern. |
| argument-hint | <operation> <file-pattern> |
| allowedTools | ["task","glob","grep_search","read_file","edit","write_file","run_shell_command","ask_user_question"] |
You are orchestrating a batch operation across multiple files. Your job is to:
First, parse the user's request to identify:
src/**/*.ts, **/*.js)If the user didn't specify a pattern, infer it from context or ask for clarification.
Use the glob tool to discover matching files.
If no files match the pattern:
Apply these common exclusions automatically:
node_modules/**dist/**build/**.git/****/*.test.ts, **/*.test.js**/*.spec.ts, **/*.spec.js**/__tests__/****/test/**, **/tests/****/package-lock.json**/yarn.lock**/*.min.jsImportant: If more than 50 files match, inform the user with the exact count and the file list, then proceed. The user can cancel (Ctrl+C) if needed. If the count exceeds 100 files, warn the user and suggest a more specific pattern instead of proceeding.
Split the discovered files into chunks based on these rules:
| Total Files | Chunk Count | Files Per Chunk |
|---|---|---|
| 1-5 | 1 | All files |
| 6-15 | 2 | 3-8 each |
| 16-30 | 3 | ~10 each |
| 31-50 | 4 | ~10-12 each |
| 51-75 | 5 | ~10-15 each |
| 76-100 | 5 | ~15-20 each |
Chunking algorithm:
Example: 24 files → 3 chunks of ~8 files each
Launch worker agents in parallel by invoking the task tool (the Agent tool) multiple times in a SINGLE message.
Note: The task tool in allowedTools is the Agent tool used to spawn worker agents.
Each worker agent should receive:
Use the general-purpose subagent type for workers.
CRITICAL: All Agent tool calls MUST be in a single response to enable parallel execution. The system automatically runs multiple Agent calls concurrently.
For each chunk, use this prompt format:
You are a worker agent processing a batch of files.
**Operation**: [describe the operation, e.g., "Add JSDoc comments to all exported functions"]
**Files to process**:
- [file1.ts]
- [file2.ts]
- ...
**Instructions**:
1. Process each file independently
2. For each file, report one of:
- SUCCESS: [file path] - [brief description of change]
- FAILED: [file path] - [reason for failure]
- SKIPPED: [file path] - [reason for skipping]
3. If a file fails or is skipped, continue with the next file - do not abort
4. At the end, provide a summary of what was done
**Constraints**:
- Do not modify test files unless explicitly requested
- Preserve existing code style and formatting
- Make minimal necessary changes to accomplish the operation
<Agent tool call 1>
description: "Process batch chunk 1/3"
prompt: "You are a worker agent... [full prompt as above]"
subagent_type: "general-purpose"
</Agent tool call 1>
<Agent tool call 2>
description: "Process batch chunk 2/3"
prompt: "You are a worker agent... [full prompt as above]"
subagent_type: "general-purpose"
</Agent tool call 2>
<Agent tool call 3>
description: "Process batch chunk 3/3"
prompt: "You are a worker agent... [full prompt as above]"
subagent_type: "general-purpose"
</Agent tool call 3>
After all worker agents complete, aggregate their results into a clear summary.
### Batch Operation Complete
**Operation**: [description of what was done]
**Files discovered**: [total count]
**Chunks processed**: [number of parallel agents]
**Total time**: [duration if tracked]
| Status | Count |
| ------- | ----- |
| Success | [N] |
| Failed | [N] |
| Skipped | [N] |
**Successful files**:
- [file1.ts] - [brief description]
- [file2.ts] - [brief description]
...
**Failed files** (if any):
- [file.ts]: [reason for failure]
**Skipped files** (if any):
- [file.ts]: [reason for skipping]
If some files failed but others succeeded:
If all files failed:
For each failed file, include:
/batch Add Apache 2.0 license header to all .ts files in src/
Flow:
src/**/*.ts → find 45 files/batch Convert all .js files in utils/ to TypeScript
Flow:
utils/**/*.js → find 12 files/batch Fix all @typescript-eslint/no-explicit-any errors in src/
Flow:
grep_search to find files containing : any pattern in src/any with proper types)| Constraint | Value | Reason |
|---|---|---|
| Max files per batch | 100 | Prevent resource exhaustion |
| Max parallel agents | 5 | API rate limit consideration |
| Min files per agent | 3 | Avoid over-parallelization |
| Max files per agent | 15 | Ensure meaningful work |
| File size limit | 500KB | Avoid context overflow |
If the user wants to preview what will be changed without actually modifying files (e.g., "preview", "show me what would change", "dry run"):
Example:
/batch preview adding JSDoc comments to src/**/*.ts
Expected output:
### Dry-Run Preview
**Operation**: Add JSDoc comments to all .ts files in src/
**Files discovered**: 24 files
**Chunking plan**:
| Chunk | Files |
|-------|-------|
| 1 | src/utils/a.ts, b.ts, c.ts, ... (8 files) |
| 2 | src/components/x.ts, y.ts, ... (8 files) |
| 3 | src/services/m.ts, n.ts, ... (8 files) |
**Planned operation per file**:
- Add JSDoc comments to all exported functions
- Preserve existing code style
Proceed? (y/n)
Diagnose memory leaks in the Qwen Code CLI using heap snapshots and the chrome-devtools CLI. Use when investigating high memory usage, unbounded growth, or suspected object retention issues.
Review changed code for correctness, security, code quality, and performance. Use when the user asks to review code changes, a PR, or specific files. Invoke with `/review`, `/review <pr-number>`, `/review <file-path>`, or `/review <pr-number> --comment` to post inline comments on the PR.
Diagnose frozen, stuck, or slow Qwen Code sessions on this machine. Scans for problematic processes, high CPU/memory usage, hung subprocesses, and debug logs. Use /stuck or /stuck <PID> to focus on a specific process.
This skill should be used when the user asks to "用 tmux 做真实测试", "保存 tmux 日志", "像真实用户一样测试 Qwen", "生成可复查的 TUI 测试报告", "测试 slash command 交互", or requests a tmux-based real user E2E run with complete readable logs. It guides real TUI usage with step-by-step capture-pane snapshots rather than ANSI raw pipe logs.
Create a recurring loop that runs a prompt on a schedule. Usage - /loop 5m check the build, /loop check the PR every 30m, /loop run tests (defaults to 10m). /loop list to show jobs, /loop clear to cancel all.
Answer any question about Qwen Code usage, features, configuration, and troubleshooting by referencing the official user documentation. Also helps users view or modify their settings.json. Invoke with `/qc-helper` followed by a question, e.g. `/qc-helper how do I configure MCP servers?` or `/qc-helper change approval mode to yolo`.