gstack-openclaw-retro

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Weekly Engineering Retrospective

每周工程回顾

Generates a comprehensive engineering retrospective analyzing commit history, work patterns, and code quality metrics. Team-aware: identifies the user running the command, then analyzes every contributor with per-person praise and growth opportunities.
生成全面的工程回顾报告,分析提交历史、工作模式和代码质量指标。支持团队感知:识别执行命令的用户,然后分析每位贡献者的表现,给出个人表扬点和成长机会。

Arguments

参数

  • Default: last 7 days
  • 24h
    : last 24 hours
  • 14d
    : last 14 days
  • 30d
    : last 30 days
  • compare
    : compare current window vs prior same-length window
  • 默认:最近7天
  • 24h
    :最近24小时
  • 14d
    :最近14天
  • 30d
    :最近30天
  • compare
    :对比当前时间窗口与之前相同长度的时间窗口

Instructions

操作说明

Parse the argument to determine the time window. Default to 7 days. All times should be reported in the user's local timezone.
Midnight-aligned windows: For day units, compute an absolute start date at local midnight. For example, if today is 2026-03-18 and the window is 7 days, the start date is 2026-03-11. Use
--since="2026-03-11T00:00:00"
for git log queries. For hour units, use
--since="N hours ago"
.

解析参数以确定时间窗口,默认采用7天。所有时间均以用户的本地时区为准。
午夜对齐窗口:对于以天为单位的窗口,计算本地午夜时刻的绝对起始日期。例如,如果今天是2026-03-18,窗口为7天,则起始日期为2026-03-11。在git log查询中使用
--since="2026-03-11T00:00:00"
。对于以小时为单位的窗口,使用
--since="N hours ago"

Step 1: Gather Raw Data

步骤1:收集原始数据

First, fetch origin and identify the current user:
bash
git fetch origin main --quiet
git config user.name
git config user.email
The name returned by
git config user.name
is "you" ... the person reading this retro. All other authors are teammates.
Run ALL of these git commands (they are independent):
bash
undefined
首先,拉取远程仓库并识别当前用户:
bash
git fetch origin main --quiet
git config user.name
git config user.email
git config user.name
返回的名称就是**"你"**——阅读这份回顾报告的人。其他所有作者均为团队成员。
运行以下所有git命令(它们相互独立):
bash
undefined

All commits with timestamps, subject, hash, author, files changed

包含时间戳、提交主题、哈希值、作者、修改文件的所有提交

git log origin/main --since="<window>" --format="%H|%aN|%ae|%ai|%s" --shortstat
git log origin/main --since="<window>" --format="%H|%aN|%ae|%ai|%s" --shortstat

Per-commit test vs total LOC breakdown with author

按提交拆分测试代码与总代码行数(LOC),并关联作者

git log origin/main --since="<window>" --format="COMMIT:%H|%aN" --numstat
git log origin/main --since="<window>" --format="COMMIT:%H|%aN" --numstat

Commit timestamps for session detection and hourly distribution

用于会话检测和小时分布的提交时间戳

git log origin/main --since="<window>" --format="%at|%aN|%ai|%s" | sort -n
git log origin/main --since="<window>" --format="%at|%aN|%ai|%s" | sort -n

Files most frequently changed (hotspot analysis)

最常修改的文件(热点分析)

git log origin/main --since="<window>" --format="" --name-only | grep -v '^$' | sort | uniq -c | sort -rn
git log origin/main --since="<window>" --format="" --name-only | grep -v '^$' | sort | uniq -c | sort -rn

PR numbers from commit messages

从提交信息中提取PR编号

git log origin/main --since="<window>" --format="%s" | grep -oE '[#!][0-9]+' | sort -t'#' -k1 | uniq
git log origin/main --since="<window>" --format="%s" | grep -oE '[#!][0-9]+' | sort -t'#' -k1 | uniq

Per-author file hotspots

按作者划分的文件热点

git log origin/main --since="<window>" --format="AUTHOR:%aN" --name-only
git log origin/main --since="<window>" --format="AUTHOR:%aN" --name-only

Per-author commit counts

按作者统计的提交次数

git shortlog origin/main --since="<window>" -sn --no-merges
git shortlog origin/main --since="<window>" -sn --no-merges

Test file count

测试文件数量

find . -name '.test.' -o -name '.spec.' -o -name '_test.' -o -name '_spec.' 2>/dev/null | grep -v node_modules | wc -l
find . -name '.test.' -o -name '.spec.' -o -name '_test.' -o -name '_spec.' 2>/dev/null | grep -v node_modules | wc -l

Test files changed in window

时间窗口内修改的测试文件数量

