Advanced Claude Code techniques: context loading, mermaid diagrams, stop hooks, and more | John Lindquist

26 Jan 2026 · 57 min · 20 chapters

Ask about this episode

Ask anything about it. ChatGPT or Claude reads this page and answers with the times it was said.

Connect VO and ask about every podcast you hear, including the moments you saved. Add to ChatGPT · Add to Claude

In short

Advanced Claude Code techniques for faster, higher-quality engineering using preloaded context (Mermaid diagrams), terminal/CLI workflows (aliases, custom CLIs), and automated quality gates via Claude “stop hooks” that run typecheck/lint/build checks and then commit.

Guest backgrounds

John Lindquist is a super user of AI-powered engineering tools (Claude Code, Cursor) and runs/teaches through aked.io/egghead.io. He teaches workshops and publishes an “AI Dev Essentials” newsletter.

Key claims

Preloading app behavior as Mermaid diagrams in a system prompt prevents slow codebase discovery and improves reliability, at the cost of more upfront tokens. Claude Code stop hooks can automate “fix errors then commit” loops by running scripts (e.g., bun type check) after the agent finishes. Team-wide shared hook/configs scale baseline quality. CLI wrappers constrain UI to the terminal for fast ideation/prototyping.

Notable examples

Mermaid “authentication flow” explanation without file reads; GitHub Actions generating diagram markdown on PR close; a stop hook that checks for TypeScript errors and blocks/feeds back the report; a “Sketch” CLI that generates website images via Gemini CLI and then iterates into site building.

Written by AI. May contain mistakes. Listen to the episode to check what was said.

Chapters

Tap a time to open that second in VO

Understanding Context and Diagrams

0:45 to 2:05

Exploration of how context and diagrams enhance AI coding capabilities.

“It's going to come up with results much quicker.”

Introduction of John Lindquist

2:05 to 4:02

Host Claire Vowell introduces John Lindquist and sets the episode's focus.

“This episode is brought to you by WorkOS.”

Utilizing Mermaid Diagrams for AI

4:53 to 6:42

Discussion on how to use mermaid diagrams to visualize application workflows.

“to help the AI understand the flow and how the pieces are connected.”

Implementing Context in AI

6:42 to 8:50

How to preload context for AI using markdown and diagrams in coding.

“the more diagrams you'll have and you can kind of pick and choose which ones to load I'm going to load them all in and I'm just going to open a terminal of the editor area.”

Exploring Different File Types for AI

8:50 to 12:29

Insights on using various file formats to enhance AI tool performance.

“So when I let this run, you'll notice that there's, it's now prompting the user to do something.”

Generating Documentation with Diagrams

12:29 to 14:03

John Lindquist explains the importance of generating diagrams for documentation.

“We'll see if there's more file types that emerge.”

Harnessing Mermaid Diagrams for AI Development

14:03 to 18:04

Learn how to utilize mermaid diagrams to accelerate AI project development and compliance.

“I think for a lot of the projects, we already have pre-existing code bases that don't have diagrams.”

Efficient Command Usage and Scripting

19:01 to 26:40

Explore efficient command usage and scripting techniques for AI tools and workflows.

“So you showed us how to just pull all of these documents into a system prompt.”

Maintaining Code Quality with Advanced Techniques

26:40 to 28:00

Understand advanced techniques for maintaining high-quality code in AI projects.

“So for example, let's say it wrote out this code and there was this error in here.”

Understanding Stop Hooks in Claude

28:00 to 30:00

Learn how to set up and utilize stop hooks in Claude for efficient programming.

“You can set up what are called hooks and I'm going to set what's called a stop hook and hit add new hook.”
Show all 20 chapters

Managing Errors and File Changes

30:00 to 35:00

Discover how to handle TypeScript errors and file changes with Claude effectively.

“see step one, were there files changed when we stopped?”

Optimizing Development with Hooks

35:00 to 36:40

Explore various use cases for hooks in Claude to enhance development efficiency.

“It definitely saves so much time where you don't have to go back in and say, well, please fix this or please run this command or please do this.”

Creative Applications of Claude Hooks

36:40 to 38:50

Learn about non-technical applications of Claude hooks for automating tasks beyond coding.

“Other than, you know, type TypeScript errors, just prattle off a couple other use cases.”

Leveraging Claude for Code Quality

38:50 to 41:05

Understand how to use Claude to automate code quality checks and document generation.

“So I think just the general framework is really useful.”

Future of IDEs and Command Line Tools

41:05 to 42:00

Discuss the evolving landscape of IDEs and command line tools in software development.

“Okay, well, I'm going to ask you a couple lightning around questions and then we will get you back to your very efficient AI coding.”

The Role of IDEs and CLIs in Development

42:00 to 45:36

Explore the importance of both IDEs and CLIs in software development and their unique benefits.

“that I talk to, you know, terminal UI, IDE or both.”

Selling AI Tools to Skeptical Engineers

45:36 to 49:49

Learn how to effectively communicate the value of AI tools to experienced software engineers.

“This is not, you know, I hope you all hung out and listened to it, but it's not for our vibe coders and our non-technical folks.”

Improving Workflows with AI Assistance

49:49 to 53:59

Discover how AI can streamline workflows and assist developers in managing tasks more efficiently.

“And you'd say, well, I'd go trace who wrote the code.”

Resetting AI Conversations for Better Outcomes

53:59 to 55:16

Find out effective techniques to reset and refocus AI conversations when they go off track.

“And so it's really funny to hear the idea, okay, like I'm having a debate with my AI.”

John Lindquist's AI Resources and Workshops

55:16 to 56:00

Learn about John Lindquist's courses and resources on AI tooling and how to engage with him.

“Where can we find you and how can we be helpful?”
Hear the part that matters, and keep it.Open this episode in VO. Double tap your headphones to save a moment as you listen.
Get VO free

