
Code Documentation Code Explain
Turn unfamiliar code into structured explanations with complexity metrics, concepts, and patterns before you document, review, or refactor it.
Overview
Code Documentation Code Explain is an agent skill most often used in Build (also Ship review, Operate iterate) that analyzes code structure and produces layered explanations with complexity metrics and concept maps.
Install
npx skills add https://github.com/sickn33/antigravity-awesome-skills --skill code-documentation-code-explainWhat is this skill?
- Code comprehension workflow: complexity assessment, concepts, patterns, and dependency inventory
- AST-driven metrics including lines of code, cyclomatic complexity, nesting depth, and function/class counts
- Difficulty leveling (beginner through advanced) from structural signals
- Implementation playbook with checklists and code samples for repeatable agent runs
- Fits pre-doc and pre-review passes on Python-style trees via ast.parse patterns
Adoption & trust: 754 installs on skills.sh; 40.1k GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
You inherited or generated code and cannot quickly explain what it does, how hard it is to change, or which patterns it relies on.
Who is it for?
Solo builders documenting legacy modules, prepping agent handoffs, or writing review summaries with objective complexity signals.
Skip if: Teams that only need auto-generated API reference from typed stubs without narrative analysis, or when you already have an approved architecture doc and only need spelling fixes.
When should I use this skill?
You need a structured explanation of code complexity, concepts, and patterns before documenting, reviewing, or refactoring.
What do I get? / Deliverables
You get a structured complexity and concept breakdown you can paste into docs, PR descriptions, or a follow-up refactor plan.
- Complexity assessment with metrics and difficulty level
- Lists of concepts, patterns, and dependencies
- Narrative explanation suitable for docs or PR notes
Recommended Skills
Journey fit
Spans multiple journey phases - primary shelf plus alternate fits below.
Canonical shelf is Build → docs because the playbook’s end state is comprehension artifacts you attach to READMEs, ADRs, and handoffs. Docs is where solo builders need plain-language maps of modules—not just line comments—so agents and future-you can navigate the codebase.
Where it fits
Draft a module overview for your SaaS API after the agent scores nesting depth and lists design patterns.
Summarize a contributor PR with difficulty level and concept list before you approve merge.
Re-explain a utility file you wrote six months ago before patching a production bug.
How it compares
Use for guided explanation and structural analysis instead of running a generic linter with no teaching narrative.
Common Questions / FAQ
Who is code-documentation-code-explain for?
Indie developers and small teams using Claude Code, Cursor, or Codex who need readable explanations of non-trivial code before documenting or reviewing it.
When should I use code-documentation-code-explain?
During Build docs when drafting README sections; in Ship review when summarizing a PR for yourself; in Operate iterate when re-learning a module you have not touched in months.
Is code-documentation-code-explain safe to install?
Review the Security Audits panel on this Prism page and only point the skill at code you are allowed to share with your agent environment.
SKILL.md
READMESKILL.md - Code Documentation Code Explain
# Code Explanation and Analysis Implementation Playbook This file contains detailed patterns, checklists, and code samples referenced by the skill. ## Instructions ### 1. Code Comprehension Analysis Analyze the code to determine complexity and structure: **Code Complexity Assessment** ```python 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)) ``` ### 2. Visual Explanation Generation Create visual representations of code flow: **Flow Diagram Generation** ```python class VisualExplainer: def generate_flow_diagram(self, code_structure): """ Generate Mermaid diagram showing code flow """ diagram = "```mermaid\nflowchart TD\n" # Example: Function call flow if code_structure['type'] == 'function_flow': nodes = [] edges = [] for i, func in enumerate(code_structure['functions']): node_id = f"F{i}" nodes.append(f" {node_id}[{func['name']}]") # Add function details if func.get('parameters'):