git log origin/main --since="<window>" --format="" --name-only | grep -E '.(test|spec).' | sort -u | wc -l

---
git log origin/main --since="<window>" --format="" --name-only | grep -E '.(test|spec).' | sort -u | wc -l

---

Step 2: Compute Metrics

步骤2:计算指标

Calculate and present these metrics in a summary:
  • Commits to main: N
  • Contributors: N
  • PRs merged: N
  • Total insertions: N
  • Total deletions: N
  • Net LOC added: N
  • Test LOC (insertions): N
  • Test LOC ratio: N%
  • Version range: vX.Y.Z → vX.Y.Z
  • Active days: N
  • Detected sessions: N
  • Avg LOC/session-hour: N
Then show a per-author leaderboard immediately below:
Contributor         Commits   +/-          Top area
You (garry)              32   +2400/-300   browse/
alice                    12   +800/-150    app/services/
bob                       3   +120/-40     tests/
Sort by commits descending. The current user always appears first, labeled "You (name)".

在摘要中计算并展示以下指标:
  • 合并到main的提交数:N
  • 贡献者数量:N
  • 合并的PR数:N
  • 总新增代码行数:N
  • 总删除代码行数:N
  • 净新增代码行数:N
  • 测试代码新增行数:N
  • 测试代码占比:N%
  • 版本范围:vX.Y.Z → vX.Y.Z
  • 活跃天数:N
  • 检测到的工作会话数:N
  • 平均每会话小时代码行数:N
随后立即展示按作者排名的排行榜
Contributor         Commits   +/-          Top area
You (garry)              32   +2400/-300   browse/
alice                    12   +800/-150    app/services/
bob                       3   +120/-40     tests/
按提交次数降序排列。当前用户始终排在第一位,标注为"You (name)"。

Step 3: Commit Time Distribution

步骤3:提交时间分布

Show hourly histogram in local time:
Hour  Commits  ████████████████
 00:    4      ████
 07:    5      █████
 ...
Identify:
  • Peak hours
  • Dead zones
  • Bimodal pattern (morning/evening) vs continuous
  • Late-night coding clusters (after 10pm)

以本地时间展示小时柱状图:
Hour  Commits  ████████████████
 00:    4      ████
 07:    5      █████
 ...
识别以下内容:
  • 峰值时段
  • 低活跃时段
  • 双峰模式(早/晚)vs 连续模式
  • 深夜代码提交集群(晚10点后)

Step 4: Work Session Detection

步骤4:工作会话检测

Detect sessions using 45-minute gap threshold between consecutive commits.
Classify sessions:
  • Deep sessions (50+ min)
  • Medium sessions (20-50 min)
  • Micro sessions (<20 min, single-commit)
Calculate:
  • Total active coding time
  • Average session length
  • LOC per hour of active time

使用45分钟间隔阈值检测连续提交之间的会话。
将会话分类:
  • 深度会话(50分钟以上)
  • 中等会话(20-50分钟)
  • 微型会话(少于20分钟,仅单个提交)
计算:
  • 总活跃编码时间
  • 平均会话时长
  • 每活跃小时代码行数

Step 5: Commit Type Breakdown

步骤5:提交类型拆分

Categorize by conventional commit prefix (feat/fix/refactor/test/chore/docs). Show as percentage bar:
feat:     20  (40%)  ████████████████████
fix:      27  (54%)  ███████████████████████████
refactor:  2  ( 4%)  ██
Flag if fix ratio exceeds 50% ... signals a "ship fast, fix fast" pattern that may indicate review gaps.

按约定式提交前缀(feat/fix/refactor/test/chore/docs)分类。以百分比柱状图展示:
feat:     20  (40%)  ████████████████████
fix:      27  (54%)  ███████████████████████████
refactor:  2  ( 4%)  ██
如果修复类提交占比超过50%,需标记出来……这表明"快速交付、快速修复"的模式,可能暗示代码审查存在漏洞。

Step 6: Hotspot Analysis

步骤6:热点分析

Show top 10 most-changed files. Flag:
  • Files changed 5+ times (churn hotspots)
  • Test files vs production files in the hotspot list
  • VERSION/CHANGELOG frequency

展示修改次数最多的前10个文件。标记:
  • 修改次数≥5次的文件(频繁改动热点)
  • 热点列表中的测试文件 vs 生产文件
  • VERSION/CHANGELOG的修改频率

Step 7: PR Size Distribution

步骤7:PR大小分布

Estimate PR sizes and bucket them:
  • Small (<100 LOC)
  • Medium (100-500 LOC)
  • Large (500-1500 LOC)
  • XL (1500+ LOC)

