code-visualizer

rysweet/amplihack · updated Apr 8, 2026

MDX-style export adds YAML metadata + attribution linking explainx.ai and this canonical listing URL.

$npx skills add https://github.com/rysweet/amplihack --skill code-visualizer
0 commentsdiscussion
summary

Automatically generate and maintain visual code flow diagrams. This skill analyzes Python module structure, detects import relationships, and generates mermaid diagrams. It also monitors for staleness when code changes but diagrams don't.

skill.md

Code Visualizer Skill

Purpose

Automatically generate and maintain visual code flow diagrams. This skill analyzes Python module structure, detects import relationships, and generates mermaid diagrams. It also monitors for staleness when code changes but diagrams don't.

Philosophy Alignment

This skill embodies amplihack's core philosophy:

Ruthless Simplicity

  • Single responsibility: Visualize code structure - nothing more
  • Minimal dependencies: Uses only Python AST for analysis, delegates diagram syntax to mermaid-diagram-generator
  • No over-engineering: Timestamp-based staleness is simple and "good enough" for 90% of cases

Zero-BS Implementation

  • Real analysis: Actually parses Python AST to extract imports - no mock data
  • Honest limitations: Staleness detection is timestamp-based, not semantic (see Limitations section)
  • Working code: All algorithms shown are functional, not pseudocode

Modular Design (Bricks & Studs)

  • This skill is one brick: Code analysis and staleness detection
  • Delegates to other bricks: mermaid-diagram-generator for syntax, visualization-architect for complex diagrams
  • Clear studs (public contract): Analyze modules, generate diagrams, check freshness

Skill Delegation Architecture

code-visualizer (this skill)
├── Responsibilities:
│   ├── Python module analysis (AST parsing)
│   ├── Import relationship extraction
│   ├── Staleness detection (timestamp-based)
│   └── Orchestration of diagram generation
└── Delegates to:
    ├── mermaid-diagram-generator skill
    │   ├── Mermaid syntax generation
    │   ├── Diagram formatting and styling
    │   └── Markdown embedding
    └── visualization-architect agent
        ├── Complex multi-level architecture
        ├── ASCII art alternatives
        └── Cross-module dependency graphs

Invocation Pattern:

# code-visualizer analyzes code structure
modules = analyze_python_modules("src/")
relationships = extract_import_relationships(modules)

# Then delegates to mermaid-diagram-generator for syntax
Skill(skill="mermaid-diagram-generator")
# Provide: Module relationships, diagram type (flowchart/class), styling preferences
# Receive: Valid mermaid syntax ready for embedding

# For complex architectures, delegates to visualization-architect
Task(subagent_type="visualization-architect", prompt="Create multi-level diagram for...")

When to Use This Skill

  • New Module Creation: Auto-generate architecture diagram for new modules
  • PR Reviews: Show architecture impact of proposed changes
  • Staleness Detection: Check if existing diagrams reflect current code
  • Dependency Analysis: Visualize import relationships
  • Refactoring: Understand module dependencies before changes

Quick Start

Generate Diagram for Module

User: Generate a code flow diagram for the authentication module

Check Diagram Freshness

User: Are my architecture diagrams up to date?

Show PR Impact

User: What architecture changes does this PR introduce?

Core Capabilities

1. Module Analysis

Analyzes Python files to extract:

  • Import statements (internal and external)
  • Class definitions and inheritance
  • Function exports (__all__)
  • Module dependencies

2. Diagram Generation

Creates mermaid diagrams showing:

  • Module relationships (flowchart)
  • Class hierarchies (class diagram)
  • Data flow between components
  • Dependency graphs

3. Staleness Detection

Compares:

  • File modification timestamps
  • Git history for changes
  • Diagram content vs actual code structure
  • Missing modules in diagrams

Analysis Process

Step 1: Discover Modules

# Scan target directory for Python modules
modules = glob("**/*.py")
packages = identify_packages(modules)

Step 2: Extract Relationships

For each module:

  1. Parse import statements
  2. Identify local vs external imports
  3. Build dependency graph
  4. Detect circular dependencies

Step 3: Generate Diagram

flowchart TD
    subgraph core["Core Modules"]
        auth[auth.py]
        users[users.py]
        api[api.py]
    end

    subgraph utils["Utilities"]
        helpers[helpers.py]
        validators[validators.py]
    end

    api --> auth
    api --> users
    auth --> helpers
    users --> validators

Step 4: Check Freshness

Compare diagram timestamps with source files:

  • Diagram older than sources = STALE
  • Missing modules in diagram = INCOMPLETE
  • Extra modules in diagram = OUTDATED

Diagram Types

Module Dependency Graph

Best for: Showing import relationships between files

flowchart LR
    main[main.py] --> auth[auth/]
    main --> api[api/]
    auth --> models[models.py]
    api --> auth

Class Hierarchy

Best for: Showing inheritance and composition

classDiagram
    class BaseService {
        +process()
    }
    class AuthService {
        +login()
        +logout()
    }
    BaseService <|-- AuthService

