python-script
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePython Scripter
Python 脚本编写工具
Overview
概述
Design and run Python scripts with clear requirements, safety checks, and reproducible logging.
设计并运行具备明确需求、安全检查与可复现日志记录的Python脚本。
Workflow
工作流程
- Confirm inputs, outputs, constraints, and preferred libraries.
- Identify risky operations and secure explicit approval.
- Scaffold a script with PEP 723 metadata and structured logging.
- Lint with .
uvx ruff check --fix .agents/scripts/{script_name}.py - Run with and monitor logs.
uv run --script .agents/scripts/{script_name}.py - Report results, risks encountered, and any follow-up steps.
- 确认输入、输出、约束条件及首选库。
- 识别高风险操作并获取明确许可。
- 基于PEP 723元数据和结构化日志搭建脚本框架。
- 使用进行代码检查与修复。
uvx ruff check --fix .agents/scripts/{script_name}.py - 通过运行脚本并监控日志。
uv run --script .agents/scripts/{script_name}.py - 汇报执行结果、遇到的风险及后续步骤。
Logging requirements
日志记录要求
- Log to and stream to console
.agents/logs/{script_name}.log - Capture start/end timestamps, parameters, file operations, and errors
- Add if logs may grow large
RotatingFileHandler
- 日志输出至同时输出到控制台
.agents/logs/{script_name}.log - 捕获开始/结束时间戳、参数、文件操作及错误信息
- 若日志可能过大,添加
RotatingFileHandler
Template
模板
Read for the full script template.
references/script-template.md查看获取完整脚本模板。
references/script-template.mdSafety practices
安全实践
- Provide dry-run or rollback paths
- Validate external inputs and API responses
- Use temporary directories for intermediates
- Never run destructive steps without confirmation
- 提供dry-run或回滚路径
- 验证外部输入与API响应
- 使用临时目录存储中间文件
- 未经确认绝不执行破坏性操作