Lesson Learned

作者 softaworks3027f20f3181無授權條款2.5K 個星標收錄於 2026年10月8日更新於 2026年10月8日儲存庫7 個月前更新

Analyze recent code changes via git history and extract software engineering lessons. Use when the user asks 'what is the lesson here?', 'what can I learn from this?', 'engineering takeaway', 'what did I just learn?', 'reflect on this code', or wants to extract principles from recent work.

AI 產生的概覽

透過 git 歷史分析近期程式碼變更,萃取出有依據的軟體工程經驗教訓並提出反思性總結。

功能
先讀取原則參考文件,再依 git 歷史決定分析範圍(功能分支、最近 N 次提交、特定提交或工作區變更),並蒐集相關 diff 與提交訊息。它找出變更中的主導模式,對應到某項軟體工程原則,並依固定範本輸出一則主要經驗教訓以及最多兩則補充說明。此技能僅含指示,產出的是書面反思,而非程式碼或檔案。
適用情境
當使用者詢問能從近期程式碼中學到什麼、想要工程面的收穫,或希望反思剛完成的變更時使用。適合檢視分支、提交區間或尚未提交的變更,從真實程式碼中提煉原則。
執行需求
需要存取 git 儲存庫,並能執行 git log、git diff、git show 等 git 指令。需讀取隨附的兩個參考檔案 references/se-principles.md 與 references/anti-patterns.md。不需要指令碼、套件、憑證或網路存取。

Lesson Learned

Extract specific, grounded software engineering lessons from actual code changes. Not a lecture -- a mirror. Show the user what their code already demonstrates.

Before You Begin

Load the principles reference first.

  1. Read references/se-principles.md to have the principle catalog available
  2. Optionally read references/anti-patterns.md if you suspect the changes include areas for improvement
  3. Determine the scope of analysis (see Phase 1)

Do not proceed until you've loaded at least se-principles.md.

Phase 1: Determine Scope

Ask the user or infer from context what to analyze.

ScopeGit CommandsWhen to Use
Feature branchgit log main..HEAD --oneline + git diff main...HEADUser is on a non-main branch (default)
Last N commitsgit log --oneline -N + git diff HEAD~N..HEADUser specifies a range, or on main (default N=5)
Specific commitgit show <sha>User references a specific commit
Working changesgit diff + git diff --cachedUser says "what about these changes?" before committing

Default behavior:

  • If on a feature branch: analyze branch commits vs main
  • If on main: analyze the last 5 commits
  • If the user provides a different scope, use that

Phase 2: Gather Changes

  1. Run git log with the determined scope to get the commit list and messages
  2. Run git diff for the full diff of the scope
  3. If the diff is large (>500 lines), use git diff --stat first, then selectively read the top 3-5 most-changed files
  4. Read commit messages carefully -- they contain intent that raw diffs miss
  5. Only read changed files. Do not read the entire repo.

Phase 3: Analyze

Identify the dominant pattern -- the single most instructive thing about these changes.

Look for:

  • Structural decisions -- How was the code organized? Why those boundaries?
  • Trade-offs made -- What was gained vs. sacrificed? (readability vs. performance, DRY vs. clarity, speed vs. correctness)
  • Problems solved -- What was the before/after? What made the "after" better?
  • Missed opportunities -- Where could the code improve? (present gently as "next time, consider...")

Map findings to specific principles from references/se-principles.md. Be specific -- quote actual code, reference actual file names and line changes.

Phase 4: Present the Lesson

Use this template:

markdown
## Lesson: [Principle Name]
**What happened in the code:**[2-3 sentences describing the specific change, referencing files and commits]
**The principle at work:**[1-2 sentences explaining the SE principle]
**Why it matters:**[1-2 sentences on the practical consequence -- what would go wrong without this, or what goes right because of it]
**Takeaway for next time:**[One concrete, actionable sentence the user can apply to future work]

If there is a second lesson worth noting (maximum 2 additional):

markdown
---
### Also worth noting: [Principle Name]
**In the code:** [1 sentence]**The principle:** [1 sentence]**Takeaway:** [1 sentence]

What NOT to Do

AvoidWhyInstead
Listing every principle that vaguely appliesOverwhelming and genericPick the 1-2 most relevant
Analyzing files that were not changedScope creepStick to the diff
Ignoring commit messagesThey contain intent that diffs missRead them as primary context
Abstract advice disconnected from the codeNot actionableAlways reference specific files/lines
Negative-only feedbackDemoralizingLead with what works, then suggest improvements
More than 3 lessonsDilutes the insightOne well-grounded lesson beats seven vague ones

Conversation Style

  • Reflective, not prescriptive. Use the user's own code as primary evidence.
  • Never say "you should have..." -- instead use "the approach here shows..." or "next time you face this, consider..."
  • If the code is good, say so. Not every lesson is about what went wrong. Recognizing good patterns reinforces them.
  • If the changes are trivial (a single config tweak, a typo fix), say so honestly rather than forcing a lesson. "These changes are straightforward -- no deep lesson here, just good housekeeping."
  • Be specific. Generic advice is worthless. Every claim must point to a concrete code change.

來源與署名

來源:softaworks/agent-toolkit位於skills/lesson-learned提交3027f20

授權條款: 無授權條款

內容歸原作者所有。SourceWeft 從公開儲存庫中收錄這些內容。

檢舉或申請下架