Data Flow

Best for: Showing how data moves through system

flowchart TD
    Request[HTTP Request] --> Validate{Validate}
    Validate -->|Valid| Process[Process]
    Validate -->|Invalid| Error[Return Error]
    Process --> Response[HTTP Response]

Staleness Detection

How It Works

  1. Find Diagrams: Locate mermaid diagrams in README.md, ARCHITECTURE.md
  2. Extract Modules: Parse diagram for referenced modules
  3. Compare: Check if all current modules are represented
  4. Report: Generate freshness report

Freshness Report Format

## Diagram Freshness Report

### Status: STALE

**Diagrams Checked**: 3
**Fresh**: 1
**Stale**: 2

### Details

| File         | Last Updated | Code Changed | Status |
| ------------ | ------------ | ------------ | ------ |
| README.md    | 2025-01-01   | 2025-01-15   | STALE  |
| docs/ARCH.md | 2025-01-10   | 2025-01-10   | FRESH  |

### Missing from Diagrams

- `new_module.py` (added 2025-01-12)
- `api/v2.py` (added 2025-01-14)

### Recommended Actions

1. Update README.md architecture diagram
2. Add new_module.py to dependency graph

PR Architecture Impact

What It Shows

For a given PR or set of changes:

  1. New modules/files added
  2. Changed import relationships
  3. Deleted dependencies
  4. Modified class hierarchies

Impact Diagram

flowchart TD
    subgraph added["New"]
        style added fill:#90EE90
        new_api[api/v2.py]
    end

    subgraph modified["Modified"]
        style modified fill:#FFE4B5
        auth[auth.py]
    end

    subgraph existing["Unchanged"]
        users[users.py]
        models[models.py]
    end

    new_api --> auth
    auth --> models
    users --> models

Integration with Other Skills

Mermaid Diagram Generator

This skill uses mermaid-diagram-generator for:

  • Syntax generation
  • Diagram formatting
  • Embedding in markdown

Visualization Architect Agent

Delegates to visualization-architect for:

  • Complex architecture visualization
  • ASCII art alternatives
  • Multi-level diagrams

Usage Examples

Example 1: New Module Diagram

User: I just created a new payment module. Generate an architecture diagram.

Claude:
1. Analyzes payment/ directory
2. Extracts imports and dependencies
3. Generates mermaid flowchart
4. Suggests where to embed (README.md)

Example 2: Check Staleness

User: Are my diagrams up to date?

Claude:
1. Finds all mermaid diagrams in docs
2. Compares with current codebase
3. Reports stale diagrams
4. Lists missing modules
5. Suggests updates

Example 3: PR Impact

User: Show architecture impact of this PR

Claude:
1. Gets changed files from PR
2. Identifies new/modified/deleted modules
3. Generates impact diagram
4. Highlights dependency changes

Detection Algorithms

Import Analysis

# Extract imports from Python file
import ast

def extract_imports(file_path):
    """Extract import statements from Python file."""
    tree = ast.parse(Path(file_path).read_text())
    imports = []
    for node in ast.walk(tree):
        if isinstance(node, ast.Import):
            for alias in node.names:
                imports.append(alias.name)
        elif isinstance(node, ast.ImportFrom):
            i
how to use code-visualizer

How to use code-visualizer on Cursor

AI-first code editor with Composer

1

Prerequisites

Before installing skills in Cursor, ensure your development environment meets these requirements:

  • Cursor installed and configured on your development machine
  • Node.js version 16.0+ with npm package manager (verify with node --version)
  • Active project directory or workspace where you want to add code-visualizer
2

Execute installation command

Execute the skills CLI command in your project's root directory to begin installation:

$npx skills add https://github.com/rysweet/amplihack --skill code-visualizer

The skills CLI fetches code-visualizer from GitHub repository rysweet/amplihack and configures it for Cursor.

3

Select Cursor when prompted

The CLI will show a list of available agents. Use arrow keys to navigate and space to select Cursor:

◆ Which agents do you want to install to?
│ ── Universal (.agents/skills) ── always included ────
│ • Amp
│ • Antigravity
│ • Cline
│ • Codex
│ ●Cursor(selected)
│ • Cursor
│ • Windsurf
4

Verify installation

Confirm successful installation by checking the skill directory location:

.cursor/skills/code-visualizer

Reload or restart Cursor to activate code-visualizer. Access the skill through slash commands (e.g., /code-visualizer) or your agent's skill management interface.

Security & Verification Notice

We perform automated surface-level scans (Gen AI Scanner, Socket, Snyk) during installation. These checks detect common vulnerabilities but do not guarantee complete security. Always review skill source code and verify the publisher's reputation before production use.

Skills execute code in your development environment. Always verify the publisher's identity, review recent commits, and test in isolated environments before production deployment.

List & Monetize Your Skill

Submit your Claude Code skill and start earning

GET_STARTED →

Use Cases

User Story & Requirements Generation

Create detailed user stories, acceptance criteria, and feature specs

Example

