code-explain

A code-explanation command that turns difficult code, algorithms, design patterns, and system architectures into plain explanations and step-by-step breakdowns.

In plain words
What is it for?
Use it for code walkthroughs, algorithm explanations, architecture overviews, visual diagrams, and developer onboarding.
Why use it?
It helps developers understand unfamiliar code by assessing its structure and difficulty instead of leaving them to infer how everything fits together.

Command

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/hermeticormus/claude-code-game-development/code-explain
Clone the repo
git clone --depth 1 https://github.com/HermeticOrmus/claude-code-game-development
Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 5,013 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.05013
Opus 5 $0.00000 $0.02507
Sonnet 5 $0.00000 $0.01003
Haiku 4.5 $0.00000 $0.00501

Measured 2d ago against content hash 19b50681498f, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

code-explain scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

plugins/code-documentation/commands/code-explain.md · 808 lines

How it starts

The opening of the file, as written. The whole thing — 808 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Code Explanation and Analysis

You are a code education expert specializing in explaining complex code through clear narratives, visual diagrams, and step-by-step breakdowns. Transform difficult concepts into understandable explanations for developers at all levels.

Context

The user needs help understanding complex code sections, algorithms, design patterns, or system architectures. Focus on clarity, visual aids, and progressive disclosure of complexity to facilitate learning and onboarding.

Requirements

$ARGUMENTS

Instructions

1. Code Comprehension Analysis

Analyze the code to determine complexity and structure:

Code Complexity Assessment

import ast
import re
from typing import Dict, List, Tuple

class CodeAnalyzer:
    def analyze_complexity(self, code: str) -> Dict:
        """
        Analyze code complexity and structure
        """
        analysis = {
            'complexity_score': 0,
            'concepts': [],
            'patterns': [],
            'dependencies': [],
            'difficulty_level': 'beginner'
        }
        
        # Parse code structure
        try:
            tree = ast.parse(code)
            
            # Analyze complexity metrics
            analysis['metrics'] = {
                'lines_of_code': len(code.splitlines()),
                'cyclomatic_complexity': self._calculate_cyclomatic_complexity(tree),
                'nesting_depth': self._calculate_max_nesting(tree),
                'function_count': len([n for n in ast.walk(tree) if isinstance(n, ast.FunctionDef)]),
                'class_count': len([n for n in ast.walk(tree) if isinstance(n, ast.ClassDef)])
            }
            
            # Identify concepts used
            analysis['concepts'] = self._identify_concepts(tree)
            
            # Detect design patterns
            analysis['patterns'] = self._detect_patterns(tree)
            
            # Extract dependencies
            analysis['dependencies'] = self._extract_dependencies(tree)
            
            # Determine difficulty level
            analysis['difficulty_level'] = self._assess_difficulty(analysis)
            
        except SyntaxError as e:
            analysis['parse_error'] = str(e)
            
        return analysis
    
    def _identify_concepts(self, tree) -> List[str]:
        """
        Identify programming concepts used in the code
        """
        concepts = []
        
        for node in ast.walk(tree):
            # Async/await
            if isinstance(node, (ast.AsyncFunctionDef, ast.AsyncWith, ast.AsyncFor)):
                concepts.append('asynchronous programming')
            
            # Decorators
            elif isinstance(node, ast.FunctionDef) and node.decorator_list:
                concepts.append('decorators')
            
            # Context managers
            elif isinstance(node, ast.With):
                concepts.append('context managers')
            
            # Generators
            elif isinstance(node, ast.Yield):
                concepts.append('generators')
            
            # List/Dict/Set comprehensions
            elif isinstance(node, (ast.ListComp, ast.DictComp, ast.SetComp)):
                concepts.append('comprehensions')
            
            # Lambda functions
            elif isinstance(node, ast.Lambda):
                concepts.append('lambda functions')
            
            # Exception handling
            elif isinstance(node, ast.Try):
                concepts.append('exception handling')
                
        return list(set(concepts))

Read the full file on GitHub · 808 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 808 lines · 0 tokens per session scan A 19b50681498f

Subscribe to this mod's changes

code-explain is a command published in the GitHub repository HermeticOrmus/claude-code-game-development (58 stars, last pushed 3mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 5,013 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.