[00:00] We'll start by creating a new cursor rule. We'll call it mermaid. Hit enter and then paste some general rules I made around using mermaid diagrams on github. I'm going to swap this over to agent requested and just say whenever diagrams or mermaid is mentioned. So then if I hit command-i and open a chat and I say please create a diagram of an extremely basic to-do application in the root of my project, hit enter, it's going to pick up on my rules which you can see here.
[00:30] I'll just command-enter to accept, swap over to the default preview, so open preview to the side, and since this gets kind of tiny we're going to right-click on this and copy it into a new window. And this will allow us to command plus and command minus this window independently of our other window. So we can essentially close this with command w, close this over here with command b, we'll swap this over to open as editor, and just let it take up the entire window. And we can look through our diagram and let's say we want to add an edit task. Please add an edit task feature to our diagram.
[01:09] It'll think through it and then start spitting that out. And this is going to allow you to play with a much more visual representation of the code you want to eventually generate. Where you could take the diagram, hand it over to the agent, and say please create a plan based on this diagram. But for now let's try please add a sequence diagram beneath our current diagram, which represents optimistic updates and how things will sync to the database with our application. So this can have our current context of our to-do app, and then once it's done we can scroll down and you can see a representation.
[01:42] I'm even going to scroll this over a bit more. A representation of the sequence of doing something to the task, the app UI, then the local state and the database and how everything is going to communicate with each other. And then you can even just kind of freestyle, please create three other sequence diagrams which just represent some edge cases or things I might need to be aware of and highlight the areas which may be a bit more troublesome. So then it came up with three new cases and it's generating what they're going to look like. So let's scroll all the way down here.
[02:10] We can have a visual representation of conflict resolution. Here's one for out of order, offline cue sync, and this provides you an excellent way to really take a step back from the code, look at it visually, and make plans before you start taking action. At any point in all of this you could ask the agent to start building out these features or even generating diagrams from existing code or existing workflows. And the awesome thing is you just have these artifacts over in your markdown. We'll just accept everything real quick.
[02:39] And you have these artifacts which very succinctly, very tersely represent the features, edge cases, etc. That you're going to build into your code base and you can use these in cursor rules, you can use them in agents when generating features. They're just extremely useful in pretty much every scenario.