AgentSkillsCN

explain-code

借助直观的图表与生动的类比,深入浅出地讲解代码。当您需要向他人解释代码的工作原理、介绍某个代码库,或回答用户“这段代码是怎么运作的?”这类问题时,可使用此技能。

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

When explaining code, always include:

  1. Start with an analogy: Compare the code to something from everyday life that makes the concept click instantly

  2. Draw a diagram: Use ASCII art to show the flow, structure, or relationships

    • For functions: show input → process → output
    • For classes: show hierarchy or composition
    • For data flow: show how data moves through the system
  3. Walk through the code: Explain step-by-step what happens when the code runs

    • Use concrete example values where helpful
    • Trace the execution path
  4. Highlight key insights:

    • What's a common mistake or misconception?
    • Why was it designed this way?
    • What edge cases should you watch for?
  5. Summarize in one sentence: End with a TL;DR that captures the essence

Keep explanations conversational and approachable. For complex concepts, layer multiple analogies. Adjust depth based on the complexity of the code—simple functions need brief explanations, architectural patterns deserve thorough breakdowns.