home / skills / toilahuongg / shopify-agents-kit / explain

explain skill

/.claude/skills/explain

This skill provides a clear, thorough explanation of code, covering what it does, how it works, and why it matters for understanding.

npx playbooks add skill toilahuongg/shopify-agents-kit --skill explain

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
1.9 KB
---
name: explain
description: Explain code in detail - what it does, how it works, and why. Use when you need to understand unfamiliar code or explain code to others.
argument-hint: "[file path, file:line-range, or function name]"
---

# Explain Code

Provide a clear, thorough explanation of the specified code.

## Input

The user will provide one of:
- A file path: `/explain src/auth/jwt.ts`
- A file path with line range: `/explain src/auth/jwt.ts:45-80`
- A function/class name: `/explain parseToken`
- Just `/explain` — explain the currently open or most recently discussed file

## Explanation Structure

### 1. Overview (2-3 sentences)
What does this code do at a high level? What problem does it solve?

### 2. Key Components

Break down the major parts:

```
## Function: functionName

**Purpose:** One sentence description

**Parameters:**
- `param1` (type) — what it's for
- `param2` (type) — what it's for

**Returns:** What and when

**Side effects:** Any mutations, API calls, state changes
```

### 3. Control Flow

Explain the execution path:
1. First, it does X
2. Then checks Y
3. If Y is true, Z happens
4. Otherwise, W happens

Use a simple flowchart for complex logic:

```
Input -> Validate -> Transform -> Output
              |
           Error -> Log -> Return null
```

### 4. Dependencies

What does this code depend on?
- External libraries
- Internal modules
- Environment variables
- Database/API connections

### 5. Gotchas & Edge Cases

Things that might surprise someone:
- Non-obvious behavior
- Edge cases handled (or not handled)
- Performance considerations
- Known limitations

### 6. Usage Example

Show how to use this code:

```typescript
// Example usage
const result = functionName(arg1, arg2);
```

## Tone

- Assume the reader is a competent developer unfamiliar with this specific code
- Avoid jargon unless defining it
- Use "this code" not "the code" for clarity
- Be concise but complete

Overview

This skill explains code in detail: what it does, how it works, and why. It accepts a file path, a file path with line range, a function or class name, or a request to explain the currently open file. Use it when you need a clear, structured breakdown to understand unfamiliar code or to explain code to others.

How this skill works

You provide a target (file path, range, symbol, or current file). The skill parses that target, extracts the relevant code, and produces a structured explanation that covers overview, key components, control flow, dependencies, edge cases, and a short usage example. Explanations focus on practical details for a competent developer and highlight surprising behaviors and limitations.

When to use it

  • You encounter unfamiliar code and need to understand its purpose quickly.
  • Preparing code walkthroughs or documentation for teammates.
  • Reviewing a pull request and wanting a concise summary of changes.
  • Learning a new module, library, or internal API before integrating it.
  • Teaching or onboarding developers who need clear, focused explanations.

Best practices

  • Specify a precise target (file path, range, or symbol) to get focused output.
  • Include relevant context (calling code or file) when behavior depends on external state.
  • Ask follow-up questions for deeper dives on algorithms, edge cases, or performance.
  • Use the provided usage example as a starting point and adapt it to your environment.
  • Request additional explanations for related files or dependencies when needed.

Example use cases

  • Explain a single function by name to see its parameters, return value, and side effects.
  • Explain lines 45-80 of a file to inspect a complex conditional or loop.
  • Get a high-level overview of an authentication or database module before integration.
  • Produce a concise explanation to paste into code review comments or documentation.
  • Translate implementation details into discussion points for an architecture meeting.

FAQ

What input formats are accepted?

Provide a file path (/explain path/to/file), an optional line range (/explain path/to/file:10-30), a function or class name (/explain myFunction), or simply /explain to use the current file.

Can it show examples of how to call the code?

Yes. Each explanation includes a short usage example showing typical invocation and expected output or behavior.

How deep does the explanation go?

Explanations are practical and focused: overview, component breakdown, control flow, dependencies, gotchas, and a usage example. Request follow-ups for deeper algorithmic or performance analysis.