Analyzes a completed PR to extract lessons learned from agent behavior. Use after any PR with agent involvement - whether the agent failed, succeeded slowly, or succeeded quickly. Identifies patterns to reinforce or fix, and generates actionable recommendations for instruction files, skills, and documentation.
Extracts lessons learned from a completed PR to improve repository documentation and agent capabilities.
| Input | Required | Source |
|---|---|---|
| PR number or Issue number | Yes | User provides (e.g., "PR #33352" or "issue 33352") |
Learning Analysis - Structured markdown with:
Actionable Recommendations - Each with:
The skill is complete when you have:
pr-finalize first)# Required: Get PR info
gh pr view XXXXX --json title,body,files
gh pr diff XXXXX
Analyze the PR to extract learning:
Focus on: "What would have helped an agent find this fix faster?"
Critical question: Did agent attempts target the same files as the final fix?
# Where did final fix go?
gh pr view XXXXX --json files --jq '.files[].path' | grep -v test
| Scenario | Implication |
|---|---|
| Same files | Agent found right location |
| Different files | Major learning opportunity - document why |
If different files: Answer these questions:
Determine which scenario applies and look for the relevant patterns:
| Pattern | Indicator |
|---|---|
| Wrong file entirely | All attempts in File A, fix in File B |
| Tunnel vision | Only looked at file mentioned in error |
| Trusted issue title | Issue said "crash in X" so only looked at X |
| Pattern not generalized | Fixed one instance, missed others |
| Didn't search codebase | Never found similar code patterns |
| Missing platform knowledge | Didn't know iOS/Android/Windows specifics |
| Wrong abstraction layer | Fixed handler when problem was in core |
| Misread error message | Error pointed to symptom, not cause |
| Incomplete context | Didn't read enough surrounding code |
| Over-engineered | Complex fix when simple one existed |
| Pattern | Indicator |
|---|---|
| Correct file, wrong approach | Found right file but tried wrong fixes first |
| Needed multiple iterations | Each attempt got closer but wasn't quite right |
| Discovery was slow | Eventually found it but search was inefficient |
| Missing domain knowledge | Had to learn something that could be documented |
Key question: What would have gotten agent to the solution faster?
| Pattern | Indicator |
|---|---|
| Good search strategy | Found right file immediately |
| Understood the pattern | Recognized similar issues from past |
| Documentation helped | Existing docs pointed to solution |
| Simple, minimal fix | Didn't over-engineer |
Key question: What made this work? Should we reinforce this pattern?
# Discover where agent guidance lives
find .github/instructions -name "*.instructions.md" 2>/dev/null
find .github/skills -name "SKILL.md" 2>/dev/null
ls docs/design/ 2>/dev/null
ls .github/copilot-instructions.md 2>/dev/null
| Location | When to Add Here |
|---|---|
.github/instructions/*.instructions.md | Domain-specific AI guidance (testing patterns, platform rules) |
.github/skills/*/SKILL.md | Skill needs new step, checklist, or improved workflow |
/docs/design/*.md | Detailed architectural documentation |
.github/copilot-instructions.md | General AI workflow guidance |
| Code comments | Non-obvious code behavior |
For each recommendation, provide:
Prioritization factors:
Pattern-to-Improvement Mapping (Failures/Slow Success):
| Pattern | Likely Improvement |
|---|---|
| Wrong file entirely | Check /docs/design/ for component relationships |
| Tunnel vision | Instruction file: "Always search for pattern across codebase" |
| Missing platform knowledge | Platform-specific instruction file |
| Wrong abstraction layer | Reference /docs/design/HandlerResolution.md |
| Misread error message | Code comment explaining the real cause |
| Over-engineered | Skill enhancement: "Try simplest fix first" |
Pattern-to-Improvement Mapping (Quick Success - reinforce):
| Pattern | Improvement |
|---|---|
| Good search strategy | Document the search pattern that worked in skills |
| Documentation helped | Note which docs were valuable, ensure they stay updated |
| Recognized pattern | Add to instruction files as known pattern |
Present your analysis covering:
| Situation | Action |
|---|---|
| PR not found | Ask user to verify PR number |
| No agent involvement evident | Ask user if they still want analysis |
| Can't determine failure mode | State "insufficient data" and what's missing |
PR #33352 - TraitCollectionDidChange crash on MacCatalyst
What happened:
ShellSectionRootRenderer.csPageViewController.csFailure Mode: Trusted issue title instead of searching for pattern.
Recommendation:
.github/instructions/ios-debugging.instructions.mdPR #34567 - CollectionView scroll position not preserved
What happened:
Pattern: Wrong abstraction layer - fixed handler when problem was in core.
Recommendation:
.github/architecture/handler-vs-core.mdPR #35678 - Button disabled state not updating
What happened:
Pattern: Good search strategy - recognized pattern from similar code.
Recommendation:
.github/skills/try-fix/SKILL.mdFor automated application of recommendations, use the learn-from-pr agent instead.