Transcript

Automatic transcript. May contain errors.

0:00There are people out there definitely like me that really want to know the advanced techniques that can leverage the most powerful parts of these AI powered coding tools. Where do you want us to get started that you think many people don't think about in terms of how they can use these tools?

0:15John Lindquist:Context and diagrams is a great place to start. They're definitely the best way to get AI to do what you want. So they have what are called mermaid diagrams. This is a way of visualizing database operations. And it's a way of essentially compressing your application down into very small lines of text that show how your application works. Now, for a human to read this, this is a big challenge. But an AI can consume this easily. I could even just say, please explain the authentication flow. And because it already has it in the context, it's not going to have to do a bunch of file reads and code base exploration to figure this out.

0:51John Lindquist:It's going to come up with results much quicker. if I gave you infinite junior to mid-career talent who is always available, who would do the work you would do if you had unlimited amount of time and no meetings, what would you do when a ticket came in? Like, what would you do?

1:10Welcome back to How I AI. I'm Claire Vowell, product leader and AI obsessive here on a mission to help you build better with these new tools. Today, we have John linguist at aked.io who is a super user of AI powered engineering tools like cursor and clod code. Now I love all you non-technical folks out there but this is an episode for the senior software engineers who really want to understand how they can use the power features of some of these AI engineering tools to really both optimize the quality of code that they're generating but also become more efficient as they use their IDE terminal and AI assistants to write, check, and deploy code.

1:55This is a great episode for any of our advanced users out there. VPs of engineering, CTO, pay attention, send this to your staff engineers. Let's get to it. This episode is brought to you by WorkOS. AI has already changed how we work. Tools are helping teams write better code, analyze customer data, and even handle support tickets automatically. But there's a catch. These tools only work well when they have deep access to company systems. Your copilot needs to see your entire code base. Your chatbot needs to search across internal docs. And for enterprise buyers, that raises serious security concerns.

2:33That's why these apps face intense IT scrutiny from day one. To pass, they need secure authentication, access controls, audit logs, the whole suite of enterprise features. Building all that from scratch, it's a massive lift. That's where WorkOS comes in. WorkOS gives you drop-in APIs for enterprise features so your app can become enterprise-ready and scale up market faster. Think of it like Stripe for enterprise features. OpenAI, Perplexity, and Cursor are already using WorkOS to move faster and meet enterprise demands. Join them and hundreds of other industry leaders at WorkOS.com. Start building today.

3:15John, welcome to How I AI. I have to put some context here, which is we have done quite a bit of coding with cursor, vibe coding episodes, but a lot of what our audience has asked for is early maturity, less technical introductions to these tools. but there are people out there definitely like me and definitely like folks that follow you that really do know how to write great software and want to you know as people say of course I'm a 9x engineer but how do I become a 10x engineer with some of these tools want to know really the advanced techniques that can leverage the most powerful parts of these AI powered coding tools and get you really high quality software so I'm really excited about what you're going to show us today.

4:02And so where do you want us to get started that you think many people don't think about in terms of how they can use these tools?

4:09John Lindquist:Yeah, I think context and diagrams is a great place to start for us. They're definitely the best way to get AI to do what you want. So, and we'll be using cloud code throughout. Oh, great. Okay. And so, yeah, we've gotten a lot of kind of markdown files in How I AI, but not a lot of diagrams. So why don't you walk us through how you use those assets to help you code better? Yeah, so these diagrams are all generated from, I can share a prompt with however you want to share with the audience, that can walk through code base and generate diagrams based on user actions or user interactions, the events, the channels, whatever happens in your code to help the AI understand the flow and how the pieces are connected.

4:58John Lindquist:I think Windsurf recently came out with something called Code Maps, a similar concept, essentially preloading valuable context so that you have to remember that every time an AI starts, it has no memory, no idea of what's going on in your application. And people try and set up lots of rules and all this stuff around it. But they usually don't include a lot of how does my application work and how do the pieces fit? And so you get a lot of really bad edits because it doesn't understand if it modifies A, how does that impact B. So we want to preload a lot of that. We can do that using diagrams. So, for example, one of these diagrams will have, I call it their markdown files with diagrams in them.

5:46John Lindquist:So they have what are called mermaid diagrams. And mermaid is a standard format for rendering diagrams inside of markdown. So this is a way of visualizing database operations. And if you were to zoom in and look at how if a record exists, then do this and that. Yes, no. And it's a way of essentially compressing your application down into very small lines of text that show how your application works. Now for a human to read this, this is a big challenge. We need to open up this big visual and it turns into like looks like an image but an AI can consume this easily and it's like a very compressed very robust way of explaining application so we can feed these into our application at at the startup time and for the more advanced pro the larger projects you get on the more diagrams you'll have and you can kind of pick and choose which ones to load I'm going to load them all in and I'm just going to open a terminal of the editor area.

6:53John Lindquist:So the way I'm going to do this, if we look at Claude and we look at look at its options, you'll see a bunch of options. The one we're going to focus on is called Append System Prompt. So in there before we load in any sort of user prompt or anything. We're actually going to say clod append system prompt and the system prompt and then you can drop in some text and we're going to drop in a command and this command can read in from our memory from AI slash diagrams and then this is going to read through, this is called a glob pattern, read through all of the markdown files, essentially force them into clod once I do this.

7:43John Lindquist:So this is reading all the files, all the markdown files, and this is cat will kind of concatenate them all together into a single text feed. Yeah, one thing I want to call out for folks that are watching this that or listening and maybe not watching is two things. It seems like, you know, in your in your standard repos, you're creating a memory directory where you're going to structure some of the context and files you might want any of these AI tools to use. And I think everybody's like, oh yeah, I've created my agent's markdown file or my clod one. I think you can actually structure your context for these tools a lot more purposefully.

