Ask Claude to Generate Mermaid Diagrams from Your Actual Code
Understanding how a codebase fits together is hard from reading files alone. Ask Claude to read your code and produce a Mermaid diagram you can actually render and share.
"Read the models in app/Models/ and generate a Mermaid ER diagram showing all the relationships"
Claude reads the Eloquent models (or ActiveRecord, or SQLAlchemy — whatever your ORM), traces the relationships, and outputs Mermaid syntax:
erDiagram
User ||--o{ Order : "has many"
Order ||--|{ OrderItem : "contains"
OrderItem }o--|| Product : "references"
User ||--o{ Address : "has many"
Order }o--|| Address : "ships to"
You can ask for different diagram types depending on what you need to understand:
# How requests flow through middleware and controllers
"Generate a Mermaid sequence diagram for the checkout flow"
# How classes relate to each other
"Create a Mermaid class diagram for the payment module"
# How the state machine works
"Draw a Mermaid state diagram for order status transitions"
# How the deployment pipeline works
"Read the CI config and generate a Mermaid flowchart of the pipeline stages"
The diagrams render in GitHub markdown, Notion, Confluence, VS Code preview, and dozens of other tools — just wrap the output in a mermaid code block.
This is especially useful for:
- Onboarding — generate architecture diagrams for new team members
- Documentation — create living diagrams derived from code, not memory
- Code reviews — visualize the impact of a structural change before approving
- Planning — see the current state before designing the next iteration
Code tells you what exists. Diagrams tell you how it connects — let Claude draw the map from the territory.
via Claude Code
Log in to leave a comment.
Set up Claude Code as an automated reviewer in your CI pipeline — on every pull request, it reads the diff, checks for bugs, security issues, missing tests, and convention violations, then posts its findings as a PR comment. Your human reviewers get a head start because the obvious issues are already flagged before they look.
Before deploying, tell Claude to read your project — migrations, environment variables, queue workers, scheduled tasks, caching, third-party integrations — and generate a deployment checklist that's specific to your app. Not a generic "did you run migrations?" list, but one that knows YOUR infrastructure and catches the things YOUR deploy can break.
Instead of writing a README from memory or copying a template, tell Claude to read your project and generate one that's actually accurate — real setup instructions from your config, real architecture from your directory structure, real API examples from your routes, and real prerequisites from your dependency files.