Automatically generate professional work weekly reports from Git commit records, supporting single-week/multi-week batch generation.
Core Principles
- Main-sub separation: The main agent is responsible for scheduling, and sub-agents are responsible for actual generation
- Concise output: Only output the commit message array, without redundant information
- Read-only Git logs: Reading project source code files is prohibited
- Content cleaning is mandatory: Convert technical terminology into business language (executed by AI, cannot be skipped)
- Task management: Use the TodoWrite tool to create a task list and track the generation status of each weekly report
Quick Start
Generating a weekly report only requires 2 steps:
Step 1: 运行编排脚本准备数据 → Step 2: 并行处理每个周报
Step 1: Run the orchestration script (prepare data)
python scripts/orchestrate_reports.py \
--paths "E:\项目1,E:\项目2" \
--time "本月" \
--output "E:\周报输出" \
--template "E:\模板.docx" \
--format docx \
--naming "第一周周报,第二周周报,第三周周报,第四周周报"
The script automatically completes:
- Parse time expressions (this week/this month/2025-1-1-2025-1-31)
- Validate project paths and output paths
- Analyze template files (identify sections that need to be supplemented)
- Generate an independent task configuration file for each week
- Generate secondary confirmation information and Claude Code invocation instructions
Output files(located in {输出路径}/tmp/):
time_result.json- Time parsing resulttemplate_structure.json- Template structure (if a template is provided)week_XX-task.json- Task configuration for each weekclaude_instruction.md- Claude Code invocation instructions
Step 2: Process each weekly report in parallel (executed by AI)
Create a task list(required):
# 使用 TodoWrite 工具创建任务清单
todos = [
{"content": "读取调用说明和参考文档", "status": "pending", "activeForm": "读取调用说明和参考文档"},
{"content": "为第1周启动子智能体", "status": "pending", "activeForm": "为第1周启动子智能体"},
{"content": "为第2周启动子智能体", "status": "pending", "activeForm": "为第2周启动子智能体"},
# ... 为每个周创建一个任务
{"content": "汇总所有结果并清理临时文件", "status": "pending", "activeForm": "汇总所有结果并清理临时文件"}
]
Read reference documents:
- Script parameters required: Read
references/script-api-reference.mdto view detailed parameters
Workflow:
- Read invocation instructions:
{输出路径}/tmp/claude_instruction.md(mark the first task as in_progress) - Launch sub-agents in parallel: Use the Task tool to launch an independent general-purpose sub-agent for each week
- 📘 Invocation method: Refer to
references/workflow.mdSection 2.2 for detailed examples - Call the Task tool multiple times in the same response to achieve parallel processing
- Mark the status for each subtask (→ in_progress when started, → completed when finished)
- ⚠️ Important: Sub-agents must only return a brief success/failure status, and must not output detailed reports
- 📘 Invocation method: Refer to
- Aggregate results: Collect the success/failure status of all subtasks (mark as in_progress)
- Clean up temporary files: Delete successful temporary files, and keep failed ones for debugging (mark as completed)
⚠️ Sub-agent output specification(important):
- ✅ Only return a brief status: "✅ Week X weekly report generated successfully" or "❌ Week X weekly report generation failed: [reason]"
- ❌ Do not output detailed work content, data statistics, terminology conversion examples, etc.
- ❌ Do not output detailed execution step descriptions
- ✅ Strictly output according to the template:
- If a template is provided (--template parameter): output only the weekly report file in the template format
Complete workflow and Task tool invocation examples:📘 workflow.md
Reference documentation
📘 workflow.md
Complete workflow guide, including:
- Detailed Step 2 execution steps
- Sub-agent task prompt template (ready to copy and use)
- Temporary file structure and cleanup rules
📘 examples.md
Common usage scenario examples:
- Example 1: Generate this month's weekly report (Markdown format)
- Example 2: Use a Word template
- Example 3: Batch generate weekly reports for multiple weeks
- Example 4: Multi-project summary
📘 script-api-reference.md
Detailed Python script invocation parameters and usage examples:
parse_time.py- Time parsinganalyze_template.py- Template analysisget_git_logs.py- Git log retrieval (compact mode)fill_template.py- Template filling and exportorchestrate_reports.py- Orchestrate all steps
Parameter description
orchestrate_reports.py parameters
--paths(required): list of project paths, comma-separated--time(required): time expression- Relative time:
本周、上周、本月、上月、本年、去年 - Absolute time:
YYYY-MM-DDorYYYY-MM-DD-YYYY-MM-DD
- Relative time:
--output(required): output directory path--template(optional): template file path (supports .md and .docx)--format(optional, default md): output format (mdordocx)--naming(optional): list of weekly report naming rules, comma-separated- Recommended: specify a custom filename for each weekly report
- Example:
--naming "华电第一周周报,华电第二周周报" - The number of naming rules must match the number of generated weekly reports
- When not provided, default naming is used:
第X周周报.docx
Time expression examples
| Expression | Description | Generated weekly reports |
|---|---|---|
本周 |
Monday to Friday of the current week | 1 report |
本月 |
From the 1st to the last day of this month (divided by week) | 4-5 reports |
2025-1-1-2025-1-31 |
Specified time range | Divided by week |
2025-1-15 |
The week containing the specified date | 1 report |
Frequently asked questions
Q: Where are temporary files saved?
A: {输出路径}/tmp/ directory, automatically cleaned up after success