# Explain Code

> 解释代码的工作原理。当用户问"这是如何工作的"、"这段代码做什么"、需要理解代码逻辑时使用。

- **Type:** Skill
- **Install:** `agentstack add skill-almax000-claude-skills-explain-code`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [almax000](https://agentstack.voostack.com/s/almax000)
- **Installs:** 0
- **Category:** [Agent Skills](https://agentstack.voostack.com/c/agent-skills)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [almax000](https://github.com/almax000)
- **Source:** https://github.com/almax000/claude-skills/tree/main/explain-code

## Install

```sh
agentstack add skill-almax000-claude-skills-explain-code
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# 代码解释助手

## 解释方法

### 1. 从整体到细节

先给出高层次的概述，再深入细节：

```
这段代码的作用是 [一句话概述]

它通过以下步骤实现：
1. 首先...
2. 然后...
3. 最后...
```

### 2. 使用类比

将代码概念与日常生活类比：

- **Promise** → 餐厅取餐号
- **回调函数** → 留下电话等回电
- **缓存** → 便利贴备忘
- **队列** → 排队
- **栈** → 叠盘子
- **递归** → 俄罗斯套娃

### 3. 绘制图表

用 ASCII 图展示流程或结构：

```
请求 → [验证] → [处理] → [响应]
           ↓
        [错误处理]
```

```
┌─────────────┐
│   Controller │
└──────┬──────┘
       │
       ▼
┌─────────────┐
│   Service    │
└──────┬──────┘
       │
       ▼
┌─────────────┐
│  Repository  │
└─────────────┘
```

### 4. 逐步讲解

对于复杂代码，逐行/逐块解释：

```javascript
// 1. 获取用户输入
const input = getUserInput();

// 2. 验证输入格式
if (!isValid(input)) {
  throw new Error('Invalid input');
}

// 3. 处理数据
const result = process(input);
```

### 5. 突出关键点

指出：
- 核心逻辑是什么
- 为什么这样设计
- 常见的误解或陷阱
- 可能的改进空间

## 输出格式

```
## 代码概述
[一句话说明这段代码的作用]

## 工作原理
[用类比或图表解释核心概念]

## 详细步骤
1. [步骤1]
2. [步骤2]
...

## 关键点
- [重要的设计决策]
- [需要注意的地方]

## 相关知识
- [涉及的概念或模式]
```

## 原则

- 根据受众调整深度
- 避免术语堆砌，用简单语言
- 复杂概念用多个角度解释
- 鼓励提问和互动

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [almax000](https://github.com/almax000)
- **Source:** [almax000/claude-skills](https://github.com/almax000/claude-skills)
- **License:** MIT

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-almax000-claude-skills-explain-code
- Seller: https://agentstack.voostack.com/s/almax000
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