估算PR大小并分组:
  • 小型(少于100行代码)
  • 中型(100-500行代码)
  • 大型(500-1500行代码)
  • 超大型(1500行代码以上)

Step 8: Focus Score + Ship of the Week

步骤8:专注度得分 + 本周重点交付

Focus score: Percentage of commits touching the single most-changed top-level directory. Higher = deeper focused work. Lower = scattered context-switching.
Ship of the week: The single highest-LOC PR in the window. Highlight PR number, LOC changed, and why it matters.

专注度得分:提交中涉及单个修改最频繁的顶级目录的占比。得分越高表示工作越聚焦,得分越低表示上下文切换频繁。
本周重点交付:时间窗口内代码行数变化最大的单个PR。突出PR编号、代码行数变化及其重要性。

Step 9: Team Member Analysis

步骤9:团队成员分析

For each contributor (including the current user), compute:
  1. Commits and LOC ... total commits, insertions, deletions, net LOC
  2. Areas of focus ... which directories/files they touched most (top 3)
  3. Commit type mix ... their personal feat/fix/refactor/test breakdown
  4. Session patterns ... when they code (peak hours), session count
  5. Test discipline ... their personal test LOC ratio
  6. Biggest ship ... their single highest-impact commit or PR
For the current user ("You"): Deepest treatment. Include all session analysis, time patterns, focus score. Frame in first person.
For each teammate: 2-3 sentences covering what they shipped and their pattern. Then:
  • Praise (1-2 specific things): Anchor in actual commits. Not "great work" ... say exactly what was good.
  • Opportunity for growth (1 specific thing): Frame as leveling-up, not criticism. Anchor in actual data.
If solo repo: Skip team breakdown.
AI collaboration: If commits have
Co-Authored-By
AI trailers, track "AI-assisted commits" as a separate metric.

针对每位贡献者(包括当前用户),计算:
  1. 提交与代码行数……总提交数、新增行数、删除行数、净新增行数
  2. 聚焦领域……他们修改最多的目录/文件(前3个)
  3. 提交类型占比……个人的feat/fix/refactor/test拆分情况
  4. 会话模式……他们的编码时段(峰值时段)、会话数量
  5. 测试规范度……个人的测试代码占比
  6. 最大交付成果……他们单个影响力最大的提交或PR
针对当前用户("你"):进行深度分析,包含所有会话分析、时间模式、专注度得分。以第一人称表述。
针对每位团队成员:用2-3句话介绍他们的交付内容和工作模式。然后:
  • 表扬点(1-2个具体事项):基于实际提交内容。不要只说"做得好"……要明确说明具体优点。
  • 成长机会(1个具体事项):以提升能力的角度表述,而非批评。基于实际数据。
如果是单人仓库:跳过团队分析部分。
AI协作:如果提交包含
Co-Authored-By
AI标记,将"AI辅助提交"作为单独指标追踪。

Step 10: Week-over-Week Trends (if window >= 14d)

步骤10:周环比趋势(若时间窗口≥14天)

Split into weekly buckets and show trends:
  • Commits per week (total and per-author)
  • LOC per week
  • Test ratio per week
  • Fix ratio per week
  • Session count per week

按周拆分窗口并展示趋势:
  • 每周提交数(总数及按作者统计)
  • 每周代码行数
  • 每周测试代码占比
  • 每周修复类提交占比
  • 每周会话数量

Step 11: Streak Tracking

步骤11:连续提交追踪

Count consecutive days with at least 1 commit, going back from today:
bash
undefined
统计从今天往前,至少有1次提交的连续天数:
bash
undefined

Team streak

团队连续提交天数

git log origin/main --format="%ad" --date=format:"%Y-%m-%d" | sort -u
git log origin/main --format="%ad" --date=format:"%Y-%m-%d" | sort -u

Personal streak

个人连续提交天数

git log origin/main --author="<user_name>" --format="%ad" --date=format:"%Y-%m-%d" | sort -u

Display both:
- "Team shipping streak: 47 consecutive days"
- "Your shipping streak: 32 consecutive days"

---
git log origin/main --author="<user_name>" --format="%ad" --date=format:"%Y-%m-%d" | sort -u

展示两者:
- "团队连续交付天数:47天"
- "你的连续交付天数:32天"

---

Step 12: Load History & Compare

步骤12:加载历史记录并对比

Check for prior retro history in
memory/
:
If prior retros exist, load the most recent one and calculate deltas:
                    Last        Now         Delta
Test ratio:         22%    →    41%         ↑19pp
Sessions:           10     →    14          ↑4
LOC/hour:           200    →    350         ↑75%
Fix ratio:          54%    →    30%         ↓24pp (improving)
If no prior retros exist, note "First retro recorded, run again next week to see trends."

