跳到正文
Skillpedia
自动化40k · #7091

batch-script-progress

它能做什么

这个工具可以为需要处理大量项目(比如文件或数据)的脚本添加进度信息。它会显示当前正在做什么、已完成多少,以及是否有失败的项目,同时不改变脚本的主要输出。

适用场景

  • ✓当你编写需要批量处理大量文件的脚本时。
  • ✓当你需要了解长时间运行的操作进度时。
  • ✓当你想在大规模操作中找出哪些项目失败了时。

技能链接

https://github.com/github/awesome-copilot/blob/main/skills/batch-script-progress/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/github/awesome-copilot/blob/main/skills/batch-script-progress/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“给这个处理文件夹中所有文件的 Python 脚本加上进度报告。”

每周 5 个新技能,1 分钟读完。

工作原理

工具会分析你的脚本,弄清它的工作方式,并在合适的位置添加提示信息,涵盖开始、进度、单个失败项以及最终汇总。这些信息会发送到单独的通道(通常是 stderr),因此不会干扰脚本的主要输出。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Batch Script Progress

Make generated batch scripts observable while they run, without changing their processing contract. Design start, periodic progress, per-item failure, and final-summary output together with result streams and exit status. A progress-bar library alone does not establish this contract.

1. Fix the existing contract

Read the script, callers, and nearby tests before editing. Identify:

  • Input unit, known or unknown total, and whether enumeration is lazy.
  • Existing stdout format and consumers, runtime version, and interactive versus redirected execution.
  • Continue-on-error or fail-fast policy, retry rules, skip rules, transaction boundaries, and cancellation behavior.
  • Existing exit codes and what callers treat as success.

Preserve these decisions. Do not add retries, parallelism, dependencies, or a new failure policy just to add progress output. If partial failures currently return zero, report the partial outcome honestly while keeping that exit contract. If the contract is missing or contradictory, ask for the decision that changes behavior; do not silently make it.

2. Define the output contract before implementation

Choose a small, stable vocabulary and fields, reusing the repository logger where suitable:

  • Start: operation name, total or explicit unknown, and initial counters. Emit before expensive enumeration; discovery itself may need progress.
  • Progress: processed, succeeded, failed, skipped, total or unknown, and elapsed time. Add a sanitized current-item identifier only when useful.
  • Item failure: safe identifier, failure category or sanitized reason, and whether processing will continue. Emit when observed, independently of the normal progress interval.
  • Summary: completed, partial, failed, or cancelled; final counters; elapsed time; known unprocessed count if available; and the exit status required by the existing contract.

Define processed = succeeded + failed + skipped for items that reached a terminal outcome. Keep in-flight and not-started items separate. Count each item once; retry attempts are not additional processed items. Do not label an item successful before its required commit, write, or acknowledgement. If a transaction rolls back, report rolled-back work rather than claiming durable success.

For an unknown total, report counts without a fabricated percentage, ETA, or remaining count. Do not materialize a stream just to count it. For zero items, emit start and summary with zero counts; never divide by zero.

3. Choose output streams and cadence

Reserve stdout for the established machine-readable result, pipeline objects, or protocol. Put progress and diagnostics on a separate channel; stderr is the portable default for standalone CLI scripts. Stderr output alone does not imply failure: callers must use the agreed exit code and result contract. Verify callers that treat any stderr as failure before changing their output. If stdout is reserved and stderr is incompatible, use an existing compatible logger or sink only when the caller already supports it. Do not move progress to stdout or another stream with changed semantics. If no compatible channel exists, stop and ask whether the output contract may change, or report that progress cannot be added safely.

Use a bounded cadence, such as every configured number of items or elapsed interval, rather than unconditionally logging every item. Emit start, failures, and summary regardless of that cadence. Preserve required per-item audit records separately. Avoid unbounded in-memory failure lists and repeated stack traces. Redact credentials, query parameters, personal data, and sensitive paths before formatting; do not dump raw exceptions or whole input records by default.

Use monotonic time for intervals and duration. Ensure output is flushed or drained so notifications arrive before exit. Use plain newline-delimited records under redirection; enable terminal rewriting or colors only for an appropriate TTY. Keep log-field meanings consistent across languages, not necessarily their exact formatting or libraries.

…

常见问题

什么是“处理约定”(processing contract)?

指关于脚本应当如何运行的约定,包括它接收什么输入、产生什么输出,以及如何报告成功或失败。

为什么不直接用普通进度条?

可视化进度条是为用户界面设计的。这个工具则专注于为在后台或批处理中运行的脚本提供清晰、结构化的信息,而不改变脚本实际的工作内容。

某一项失败了会怎样?

工具可以报告是哪一项失败、原因是什么,以及脚本是否会继续运行。这有助于精确定位问题,而不必中止整个操作。

详情

作者的原始描述

Design and verify runtime output when creating or modifying Python, PowerShell, or Node.js scripts that process multiple files, records, or API requests. Use for batch scripts, bulk operations, silent long-running loops, progress reporting, per-item failures, final counts, stdout separation, or exit-status consistency. Not for UI progress bars, monitoring infrastructure, or progress updates in the

repo: github/awesome-copilot

热度

GitHub 星标
40k
排名
#7091
许可证
MIT
更新时间
2026/10/15

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能