AgentSkillsCN

explain-diff

以丰富且交互性强的 HTML 格式,为代码差异或 PR 提供详尽的解释,包含背景介绍、核心理念、代码详解,以及趣味问答环节。当用户希望以交互式的单页 HTML 格式,借助图表与标注来解释代码差异、补丁或 PR 时,可使用此技能。

SKILL.md
--- frontmatter
name: explain-diff
description: Generate a rich, interactive HTML explanation of a code diff/PR with background, intuition, code walkthrough, and a quiz. Use when a user asks to explain a diff, patch, or PR in an interactive single-page HTML format with diagrams and callouts.

Explain Diff

Overview

Create a single self-contained HTML page that explains a code change with clear background, intuition, a structured walkthrough of the code changes, and an interactive quiz. Write with the clarity and flow of Martin Kleppmann, and favor concrete examples, diagrams, and callouts.

Workflow

  1. Gather context

    • Inspect the change and the surrounding code paths to understand how the system works before and after.
    • Identify the main behavioral change, key data flows, and any user-visible impact.
  2. Draft the content

    • Background: Provide a deep, beginner-friendly overview first, then a narrower background directly relevant to the change.
    • Intuition: Explain the essence of the change with toy examples and reusable diagram families.
    • Code: Walk through the change at a high level, grouping related modifications for clarity.
    • Quiz: Write five medium-difficulty multiple-choice questions that require real understanding, with immediate feedback.
  3. Build the HTML

    • Output a single HTML file that includes all CSS and JavaScript inline.
    • Use a table of contents and clear section headers on one long page (no tabs).
    • Provide responsive styling for mobile.
    • Use HTML-based diagrams (divs, lists, tables) and avoid ASCII diagrams.
    • Add callouts for key concepts, definitions, and edge cases.
  4. Save location and naming

    • Save the file outside the repo at /tmp/explanation-YYYY-MM-DD-<slug>.html.
    • Use today’s date and a short, descriptive slug derived from the change.

Output checklist

  • Single self-contained HTML file with inline CSS/JS
  • Table of contents
  • Sections: Background, Intuition, Code, Quiz
  • Interactive multiple-choice quiz with feedback
  • Diagrams rendered with HTML/CSS (no ASCII)
  • Callouts for key points and edge cases
  • Saved in /tmp with date-based filename