8:23And so I think this is a really good example of this. The other thing that I think a lot of people are quite lazy about is they haven't explored the surface area of all the system commands available in Cloud Code. And so by using that help command, you can actually see things that not just chatting with Cloud Code you can do, but you can actually inject into how Cloud operates. And appending system prompt is one of those ones that I think people probably underuse.

8:51John Lindquist:Yeah, absolutely. It's one I use constantly. Great points there. So when I let this run, you'll notice that there's, it's now prompting the user to do something. And we don't have to try and reference all the files, which you'd normally do with at. We don't have to try and tell it, you know, what we're going to work on. I could even just say, like, I use dictation all the time. Please explain the authentication flow. And because it already has it in the context, it's not going to have to do a bunch of file reads and code base exploration to figure this out. It's going to come up with results much quicker.

9:35John Lindquist:This does come at the cost of a lot more context and a lot more tokens being used up front, but the work that you do, the time that you spend on these tasks is more valuable than that to me. So you'll notice that there were no file reads in this. There were no, it did not search the code base. It didn't do any of that stuff. It just simply had all that in context. And now I can take this and look through it, start creating plans, a swap or to plan mode to how we want to update and change authentication. So this saves, again, the trade-off here is the cost of many tokens up front, but the The value is you get a lot faster and a lot more valuable output as the tasks complete much faster.

10:26John Lindquist:The tasks are much more reliable because it understands what's going on in the code. Two things I think people should think about with this flow. One is I've said this in a couple episodes and we'll call it out again in yours is I think that with LLM starting to become more of a part of how we do work and feed context and understand things like documentation or business context. This is the era of the file type. And I think so many people think about Markdown and JSON files as effective ways to inject context into LLMs. I see a lot of course Markdown files. I think more people now write Markdown than they have in many, many years.

11:09And then a lot of we've had some episodes on using JSON, for example, to put realistic or semi-realistic data into prototypes. But we're having more and more episodes where people are discovering specific file types that have a specific context structure that are really useful for a use case. In this one, you have mermaid diagrams, which again are hard to parse as a human. And even if they turn into graphics are still hard to parse as a human. Like I looked at that big diagram and my eyes crossed and I said, I don't want to read this. But to a machine, it's very effective. We've also in some episodes talked about image and multimedia file formats that not only contain image data, but contain metadata that you can use.

11:56And so I think this is an interesting moment where we can all use different file types in a more extensive way than our kind of human brains could, because the machines are so good at using the different components, structures or syntax of those files. So I think that's pretty interesting. And I I think mermaid diagrams are one of those examples of something that could be used really well.

12:16John Lindquist:Yeah, absolutely. There's a lot of research being done into how they can compress all of this information down into like a single image. So if I could take all the diagram files and somehow come up with an image format that would store everything in there, would the tradeoff on tokens be there and would the tradeoff on understanding be there as well?

12:37John Lindquist:We'll see if there's more file types that emerge. Huge. And I'm huge on video and using videos. Gemini being the best model for uploading video and understanding. And recently built a tool that can take one of my six hour workshops and process the entire thing and take out notes and examples and thoughts and frequently ask questions. So each time I teach a workshop, I can iterate on it. And I don't have to go like search through the video some other way. It's... You and I will have to trade notes because I did a very similar thing with our episodes, which is it takes a video of our episode. It pulls out all the learnings, all the code snippets, screenshots where the guest and I look cute and put it into a blog post.

13:22So I agree on that. You know, the second question I had for you, though, is going back to these diagram files in this memory directory. Where in your development process do you find that you generate those files? So for me, I actually have a GitHub action that generates files almost exactly like you have with documentation and diagrams for new features of a specific scope. And so I do it when a pull request is closed and then I go back and update our diagrams. I'm curious where this falls in your where documentation like this falls into your workflow.

13:59John Lindquist:Yeah, usually I think pull request is a good paradigm there. But as soon as you have something working where you want it to be working, and then you can say, okay, now this is working as expected, please diagram it. I think for a lot of the projects, we already have pre-existing code bases that don't have diagrams. And so that's, that's been the major use case is taking existing stuff and diagramming all of that so that our AI development is accelerated, I guess is the buzzword. um but yeah if you're starting from scratch you definitely just want to spike spike things out get it working um don't worry about diagrams up front um just use a plan mode build something and once it's working then diagram it out and then even with the diagrams um they're great to help walk you through like what did i just build like i didn't look at any of this code uh show me diagrams of what the code is doing and then if the diagrams look kind of wonky you can just say there's there's tools in there that people are working on where you can like drag around pieces of the diagram to say well i don't want this to navigate there i don't want this you do that there's going to be so many tools in the next few years that emerge from all this yeah and then i will give folks just a couple other use cases of generating mermaid diagrams from code that are not just about improving the efficiency of using something like cloud code um i use a lot of diagram generating out of our repo to answer very complex security and data flow requirements from our customers.

15:30This is a it's a workflow that is actually like pretty expensive if you ask an engineer to do it which is I have specific customer A they need a very specific data flow diagram of this part of our application so they can understand the third party parts of it again also if you're going through SOC 2 compliance or any compliance like these are these are assets that historically have just been so tedious to create efficiently and effectively. And now you can kind of generate them on demand. My last question for you on this diagram flow is, do you find that you have the AI right or you would write documentation any differently than you would for a human audience?

16:11Or do you feel like there's enough overlap that the content format, et cetera, can be pretty consistent between the two?

16:17John Lindquist:I would say could be pretty consistent. I think they serve as an nice bridge between kind of human and AI. Um, definitely think, I know people generate documents, like you'll write code and then generate documentation around it using AI for both steps, which is just wild. But, um, yeah, I think the markdown is kind of the language of the future for a lot of this, um, text and then you can do images and everything inside of markdown files as well. So they can kind of, um, and the front matter of metadata. you'll you see Claude using that extensively for their skills and commands yep and everything so um and Anthropic is pretty good at pioneering all this stuff so if they're using Markdown then everybody else can yeah yeah uh again for people who want to like pull the thread a little further uh what what I do is we generate a lot of AI code then on pull requests we generate AI documentation internally for engineers and for AI, obviously, to use this context.

