batch
它能做什么
它查找符合某个模式的文件,把它们分成若干组,由并行的工作智能体处理每一组,然后汇总结果。适合需要对大量文件做相同修改的人。
适用场景
- ✓当你希望对符合某个模式的大量文件应用同一项修改时。
- ✓当你需要并行完成大量相互独立的编辑时。
- ✓当你希望在大批量文件操作之后获得结果摘要时。
技能链接
https://github.com/QwenLM/qwen-code/blob/main/packages/core/src/skills/bundled/batch/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请为 src 文件夹中的每个 TypeScript 文件添加一段简短的 JSDoc 注释,排除测试文件。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体查找匹配的文件,自动跳过 node_modules 和构建输出等常见文件夹,把列表拆分为分块,并让工作智能体并行处理。然后,它把结果合并成摘要。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
/batch - Parallel Batch Operations
You are orchestrating a batch operation across multiple files. Your job is to:
- Parse the user's request to understand the target files and operation
- Discover matching files using glob
- Split files into chunks for parallel processing
- Launch multiple worker agents to process files concurrently
- Aggregate results and present a summary
Step 1: Parse Intent and Discover Files
First, parse the user's request to identify:
- Target pattern: glob pattern for files (e.g.,
src/**/*.ts,**/*.js) - Operation: what to do with each file (e.g., "add JSDoc comments", "convert to TypeScript")
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:
- Inform the user that no files were found for the given pattern
- Suggest checking the pattern or broadening the search scope
- Do not proceed with an empty batch
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**/pnpm-lock.yaml**/*.min.js- Binary files (images, fonts, etc.)
- Files larger than 500KB (check size if needed)
Important: 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.
Step 2: Chunk Files for Parallel Processing
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:
- Minimum chunk size: 3 files (avoid over-parallelization for small batches)
- Maximum chunk size: 15 files (ensure reasonable work per agent)
- Maximum parallel agents: 5 (API rate limit consideration)
Example: 24 files → 3 chunks of ~8 files each
Step 3: Launch Parallel Worker Agents
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:
- The list of files to process (full paths)
- The operation to perform
- Clear instructions to report success/failure per file
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.
Agent Prompt Template
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
Example Invocation Pattern
Set run_in_background: false on every worker call so all results return inline
for aggregation in Step 4.
<Agent tool call 1>
description: "Process batch chunk 1/3"
prompt: "You are a worker agent... [full prompt as above]"
subagent_type: "general-purpose"
run_in_background: false
</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"
run_in_background: false
</Agent tool call 2>
<Agent tool call 3>
description: "Process batch chunk 3/3"
prompt: "You are a worker agent.
常见问题
哪些文件会被自动跳过?
常见文件夹,例如 node_modules、dist、build 和 .git,以及测试文件、锁文件、压缩文件、二进制文件,以及超过 500KB 的文件。
如果没有匹配的文件怎么办?
智能体会告诉你,并建议检查模式,而不是运行一个空的批次。
批处理运行更便宜吗?
不一定。它现在是并行运行的,而独立的批处理 API 技能是适合可以等待的工作的半价选项。
详情
作者的原始描述
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. For many independent single-turn transforms (translate/rewrite/extract each file into a new file) that can wait minutes to hours, you may suggest the user type `/batch-api` themselves for the half-price asynchronous Batch API — you cannot invoke it, and it is not suited to in-place edits or tasks needing tool feedback.
repo: QwenLM/qwen-code
热度
- GitHub 星标
- 29k
- 排名
- #9777
- 许可证
- Apache-2.0
- 更新时间
- 2026/11/2
评论
- …
同一仓库的更多技能
codegraph
29k帮你的智能体通过调用图、依赖关系、无用代码、热点和语义搜索来分析已建立索引的代码库。
qwen-code-claw
29k帮你的智能体把编程任务交给 Qwen Code,例如理解代码库、修复缺陷、重构代码或生成新项目。
structured-debugging
29k教你的智能体用一步一步的方法调试疑难缺陷:先提出假设,再添加有针对性的检查,验证后找出真正的原因,然后才修复。
tmux-real-user-testing
29k帮你的智能体在 tmux 中像真实用户一样测试终端应用,并为每一步操作保存带屏幕截图的可读步骤日志。