Snippet
Copy and paste this snippet when you need code explained:
Code Explanation Protocol:
Explain the provided code using this layered approach:
1. Executive Summary (2-3 sentences):
What does this code do at a high level? What problem does it solve?
Use plain language that a product manager could understand.
2. Architecture Overview:
- What are the main components/modules involved?
- How do they interact? (describe the data flow)
- What design patterns are being used, if any?
- Create a simple diagram if it aids understanding
3. Step-by-Step Walkthrough:
Walk through the code execution chronologically:
- Entry point: Where does execution begin?
- Key decision points: What branches or conditions exist?
- Data transformations: How is data modified along the way?
- Exit points: What are the possible outcomes?
4. Critical Details:
Highlight the non-obvious aspects:
- Why was this approach chosen over alternatives?
- What are the assumptions this code makes?
- Where are the potential failure points?
- What dependencies or side effects exist?
5. Terminology Glossary:
Define any domain-specific terms, library functions, or patterns used.
Format: `term` — definition
6. Questions to Clarify:
If any part of the code's purpose or behavior is ambiguous, list specific questions rather than guessing.How It Works
This snippet helps you understand unfamiliar code by:
- Progressive depth - Start high-level, drill down as needed
- Visual thinking - Encourages diagrams for complex flows
- Honest uncertainty - Prevents hallucinated explanations
- Vocabulary building - Builds your domain knowledge
Use this snippet when onboarding to a new codebase, debugging unfamiliar code, or preparing to modify code you didn't write.