17:20And then we take that code and we generate markdown customer-facing support documents, again, that really benefit from these workflows. Because then you say, click button A, move to section B, save this. And so you can really pull the thread on documentation from one asset. And I think you're showing a place where it's really useful from the engineering perspective, but it can start to become customer-facing and all sorts of interesting things. Yeah.

17:45John Lindquist:And you could summarize the documents for customers. You could have it build little interactive demos. I mean, there's the sky's the limit. Like however much you want to support the customers there is, if this is enough, then great. If it's not, then it's an AI prompt away from something pretty, I guess. This episode is brought to you by Tynes, the intelligent workflow platform powering the world's most important work. Business moves faster than the systems meant to support it. Teams are stuck with repetitive tasks, scattered tools, and hard-to-reach data. AI has huge promise but struggles when everything underneath is fragmented.

18:24Times fixes that. It unifies your tools, data, and processes in one secure, flexible platform, blending egetic AI, automation, and human-led intervention. Teams get their time back, workflows run smarter, and AI actually delivers real value. Customers now automate over 1.5 billion actions every week. Tynes is trusted by companies like Canva, Coinbase, Databricks, GitLab, Mars, and Reddit. Try Tynes at tynes.com slash howiai. Great. So you showed us how to just pull all of these documents into a system prompt. You get much more performant use of something like Claude code. And this seems like a command that you're using over and over again.

19:16And that's something you and I talked about before we started recording, which is how to alias and make more efficient your use of different commands. So should we pop over to that or anything else you want to show on diagrams?

19:28John Lindquist:That's great. Let's do that. So there are a lot of, on Mac, it's ZSH is the default shell on Windows with your PowerShell. So this looks very different. But depending on what tools you use the most, you can easily set up aliases for things like setting the default model for Claude or setting like if you want to do something completely dangerously so that once you open a new terminal, if you just type X, now anything I type has bypass permissions enabled or if I type h this will be haiku it'll be much faster but not quite as smart or if I type in this scenario cdi this will do that diagram loading where once you have these systems in place these commands in place then you can just kind of capture them in the these smallest, like, because I use these a lot, I keep them in very short shortcuts.

20:31Yeah, and I can imagine you could do something like this for project-specific context. So you could do like CC dash, whatever project you're working on, you could pull in the diagrams for just that initiative. So if you're going back over and over again into specific things that any specific context, this would be just a cheap shortcut to get you into the mode of, for example, cloud code that you want.

20:55John Lindquist:Yeah, absolutely. You showed a lot of cloud examples here. Are there any other ones that you think are really, really useful for folks or creative uses of this you think we should think about? So I tend to build any idea I come up with. So for example, this is one I'm working on called Sketch and this feeds into the Gemini, Gemini CLI. So like what type of website do I want to build? Let's do a store for selling Christmas decorations and then let's make the home page of that. Let's make it creative and artistic for a desktop website. we'll do the GitHub light theme for it. No reference image. Let's do five images and go ahead and generate it.

21:47John Lindquist:And this is the sort of thing where kind of beyond the simple alias, if you've never dived into creating what's called a CLI, you can tell an AI, like, listen, I want to use, Like this is a wrapper around Gemini where it will execute Gemini with specific prompts. So you have to remember that you have these tools on your desktop, which can do incredible things, but you can also script them. And this is a scripted way of generating images based on all of these topics with these concepts with preloaded prompts. And I can say, if I want to add another feature, like you can just go in there and say, please tweak the prompts or please add this feature, please do this.

22:34John Lindquist:And then instead of, um, constantly thinking of, oh, what was that prompt again? Or was that idea I had, you can have these little CLIs and these little projects that are just for you. Um, because you just like build the tools that you need now. and this is just spitting out these um my my mom lives with me and she's setting up christmas decorations upstairs this is why i'm thinking about this so this is yeah this is gemini generating based on the promptly fed in based on the color scheme this is github light christmas store color theme um and i told it to generate five variations of it and then we could take one of these images and drop it into one of the um drop it into one of the ais and say let's start building out this website let's break this into sections and go from there and this is kind of like my ideation inspiration sort of thing that I use one reason I want to make sure people are paying attention to this use case which is essentially you've exposed a command line interface to do a couple you know script a couple workflows around calling um nano banana and some of the Gemini models to do some things.

23:49And there are two benefits, I think, to this that are really important. One is building command line tools has been so opaque and just kind of not fun for so many people for so long. I've built lots of them. And how easy it is to build a really nice command line tool is such a treat for anybody who's ever had to build them and make them look good. Everybody has these cool ASCII only logos in their command line tools, which have been very tedious to make before. So I think one thing is these tools are just a lot easier to build. Two, from a product builder perspective, the reason why I like this move to these command line tools is the constrained UI space of the terminal.

24:34Actually make sure you don't get distracted in building UI around something as simple as this, right? You just had like five questions you had to answer, a couple multi-select. You could tab through those with your keyboard. If you were creating like a little WYSIWYG walkthrough web editor thing here, I mean, one, I would have gotten really distracted about how it looks. Two, you'd have to type into, you know, you'd have to run localhost and type into your web browser. And so I actually like the constrained UI space for speed of prototyping on some of these ideas, because you just don't get distracted by anything but the essential kind of toolkit.

25:15And then you can get a really cool thing out the other end.

