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.
Read
references/se-principles.md
to have the principle catalog available
Optionally read
references/anti-patterns.md
if you suspect the changes include areas for improvement
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.
Scope
Git Commands
When to Use
Feature branch
git log main..HEAD --oneline
+
git diff main...HEAD
User is on a non-main branch (default)
Last N commits
git log --oneline -N
+
git diff HEAD~N..HEAD
User specifies a range, or on main (default N=5)
Specific commit
git show
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):
Also worth noting: [Principle Name] ** In the code: ** [1 sentence] ** The principle: ** [1 sentence] ** Takeaway: ** [1 sentence] What NOT to Do Avoid Why Instead Listing every principle that vaguely applies Overwhelming and generic Pick the 1-2 most relevant Analyzing files that were not changed Scope creep Stick to the diff Ignoring commit messages They contain intent that diffs miss Read them as primary context Abstract advice disconnected from the code Not actionable Always reference specific files/lines Negative-only feedback Demoralizing Lead with what works, then suggest improvements More than 3 lessons Dilutes the insight One 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.