AgentSkillsCN

explaining-code

通过直观的图表和生动的类比来讲解代码。适用于在解释代码运行原理、介绍代码库,或当用户提出“这段代码是怎么工作的?”“这段代码是做什么的?”“能帮我一步步梳理这段代码吗?”这类问题时使用。

SKILL.md
--- frontmatter
name: explaining-code
description: Explains code with visual diagrams and analogies. Use when explaining how code works, teaching about a codebase, when the user asks "how does this work?", "what does this do?", or "walk me through this code".

When explaining code, always include:

  1. Start with an analogy: Compare the code to something from everyday life
  2. Draw a diagram: Use ASCII art to show the flow, structure, or relationships
  3. Walk through the code: Explain step-by-step what happens
  4. Highlight a gotcha: What's a common mistake or misconception?

Keep explanations conversational. For complex concepts, use multiple analogies.

Explanation Techniques

TechniqueUse WhenExample
AnalogyAbstract concepts"A mutex is like a bathroom key"
ASCII diagramData flow, architectureBox-and-arrow diagrams
Step traceAlgorithm logic"First x=5, then after line 3..."
Before/AfterTransformationsShow input → output

Output Structure

  1. Overview - 1-2 sentence summary of what and why
  2. Analogy - Everyday comparison
  3. Visual - ASCII diagram or structured representation
  4. Step-by-Step - Numbered walkthrough
  5. Key Gotcha - Non-obvious behavior to watch for