25:18John Lindquist:My only problem is I've built more tools than I can remember. And sometimes I have to think, where was that thing? Yeah. I also like how you started this little segment, which is you said you just build every idea you have. I think that is totally the move. While you have an idea kick off something get it built build yourself a little throwaway repo um you know eventually the ai can crawl it and remind you everything that you built before but this is pretty cool and that's that's why i love dictation because all you have to do is start up a new terminal in a new folder and just kind of brain dump in there and then it'll try something and once you have something even if it's wrong you can iterate on it yeah you have nothing you can't iterate on nothing and i think that's the magic of even for people who hate ai tools like a sheet of paper full of things that are wrong is much better than a blank than nothing because even if it's wrong you you recognize it's wrong and it helps you think of what's right and what you want to build.

26:28Yeah, I say this a lot. It's easier to edit than author. So let's get the authoring out of the way. And then even if you completely revise the whole thing, it's a much easier starting starting point to work with something. Okay, so I think we're going to close out and spend a little bit of time on your workflow for when you're doing more complex coding projects or features, how you keep those really high quality using some advanced techniques in um i think in cloud code

Read the full transcript

26:57John Lindquist:and cursor so when we're gonna excuse me when working on a project um often when the ai is generating code it'll often build out mistakes and so even it will say it's done you're like wait a second there were a ton of mistakes there why did you stop just fix it until the mistakes are done. So for example, let's say it wrote out this code and there was this error in here. And this error is something that you usually catch with tools such as TypeScript, or maybe it's formatting or linting or any sort of complexity tools. That there are code quality tools that you run before you think the work is done.

27:42John Lindquist:So you would run something like bon type check and you would see that it has this error but your Claude code and the other agents don't know that this error exists. What Claude has and what Cursor and a few others have is the concept of hooks and what this can do is so inside of of claw, let's go here. You can set up what are called hooks and I'm going to set what's called a stop hook and hit add new hook. And just, it shows you a bunch of examples. I'm accepting responsibility for all of this, a bunch of warnings, because it can run scripts that aren't checked by the AI. and I'm going to say the command for now is just going to be echo which does nothing and I'm going to add it to my project local settings and now we have this echo hook and this is defined in this settings local dot json file and this is for this is a local file for me if you want it to with your team would be settings.json settings.local.json.

29:01What we're going to do is instead of running this command, we're going to run a custom

29:10John Lindquist:clodhook, which I've defined inside of clodhooks. And I called it index.ts. You could call it stop or whatever. So from this script, which is in this directory, I need to run this install for this package because I don't have it installed right now. So I'm going to bun install Anthropic. And this is their Claude Agent SDK. Now in the SDK, they have what are called hook inputs and other types you can use. So that when you're dealing with hooks, you have a lot more information. So like on this input, you have all of this information around what the input name is. And then what the session ID is and the current working directory permission mode and all that.

29:55John Lindquist:and you can use that to customize your hook. But what we are going to focus on is we're going to see step one, were there files changed when we stopped? And a stop is once Claude has kind of finished its conversation and it's now waiting for you to do something. So we're going to check, are there files changed? And we're going to, if there's files changed, we're going to say, okay, then let's go ahead and run that bun type check. And if there is a type check, then we can say back to Claude, we can say, hey, there were TypeScript errors. This is the report and then send them back the output that we showed in the terminal before.

30:39John Lindquist:And it'll continue. Otherwise, if there were files changed, then we can tell Claude to please, there's a prompt way down here, it says please commit essentially uh the files don't commit anything anything sensitive and go ahead and commit it so we set up this workflow of once a conversation is finished check to see if any files have changed if they have you check to see if there's any type script errors which could be a type check or build errors or any sort of other code quality guards you have in place and if there are none then go ahead and commit and this saves you a lot of the overhead in your mind of here's all this extra stuff I have to do when something's done.

31:22Yeah. And what I want to call out for folks that are maybe listening and not seeing this code here is it's really what's nice about this is it's a combination of commands that you would run in the terminal to just generate errors and see them yourselves. But then you can feed those back into cloud code in a more natural language way and give natural language instructions on what to fix or again default to some command that's different which is this github commit command and so i like this combination of kind of like structured commands in in the terminal combined with natural language calls back into clod to then kind of put the bow on the end of any work that this ai system does is that kind of how you think about it

32:10John Lindquist:Yeah, exactly. The gotchas you have to think about here are when you're communicating from a hook back to clod, you're essentially using console log, which is one of the first things any JavaScript developer learns, and you're sending back a JSON object. So it's going to find that first console log, whatever it gets back, that's what it's going to see as its input, its standard input. So you have to be careful if you're running commands like this, you tell this one, please be quiet, because if it's not quiet, then it would log back to the console and maybe interfere with something. Or if you want other logs or you're debugging the script, just use console error or any other way of showing logs.

33:00John Lindquist:Otherwise, console log turns into this feeding instructions back to the agent. So it's one of those gotchas that everyone falls into when building this out. And just to demo it real quick, I'll just turn on Claude. And I'll say, well, actually, for this to work correctly, let's make sure we have everything staged and set up so that when it does the git check, let's just generate a message. So yeah, let's please create a foo.ts file on the root of the project. And we'll go ahead and accept this. And you'll see that it says stop hook returned a blocking error. And that error return is please fix the TypeScript errors.

33:51And here's our prompt right here with this block.

33:54John Lindquist:And it says I'll fix the TypeScript error. So this is when it would have stopped. It would have stopped right here, but we hit the stop hook. Now it sees these errors. So it's going to go ahead and read that. It says, oh, I found the mismatch quote. I fixed it. And now behind the scenes, there's a clod running, which should it commit that fix. You make this a bit smaller, show our graph here. And you'll see, this is the fix that it made was correct the quote syntax. This is what the little haiku did in the background. So the stop hook ran twice. It ran once where it found the error and had files changed.

