Skip to main content
ClaudeWave
Slash Command65 estrellas del repoactualizado yesterday

explain-code

Explain complex Solana/blockchain code with visual diagrams and step-by-step breakdowns

Instalar en Claude Code
Copiar
mkdir -p ~/.claude/commands && curl -fsSL https://raw.githubusercontent.com/solanabr/solana-ai-kit/HEAD/.claude/commands/explain-code.md -o ~/.claude/commands/explain-code.md
Después abre una sesión nueva de Claude Code; el slash command carga automáticamente.

explain-code.md

Explain complex Solana blockchain code through clear narratives, visual diagrams, and step-by-step breakdowns.

## Code to Explain

$ARGUMENTS

## Related Context

- **Solana Concepts**: See [SKILL.md](../skills/SKILL.md) for concept references
- **Anchor Patterns**: See [programs/anchor.md](../skills/ext/solana-dev/skill/references/programs/anchor.md)
- **Learning Approach**: See **solana-guide** agent for educational patterns

## Explanation Framework

### 1. Initial Assessment

Determine:
- **Code type**: Program instruction, client code, account structure, test
- **Complexity level**: Beginner, intermediate, advanced
- **Key concepts**: What Solana/blockchain concepts are used
- **Target audience**: Adjust depth accordingly

### 2. Explanation Structure

**High-Level Overview**
- What does this code do? (1-2 sentences)
- What problem does it solve?
- Key concepts used

**Visual Diagram**
- Use Mermaid flowcharts for control flow
- Use relationship diagrams for account structures
- Use ASCII art for simple data flows

**Step-by-Step Breakdown**
- Walk through each significant section
- Explain what's happening AND why it matters
- Highlight non-obvious decisions

**Concept Deep Dives**
For Solana concepts encountered (PDAs, CPIs, etc.):
- Brief explanation of the concept
- How it's used in this code
- Common pitfalls to avoid

**Security Analysis**
- Access control checks
- Validation patterns
- Potential issues or considerations

**Patterns Identified**
- Design patterns used (state machine, authority, escrow, etc.)
- Why the pattern fits this use case

### 3. Interactive Elements

Include comprehension checks:
- "What would happen if...?"
- "How would you modify this to...?"
- Links to related concepts for further learning

## Output Format

1. **Overview** - What does this code do? (2-3 sentences)
2. **Visual Diagram** - Flow chart or relationship diagram (Mermaid)
3. **Step-by-Step** - Walk through significant sections
4. **Deep Dives** - Explain Solana-specific concepts encountered
5. **Security** - Highlight security considerations
6. **Patterns** - Identify design patterns used
7. **Questions** - Comprehension checks

Adjust depth based on complexity. Simple code needs brief explanation. Complex code needs thorough breakdowns with diagrams.

For comprehensive educational content, delegate to **solana-guide** agent.
anchor-engineerSubagent

Anchor framework specialist for rapid Solana program development. Use for building programs with Anchor macros, IDL generation, account validation, and standardized patterns. Prioritizes developer experience while maintaining security.\\n\\nUse when: Building new programs quickly, team projects needing standardization, projects requiring IDL for client generation, or when developer experience is prioritized over maximum CU optimization.

defi-engineerSubagent

DeFi integration specialist for composing with Solana protocols including Jupiter, Drift, Kamino, Raydium, Orca, Meteora, Marginfi, and Sanctum. Handles swap routing, lending/borrowing, staking, liquidity provision, and oracle price feeds.\n\nUse when: Integrating DeFi protocols, building swap interfaces, implementing lending/borrowing, setting up yield strategies, working with Pyth/Switchboard oracles, or composing multi-protocol transactions.

devops-engineerSubagent

CI/CD, infrastructure, and deployment specialist for Solana projects. Handles GitHub Actions, Docker, monitoring, RPC management, and Cloudflare Workers edge deployment.\n\nUse when: Setting up CI/CD pipelines, containerizing Solana validators or programs, configuring monitoring and alerting, managing RPC infrastructure, deploying edge workers, or automating build and deploy workflows.

game-architectSubagent

Senior Solana game architect for game system design, Unity/C# architecture, on-chain game state, player progression, NFT integration, and PlaySolana ecosystem. Use for high-level game design decisions, architecture reviews, and planning complex game systems.\n\nUse when: Designing new Solana games from scratch, planning game state on-chain, Unity project architecture, integrating with PlaySolana/PSG1, or deciding between implementation approaches.

mobile-engineerSubagent

React Native and Expo specialist for building Solana mobile dApps. Handles mobile wallet adapter integration, transaction signing UX, deep linking, and mobile-specific performance optimization.\n\nUse when: Building React Native or Expo mobile apps with Solana integration, implementing mobile wallet adapter flows, setting up deep links for transaction signing, or optimizing mobile dApp performance.

pinocchio-engineerSubagent

CU optimization specialist using Pinocchio framework. Use for performance-critical programs requiring 80-95% CU reduction vs Anchor. Specializes in zero-copy access, manual validation, and minimal binary size.\\n\\nUse when: CU limits are being hit, transaction costs are significant at scale, binary size must be minimized, or maximum throughput is required.

rust-backend-engineerSubagent

Rust backend specialist for building async services that interact with Solana blockchain. Builds APIs, indexing services, and off-chain processing using Axum, Tokio, and modern async patterns.\n\nUse when: Building REST/WebSocket APIs for Solana dApps, implementing transaction indexers, creating webhook services, or any Rust backend that interacts with Solana.

solana-architectSubagent

Senior Solana program architect for system design, account structures, PDA schemes, token economics, and cross-program composability. Use for high-level design decisions, architecture reviews, and planning complex multi-program systems.\n\nUse when: Designing new programs from scratch, planning account structures, optimizing PDA schemes, reviewing architecture for security, or deciding between implementation approaches.