检查
memory/
目录中的过往回顾记录:
如果存在过往回顾记录,加载最新的一份并计算差值:
                    上次回顾  当前回顾       差值
测试代码占比:         22%    →    41%         ↑19个百分点
会话数量:           10     →    14          ↑4
每小时代码行数:           200    →    350         ↑75%
修复类提交占比:          54%    →    30%         ↓24个百分点(有所改善)
如果没有过往回顾记录,标注"首次记录回顾,下周再次运行即可查看趋势。"

Step 13: Save Retro History

步骤13:保存回顾历史

Save a JSON snapshot to
memory/retro-YYYY-MM-DD.json
with metrics, authors, version range, streak, and tweetable summary.

将JSON快照保存到
memory/retro-YYYY-MM-DD.json
,包含指标、作者、版本范围、连续提交天数和适合分享的摘要。

Step 14: Write the Narrative

步骤14:撰写叙事报告

Format for Telegram (bullets, bold, no markdown tables in the final output).
Structure:
Tweetable summary (first line):
Week of Mar 1: 47 commits (3 contributors), 3.2k LOC, 38% tests, 12 PRs, peak: 10pm | Streak: 47d
Then sections:
  • Summary ... key metrics
  • Trends vs Last Retro ... deltas (skip if first retro)
  • Time & Session Patterns ... when the team codes, session lengths, deep vs micro
  • Shipping Velocity ... commit types, PR sizes, fix-chain detection
  • Code Quality Signals ... test ratio, hotspots, churn
  • Focus & Highlights ... focus score, ship of the week
  • Your Week ... personal deep-dive for the current user
  • Team Breakdown ... per-teammate analysis with praise + growth (skip if solo)
  • Top 3 Team Wins ... highest-impact things shipped
  • 3 Things to Improve ... specific, actionable, anchored in commits
  • 3 Habits for Next Week ... small, practical, realistic (<5 min to adopt)

Telegram格式(使用项目符号、粗体,最终输出中不使用Markdown表格)。
结构:
适合分享的摘要(第一行):
3月1日当周:47次提交(3位贡献者),3.2k行代码,测试代码占38%,12个PR,峰值时段:晚10点 | 连续交付天数:47天
然后分以下章节:
  • 摘要……关键指标
  • 与上次回顾的趋势对比……差值(首次回顾则跳过)
  • 时间与会话模式……团队编码时段、会话时长、深度会话vs微型会话
  • 交付速度……提交类型、PR大小、修复链检测
  • 代码质量信号……测试代码占比、热点文件、频繁改动情况
  • 聚焦度与亮点……专注度得分、本周重点交付
  • 你的本周情况……当前用户的深度分析
  • 团队细分分析……每位团队成员的分析,包含表扬点+成长机会(单人仓库则跳过)
  • 团队Top3成果……影响力最大的3项交付内容
  • 待改进的3个事项……具体、可落地、基于提交内容
  • 下周养成的3个习惯……微小、实用、符合实际(实施耗时<5分钟)

Compare Mode

对比模式

When the user says "compare":
  • Run the retro for the current window
  • Run the retro for the prior same-length window
  • Present side-by-side metrics with arrows showing improvement/regression
  • Brief narrative on biggest changes

当用户输入"compare"时:
  • 生成当前时间窗口的回顾报告
  • 生成之前相同长度时间窗口的回顾报告
  • 并排展示指标,用箭头表示提升/退步
  • 简述最大的变化

Important Rules

重要规则

  • All times in local timezone. Never set
    TZ
    .
  • Format for Telegram. Use bullets and bold. Avoid markdown tables in the final output.
  • Praise anchored in commits. Never say "great work" without naming what was good.
  • Growth areas anchored in data. Never criticize without evidence.
  • Save history. Every retro saves to
    memory/
    for trend tracking.
  • Completion status:
    • DONE ... retro generated, history saved
    • DONE_WITH_CONCERNS ... generated but missing data (e.g., no prior retros for comparison)
    • BLOCKED ... not in a git repo or no commits in window
  • 所有时间采用本地时区,绝不设置
    TZ
  • 采用Telegram格式,使用项目符号和粗体,最终输出中避免Markdown表格。
  • 表扬点基于提交内容,绝不空泛地说"做得好",必须明确说明具体优点。
  • 成长机会基于数据,绝不无凭无据地批评。
  • 保存历史记录,每次回顾都要保存到
    memory/
    目录以追踪趋势。
  • 完成状态
    • DONE……已生成回顾报告,历史记录已保存
    • DONE_WITH_CONCERNS……已生成报告但缺少数据(例如,无过往回顾记录用于对比)
    • BLOCKED……不在git仓库中或时间窗口内无提交