34:35John Lindquist:And then the second time there were no more errors. And so it ran the commit. And so that saved us all of that work of both passes. And now we have a completed task that has been error checked, fixed, and then commit. And conditionally inscripted in a way where this will be different for every single project based on your requirements, based on your code base. So this is definitely something that you have to like think through and set up yourself. It definitely saves so much time where you don't have to go back in and say, well, please fix this or please run this command or please do this. When you know part of your workflow is always like if these things should always run, you might as well run them automatically.

35:16And something I have to say is I get so much pushback from software engineers saying these tools don't really make me faster. The quality isn't as good. And I think if you make the investment as you've shown us in, okay, well, what things would it do to make the quality better? Or what things would it do that you can automate that would make you a little bit faster? And you put that effort in to understanding all the things that these tools can do for you, either programmatically or through prompting. I think you can actually see a lot of those efficiencies. And then I want to call out something that you said, which is you have this local settings, but you can create settings that are shared across your team for anybody that's working in the repo.

36:02And that's for our engineering leaders out there or larger engineering teams to really think about if you haven't created these hooks for key repos or key projects where everybody is benefiting from this when they're using something like Claude Code, then you're missing out on some of the scaled leverage, I think, of these tools. And so I'd love to put somebody in charge in an engineering organization of figuring how stuff like this can work inside your code base and then scaling it out either through training or through configuration into all the other engineers so that everybody's getting this baseline quality and this baseline efficiency.

36:39Amazing. Well, okay. Other than, you know, type TypeScript errors, just prattle off a couple other use cases. You deleted a bunch of stuff from this hook. So what are the things you think that people should bake into a stop hook like this for CloudCode?

36:55John Lindquist:Definitely formatting. There's kind of the mindset we've always had before of like pre-commit hooks or pre-push hooks, things that operate on the CI. And these are a lot of things that can be fixed before those are even run. So whether it's, there's a lot of tools around with linting it could constrain the length of files there's things like circular dependencies where I could check the imports to make sure that files don't reference each other there's code complexity there's tools that say does this code look like any other code in the code base where this could be extracted into a function or something because it was like duplicate code throughout the code base and there's all sorts of analytics and tools you could run.

37:43John Lindquist:Um, uh, some of them probably not as often as others because it's more expensive and you just have to make those, um, decisions based on, you know, the size of your team, the size of your application. But there's just, just put into an AI prompt of chat GPT or any of them to say, what are I'll make a long list of developer tools people run on pre-push or on pre-commit, and you'll see a huge list of them that you could pick and choose from. Well, and I'm going to take a tiny detour for our very patient, non-technical audience members that have maybe listened to this, which is these post-tool call hooks or post-stop hooks in Claude can also be used when you're working on non-code.

38:31So we have so many people using Claude code to write documents, to do all sorts of things. And so you could just think about, what do I want automated after this tool is called? Or what do I want automated after Claude finishes writing my document? And you could think about ways to use something like this, not even for code quality review, just for a post kind of task completion check. So I think just the general framework is really useful. It's obviously highly applicable to software development, but I think people can think of other creative use cases for this as well.

39:05John Lindquist:Yeah, absolutely. The diagramming stuff, create an image of what we just did and send it to my mom to show her I'm working hard. Like anything you want, right? The sky's the limit. Okay, so just to wrap up, these have been super useful use cases. I want to call them out. One is using documentation and diagramming, specifically mermaid diagrams, to preload as a system prompt in your Cloud Code instance so that you don't have to waste the time of doing context discovery. And you can really make sure that that context is preloaded. It's a little more expensive on the token side, but a lot faster.

39:47And these diagrams are much more easily read by machines than by humans. so it's a good format to get things in. We looked at aliasing some of your favorite Claude code instances and settings so that you can pop into your Live Dangerously mode. You can pop into your You Have All My Diagrams mode. You can just pop into those with one or two letters, which I like. We got a little side preview that we didn't call out, but just how casually you use voice and transcription to enter in and out of these tools. What I like about the way you use AI is you were just like highly efficient. You're like the minimum number of things I could type, the better.

40:30And you're pretty fluent in switching between voice and typing. So we saw we saw a little that. You encouraged us to create in particular little command line tools to build one off ideas or tools. Yours was a website design generator using Nano Banana. And then you showed us how to use clawed hooks and in particular a stop hook to do some quality and other checks on code written by these AI tools and automate some of the processes that you might do as a software engineer that you want our little AI software engineers to do instead. Just that in, I'm looking, 40 minutes. We did it pretty fast.

41:13John Lindquist:Nice. This is great. Okay, well, I'm going to ask you a couple lightning around questions and then we will get you back to your very efficient AI coding. My first question, again, you're like me. We love Cursor. We love Cloud. We love VS Code. We have all of them open. You know, I think everybody's, I think there's interface wars happening right now. Are people going to love these terminal UIs and command line tools like Cloud Code? do people want the the ide i i noticed that you're on cursor 2.0 so you have the agents view which is very simple and abstracts away some of the code and you're in the editor view i'm going to give you two two wars i want your quick opinion right now we won't hold you to it of what you think wins for i would say real software engineers you know writing real code out there um the friends that I talk to, you know, terminal UI, IDE or both.

42:11And then do you have any hypotheses on, I think particular in the VS fork world, VS code fork world, are there any moats or, you know, what do you think, how do you think people can compete in the IDE world? Yeah.

42:27John Lindquist:So I think you need both. I think you need an IDE and there are so many use cases for the CLIs. The reason being that the CLIs have a lot of configuration and a lot of settings where, as you saw with aliases, I could launch a version of Claude that loaded up a specific set of MCPs or a specific set of prompts and preload a bunch of things and do that in a single terminal command and be very quick and fast with that and then set it off in the background and just have it running. currently inside of inside of a cursor inside of any of these idees there's usually a lot of okay open the ui navigate to this and then navigate that then switch over to this then switch over to that and they try and streamline as much as possible with slash commands and whatnot but it's just not quite the same but if you have an ide and you're reading through the files and you're selecting lines and you want to modify certain bits like focused work.

