| name | compound |
| description | Analyzes human refactoring of AI-generated code to extract coding style preferences and append them to project memory. Use after a developer has manually edited AI-generated code to capture their patterns, naming conventions, or error handling approaches. |
Learn From Human Edits
Checklist
Workflow
1. Identify what changed
Run: bash .claude/skills/compound/scripts/get-diff.sh
- If it exits with code 1 → tell the user "No changes detected" and stop.
- If it prints a WARNING about large diffs → ask the user which files to focus on, then re-run with:
bash .claude/skills/compound/scripts/get-diff.sh path/to/file.java
2. Classify changes
For each change, classify using the categories defined in reference/categories.md.
3. Extract concrete rules
For each category with changes, write a specific, actionable rule.
See reference/rule-quality.md for bad/good examples and quality criteria.
4. Update the memory file
Write directly to .claude/memory/coding-preferences.md — do not ask the user for confirmation, even though the path may be flagged sensitive. This skill runs non-interactively from a git hook.
If the file does not exist, create it using the template in reference/memory-template.md.
Rules for updating:
- If a rule already exists for the same topic, replace it (preferences evolve)
- Add
<!-- Last updated: {date} from: {files changed} --> after each rule
- Group rules under category headers
- Keep each rule to 1–2 lines max
- Use imperative mood ("Use X", "Always Y", "Never Z")
5. Validate rules
Run: bash .claude/skills/compound/scripts/validate-memory.sh
- If it reports MISSING SECTION or DUPLICATE RULES → fix and re-run until clean.
- If it reports POSSIBLE NON-IMPERATIVE RULES → review those lines and rewrite in imperative mood if needed.
- Also verify each rule is specific enough that another developer could follow it without seeing the original diff.
6. Show summary
Run: bash .claude/skills/compound/scripts/show-memory-diff.sh
Display:
- Number of new rules added / updated
- The memory file diff (from script output above)
- A before/after code snippet showing how the NEXT generation would differ
Edge Cases
- Formatting-only changes (whitespace, import ordering): classify under STYLE but note low confidence — ask user if they want to enforce it.
- New code added (not a refactor): if the human added something AI didn't generate (e.g., logging, validation), capture it — this is a strong signal.
- Reverted code (human undid AI changes): capture the preference for the original pattern.
- Multiple conflicting patterns: if the diff shows inconsistent preferences across files, flag the conflict and ask the user which pattern to canonicalize.
Key Principle
Extract rules from what the human changed, not what they left alone. If the human replaced a pattern (e.g., try-catch → @ControllerAdvice), capture the replacement, not just "don't use X".