Enhancing AI Agents in Cursor with Memory Bank
Today I'm going to tell you about a feature that's not actually built into Cursor; it was released by Klein and it's called Memory Bank. Let me explain what it does.
The Problem: Losing Context
First, let's look at the problem. During long sessions, AI agents, like the ones in Cursor or Windup, tend to forget past conversations or lose context. This means you either have to repeat yourself, or the agent has to search through your files to regain context.
The Solution: Memory Bank
That's where Client's Memory Bank comes in. It stores structured files to help the AI retain context across multiple sessions, so you don't have to keep explaining things. The context window doesn't get filled up, which reduces or even eliminates hallucinations.
Now, let's talk about these files.
- Project Brief: This outlines the main goals of the project.
- Product Context: This explains the problem you're solving and how the project functions.
- System Patterns: This covers the architecture and design approach.
- Tech Context: This lists the tech stack and dependencies. This is especially useful because it prevents mistakes, like when Cursor once wrote React Router code in a Next.js project, completely breaking it.
- Product Context: This also tracks what you're currently working on.
- Progress: This documents the entire development cycle so the agent can track its tasks.
The best part? This isn't just for Client. These files come with a set of instructions so they can be used with any agentic IDE. Someone has actually implemented this for Cursor as well, and now you can use this feature directly with Cursor. I'll tell you how later in this article, but it's available right now.
Plan and Act Workflows
Another thing is that Client has two configured workflows: it operates in plan mode and act mode. You can now get these in Cursor too, once you paste the necessary setup. Each mode follows its own workflow.
- In plan mode, the agent uses the Memory Bank to decide what to do next.
- Then, in act mode, it checks the Memory Bank, updates its tasks (since there's also a built-in task management system), and then takes action.
- After executing, it updates the documentation based on what happened.
So, in addition to the memory system, Client also has a task management system to keep the agent on track.
How to Initialize the Memory Bank
Now, let me show you how to initialize the Memory Bank for any project you want.
First, you'll see the markdown file. Click on the "RAW" button to get the file in its raw format. Now, copy the entire file. Then, go to Cursor.
Here, under the "Rules" section, paste the file so the agent knows how to act. You can actually create project-specific rules because the Cursor agent allows you to add configurations for different projects. However, setting that up takes some time, so for now, I'm just going to paste it into the global rules. If you want to create project-specific rules later, there are tutorials available, and you can easily do that.
Now that I've pasted the user rules, you can see my project right here. It's called Mac-wall
.
Now, I'm going to ask Cursor in agent mode to initialize the Memory Bank. By reading the rules and understanding the objective, the agent will create the Memory Bank. You can see that it has been initialized. Now it will generate the files one by one. After that, it will read the project and store all the context accordingly.
Oh, it looks like it's asking for project details. It seems like it can't see the Mac-wall
folder for some reason. What actually happened was that since I had copied the project from another folder, I had to reopen Cursor for it to become available. Once reopened, it was able to read everything and automatically fill out all the files. Had I reopened Cursor from the start, it wouldn't have even asked me to provide the project context; it would have just done it on the first try.
What It Generated
Now let me show you what it has generated. It has filled out all the project details. Here's how it has labeled the project according to its analysis:
Mac-wall is a modern web application built with Next.js that provides a beautiful wallpaper browsing experience and integrates with the Unsplash API.
Which is exactly what it does. It has also listed core requirements along with other relevant details.
Under Tech Context, it has documented all the dependencies so the agent understands what's inside the project.
In the Project Progress section, it has recorded what has been completed so far. However, it hasn't listed upcoming tasks or future plans yet, as that will be filled out later. Similarly, since no issues have been identified, that section remains empty for now. This is useful because the Cursor agent doesn't need to manually retain the project context while you're developing. It also doesn't have to re-read your files repeatedly; since all the context is stored in the Memory Bank, it can simply reference it and act accordingly.
Another thing it has done is detect System Patterns, identifying what we're using and how the project is structured. It has also generated a Mermaid diagram, though you might not fully understand it since it's in its raw form. Based on these system patterns, it has also developed Cursor rules. Now, I know this is a deprecated method, but since we've specified in the global rules how it should access the project, it still works. So this is actually a valid way to make it function properly. Additionally, you can modify the rules according to your preferences. If you feel something is missing or needs to be added, you can adjust them as needed.
Implementing a Landing Page
Now, here's what I did. I asked the agent to implement a landing page for the app, so the app would be visible there. However, there isn't any authentication involved. To force it into plan mode, I actually made it so it couldn't edit files. For some reason, this is a bug in the Cursor rules file, so this is the workaround.
In plan mode, the agent mapped out how it was going to add the elements and listed everything. Then, I told it to switch to act mode to implement the changes. From there, it started editing the files, and this is the result.
It asked me to add an image, but I told it to do it on its own. For now, we need to place our product image right there, but for now, I just asked it to place a simple grid. This is the rest of the landing page—a simple, minimal design that looks really nice. When you click on "Get Started," it takes you directly to the app with all the wallpapers, the filter system, and everything else.
So, it's a really cool way to keep your agents organized, minimize hallucinations as much as possible, and incorporate task management into the process. Plus, it's not even that difficult to set up. You should definitely check out the documentation and the rules files, and if you run into any bugs like I did, you can always try editing the rules files yourself.
If you found this useful, I hope you enjoyed this article. Catch you in the next one.
Join the 10xdev Community
Subscribe and get 8+ free PDFs that contain detailed roadmaps with recommended learning periods for each programming language or field, along with links to free resources such as books, YouTube tutorials, and courses with certificates.