43:32John Lindquist:There's so many use cases for IDEs where there's a recent cloud tool where it has a IDE integration where it can check the diagnostics from the IDE. And you'll see that with VS Code as well, like the extensions you put into an IDE can be fed back into the agent. So there's a whole robust extensions ecosystem from IDEs because people build on top of these things their own workflows. And I don't think we've quite reached, like we build our own CLIs from AI. I don't see a lot of people building their own cursor extensions or ES code extensions, which is very possible. And you could feed those errors and warnings and company rules and everything in very complex ways back into the agents.

44:20John Lindquist:So that will happen as well. And I think for one IDE to stand out above the other, they have to separate themselves like Cursor is doing with their agent mode. They have to make something unique and user-friendly that once, like people are not going to give you a bunch of time to convince them. You're going to have to open the agent and you're going to have to like see that click on browser mode and it's going to have to launch your dev server and you're going to have to click on the element and say, I want this to look with more pink or purple or whatever. And then they want that to just work.

45:01John Lindquist:We'll see any sort of friction or frustration from any AI tool anybody puts out there is just instant dismissal from so many people. Like there's just the bar for quality is so high in the AI landscape because everyone can build anything that you have to focus on the UX and you have to make that experience better than everyone else. And that's where you can see Cursor making the bold moves of like, okay, let's go full on agents. Like you have to make those leaps. Yeah, I agree. And, you know, just talking about this skepticism and high bar, what I love about this episode that we recorded today is it's really most relevant for software engineers with more experience who are shipping high quality code and who want to write production level code more efficiently using some of these tools.

45:56This is not, you know, I hope you all hung out and listened to it, but it's not for our vibe coders and our non-technical folks. And so what would you tell kind of senior principal software engineers, engineering leaders? I get asked this a lot about how do I sell the value proposition of these tools into very skeptical organizations? and what are, as a more advanced software engineer, the things that have just changed your life in the last year, which say you should never go back to doing it this way. Kind of how do you make that pitch?

46:31John Lindquist:The first thing that jumps to mind is any time an issue is opened, like you can set up streamlined workflows that someone opens an issue and you can have Claude automatically tackle it. You can set up triggers for linear GitHub, whatever, that once something happens, you can get that first pass to see, okay, can we at least find this without doing any work? Can we at least get that initial review in there of what's going on? So that once we jump into the task, I mean, for my entire career, someone throws an issue at you, you spend the first you know probably day or two orienting yourself to like okay i didn't write this code this is legacy from let's you get blame let's do all this stuff like all of that busy drudgery that you're going through to even get started on the issue um it can wipe out so much of that it can find who touched the files who did this like if if you have a diagram set up what are the risks the impacts are there potential security things are there like it it's so great at surfacing the you don't know you don't know sort of scenarios where you hire so many contractors you hire so many people who are new to these things and then you throw them into these tasks and they just don't know like they haven't spent time with the code base and then you ask them to fix these things they just have zero idea what sort of impact their change is going to have the AIs can surface a lot of that and they can just be like okay we need to be super careful This is, you know, in production and, um, this is cost going to cost us money if this goes wrong.

48:17John Lindquist:Just tell me everything I need to look at, like find every single debug path, find every single, um, uh, every, why has this file changed over the course of history? Like write a summary of everybody who's touched this file so I can know why this function is the way it is. Like there's just so much work that is just not writing code. Um, and all the exploration work is just so much easier to just say, like everything I just said over the past 30 seconds is a prompt, which I could have just dictated. Right. Um, and you just have to walk up to your computer and say, I have this issue, like guide me through all this stuff.

48:57John Lindquist:And, um, it's just, it blows my mind that people be hesitant for those sorts of tools i understand if they're like okay maybe some of the code isn't perfect we still have to do code reviews we still have to like check for quality we still have to run our tools to validate things but if you're not using it to do to like inspect and investigate and write orientation and all that stuff then like you're really missing out like in the enterprise space yeah and on the other end if you're not using it to document so the next time somebody has to do that investigation you have a little bit of an easier time um you're also missing out so i do think on that that front of the back end and what i often tell people is a good way to think about how to design your AI workflows is do not think in a task level orientation, like I'm going to write code.

49:53I say, think about if I gave you infinite junior to mid-career talent who is always available, who would do the work you would do if you had unlimited amount of time and no meetings, what would you do when a ticket came in? Like, what would you do? And you'd say, well, I'd go trace who wrote the code. I would go figure out the history. I would make myself a really good tech spec. I would call out the risks. I would publish this in a way that my team could review it. I would have a senior engineer look at it and give me some really hard feedback. All of that could just become a prompt. And then, you know, but so many people are just constrained by their time and cognitive capacity.

50:36And so they just go, well, I'm going to read the issue and bounce around in the code a little bit. And I guess I'm going to start coding. And so you can kind of get to this model of optimal, not perfect, but like optimal workflow, and then figure out how you can prompt or build workflows or hooks that would replicate that at least in an 80 % way, which is a lot better than not doing it.

51:03John Lindquist:And something as simple as the commit messages are so much better than they used to be because developers don't have to write them. so much better for for people who are new to programming um commit messages used to be like second attempt or like please work or swear words like my my favorite one is just like 17 f's like or like trying this trying that trying this other thing yeah not please work plz yes yeah you know if anybody wants to vibe code a product i always thought that startups would want a printed book of all their first years commit messages with like calling out the really funny ones oh if somebody wants to vibe code a little uh github api powered print uh business i'm sure you could get a couple startups to print those out okay last question yeah this is probably challenging for you because you do a lot of dictation so you're probably actually pretty polite to ai given you would have to say frustrating things to it if you wanted to be mean but when our little friend Claude is going off the rails or you're really not getting what you want?