Generate user stories for 'password reset feature' with acceptance criteria, edge cases, and test scenarios

Reduce spec writing time by 50%, ensure comprehensive coverage

Competitive Analysis

Research competitors, compare features, identify gaps

Example

Analyze 5 competitor products, create feature comparison matrix, suggest differentiation opportunities

Complete competitive research in 2 hours instead of 2 days

Roadmap Prioritization

Evaluate features using frameworks (RICE, ICE, Kano) and create prioritized backlogs

Example

Score 20 feature ideas using RICE framework, generate prioritized roadmap with rationale

Make data-driven prioritization decisions faster

Stakeholder Communication

Draft PRDs, status updates, and stakeholder presentations

Example

Create executive summary of Q3 roadmap, monthly progress report, feature launch announcement

Save 3-5 hours/week on communication overhead

Implementation Guide

Prerequisites

  • Claude Desktop or compatible AI client
  • Access to product documentation and roadmap tools (Jira, Notion, etc.)
  • Understanding of product management frameworks (RICE, Jobs-to-be-Done, etc.)
  • Stakeholder contact information and communication channels

Time Estimate

30-60 minutes to see productivity improvements

Installation Steps

  1. 1.Install product management skill
  2. 2.Start with user story generation for known feature
  3. 3.Progress to competitive analysis: research 2-3 competitors
  4. 4.Use for roadmap prioritization: apply RICE/ICE scoring
  5. 5.Draft stakeholder communications and refine based on feedback
  6. 6.Build template library for recurring PM tasks
  7. 7.Share effective prompts with product team

Common Pitfalls

  • Not validating competitive research—verify facts before sharing
  • Accepting user stories without involving engineering team
  • Over-relying on frameworks without qualitative judgment
  • Not customizing outputs to company culture and communication style
  • Skipping stakeholder validation of generated requirements

Best Practices

✓ Do

  • +Validate research and competitive analysis with real data
  • +Collaborate with engineering when generating technical requirements
  • +Customize frameworks and templates to your company context
  • +Use skill for first drafts, refine with stakeholder input
  • +Document successful prompt patterns for PM tasks
  • +Combine AI efficiency with human judgment and intuition

✗ Don't

  • Don't publish competitive analysis without fact-checking
  • Don't finalize user stories without engineering review
  • Don't make prioritization decisions solely on AI scoring
  • Don't skip customer validation of generated requirements
  • Don't ignore company-specific context and culture

💡 Pro Tips

  • Provide context: company goals, constraints, customer feedback
  • Ask for alternatives: 'Show 3 ways to prioritize this roadmap'
  • Request stakeholder-specific formatting: 'Executive summary vs. engineering spec'
  • Use skill for 70% generation + 30% customization to company needs

When to Use This

✓ Use When

Use for user story writing, competitive research, roadmap prioritization, stakeholder communication, and PRD drafting. Best for reducing repetitive documentation and research work.

✗ Avoid When

Avoid for strategic product vision (requires deep customer empathy), pricing decisions (needs market and financial expertise), or when face-to-face customer discovery is more valuable than speed.

Learning Path

  1. 1Basic: user stories, feature specs, status updates
  2. 2Intermediate: competitive analysis, prioritization frameworks, PRDs
  3. 3Advanced: product strategy, go-to-market planning, OKR setting
  4. 4Expert: product vision, market positioning, business model innovation

Discussion

Product Hunt–style comments (not star reviews)
  • No comments yet — start the thread.
general reviews

Ratings

4.661 reviews
  • Benjamin Thompson· Dec 28, 2024

    Solid pick for teams standardizing on skills: code-visualizer is focused, and the summary matches what you get after install.

  • Benjamin Robinson· Dec 24, 2024

    code-visualizer is among the better-maintained entries we tried; worth keeping pinned for repeat workflows.

  • Anika Agarwal· Dec 12, 2024

    Useful defaults in code-visualizer — fewer surprises than typical one-off scripts, and it plays nicely with `npx skills` flows.

  • Benjamin Desai· Dec 12, 2024

    We added code-visualizer from the explainx registry; install was straightforward and the SKILL.md answered most questions upfront.

  • Benjamin Sharma· Dec 8, 2024

    code-visualizer is among the better-maintained entries we tried; worth keeping pinned for repeat workflows.

  • Henry Khan· Nov 23, 2024

    code-visualizer fits our agent workflows well — practical, well scoped, and easy to wire into existing repos.

  • Soo Srinivasan· Nov 19, 2024

    I recommend code-visualizer for anyone iterating fast on agent tooling; clear intent and a small, reviewable surface area.

  • Harper Rao· Nov 15, 2024

    code-visualizer reduced setup friction for our internal harness; good balance of opinion and flexibility.

  • Henry Park· Nov 3, 2024

    code-visualizer has been reliable in day-to-day use. Documentation quality is above average for community skills.

  • Benjamin Garcia· Oct 22, 2024

    Solid pick for teams standardizing on skills: code-visualizer is focused, and the summary matches what you get after install.

showing 1-10 of 61

1 / 7