52:14What is your prompting, reset, start over technique? Have you found any tricks that work particularly well? Yeah, it's really the take the conversation, export it.

52:29John Lindquist:A lot of them have the export commands. Drop the conversation with some of the code files into the um into chat gpt pro 5 or whatever it's called or a gemini uh deep think i believe is the and have a have them do a second set of eyes on it and then kind of start over rather than like if things go off the rails and you can't fix it in about maybe one prompt or like where you see what's going wrong and just revert to the previous commit and kind of start over because there there's always this underlying ai is trying to go somewhere and you want it to go over here and you keep on telling it to to join on your path but it still wants to like get somewhere else that you don't quite understand and so starting over from ground zero and like revising your original prompt is better than like trying to steer it to where you are when you've like drifted so far away um and that has to do it's so different with every model it's so different with every prompt and all the context and project that it's like i can't give you like the here's instructions that work every time but like starting overworks every time tossing a second set of eyes on the entire conversation where that AI isn't invested in that conversation.

53:57John Lindquist:It's instead critiquing the conversation. Those are my two. I think that second workflow is so funny because I think as somebody who's been a manager and a leader so many times, sometimes I feel like I'm the reasoning model being brought in to mediate the misunderstanding between too smart but misaligned resources. And so it's really funny to hear the idea, okay, like I'm having a debate with my AI. Let's bring in like the third party. Let's mediate this conversation, have an objective set of eyes to see where we maybe are misunderstanding each other or going wrong, and then reset and start over.

54:39So again, I think, this is the moment for folks with a lot of organizational and social skill thinking to apply this to how you might design some of these flows for AI, even though there are beep-boop machines that we're really using.

54:55John Lindquist:Yeah, and I would say, kind of last thought on that, is the recent planning modes that have been released with Cloud Code and Cursor and all of them have eliminated a vast majority of that drift. So they've been fantastic releases, which I strongly recommend for anything beyond like a small file change planning is awesome. Yeah, I love those features too. Okay, well, John, this has been great. Where can we find you and how can we be helpful? Yeah, I'm on egghead.io. I have tons of courses on AI tooling. I teach workshops through egghead.io. I send a newsletter out every week called AI Dev Essentials.

55:34You can find me on X and other platforms as well under my name. And that's it.

55:41John Lindquist:I love to talk with anyone about all this stuff. My workshops are fun and we talk, go way deeper into this super advanced stuff. So, yeah. Great. And then maybe some of us can shop your possibly to be created Christmas and holiday decorations night. So you let us know. You let us know if that goes live. We'll drop into the show notes. Thank you so much for joining us and sharing your workflows. Thanks, Claire. Thanks so much for watching. If you enjoyed the show, please like and subscribe here on YouTube, or even better, leave us a comment with your thoughts. You can also find this podcast on Apple Podcasts, Spotify, or your favorite podcast app.

56:23Please consider leaving us a rating and review, which will help others find the show. You can see all our episodes and learn more about the show at howiaipod.com. See you next time.

From the publisher

John Lindquist is the co-founder of egghead.io and an expert in leveraging AI tools for professional software development. In this episode, John shares advanced techniques for using AI coding tools like Claude Code and Cursor that go far beyond basic prompting. He demonstrates how senior engineers can use mermaid diagrams for context loading, create custom hooks for automated code quality checks, and build efficient command-line tools that streamline AI workflows.


What you’ll learn:

  1. How to use mermaid diagrams to preload context into Claude Code for faster, more accurate coding assistance
  2. Creating custom hooks in Claude Code to automatically check for TypeScript errors and commit working code
  3. Building efficient command-line aliases and tools to streamline your AI workflows
  4. Techniques for using AI to generate documentation that works for both humans and machines
  5. How to leverage AI for code investigation and orientation when tackling unfamiliar codebases
  6. Strategies for resetting AI conversations when they go off track

—

Brought to you by:

WorkOS—Make your app enterprise-ready today

Tines—Start building intelligent workflows today

—

In this episode, we cover:

(00:00) Introduction to John Lindquist

(03:15) Using context and diagrams to provide context to AI tools

(05:38) Demo: Mermaid diagrams

(06:48) Preloading context with system prompts in Claude Code

(10:30) The rise of specialized file formats for AI consumption

(13:23) Mermaid diagram use cases

(19:01) Demo: Creating aliases for common AI commands

(21:05) Building custom command-line tools for AI workflows

(26:39) Demo: Setting up stop hooks for automated code quality checks

(35:16) Investing in quality outputs

(36:40) Additional use cases for hooks beyond code quality

(39:19) Quick review

(41:14) Terminal UI vs. IDE

(45:35) Selling AI to skeptical teams

(51:57) Prompting reset tricks

—

Tools referenced:

• Claude Code: https://claude.ai/

• Cursor: https://cursor.sh/

• Gemini: https://gemini.google.com/

—

Other references:

• Zsh: https://www.zsh.org/

• GitHub: https://github.com/

• TypeScript: https://www.typescriptlang.org/

• Bun: https://bun.sh/

• Claude hooks: https://code.claude.com/docs/en/hooks

—

Where to find John Lindquist:

Website: https://egghead.io

Newsletter: https://egghead.io/newsletters/ai-dev-essentials

LinkedIn: linkedin.com/in/john-lindquist-84230766

X: https://x.com/johnlindquist

—

Where to find Claire Vo:

ChatPRD: https://www.chatprd.ai/

Website: https://clairevo.com/

LinkedIn: https://www.linkedin.com/in/clairevo/

X: https://x.com/clairevo

—

Production and marketing by https://penname.co/. For inquiries about sponsoring the podcast, email jordan@penname.co.

More from How I AI

All 103 episodes
Advanced Claude Code techniques: context loading, mermaid diagrams, stop hooks, and moreHow I AI · 57 min
Listen in VO