
Vibe Coding with AI: Managing Context So AI Doesn't Repeat the Exact Bug You Fixed Yesterday — A 3-Layer Memory with a 'Forgetting' Mechanism
Vũ Khôi
Tác giả tại Wotech Electronics Blog

Vibe Coding with AI: Managing Context So AI Doesn't Repeat the Exact Bug You Fixed Yesterday — A 3-Layer Memory with a 'Forgetting' Mechanism
When you work on a long enough project with AI, most of us hit the same problem: no matter how smart the model is, every time you open a new chat session (or when a conversation gets too long and is compressed), the AI loses the detailed thread of what just happened. Yesterday you spent the whole afternoon fixing an API permission leak, or a bug where reloading the page wiped all user data. But today, when you ask the AI to build one more screen, it can run straight back into the same old problem you fixed yesterday.
Quick answer: Tank Mentor — author of a series on vibe coding in the Sắc Màu Cuộc Sống Xa Quê group — argues the problem isn't that AI is "dumb", but that AI "forgets": each new chat session or each conversation compression loses the detailed thread, and the automatic memory features of IDEs only remember surface habits (which library you like, how your folders are structured) instead of distilling the deep causes of a bug you just fixed into controllable rules. The community uses 3 approaches — a fixed rules file, a Memory Bank folder, an Obsidian notes store + RAG — each with its own limits as projects grow. The author's approach: a self-built local context-management tool ("lob-brain") with a 3-layer memory and a "forgetting" mechanism inspired by how the human brain stores memories — separating background context from per-task rules, a lesson store that reinforces when used often and sinks when unused for a long time (but resurfaces when it touches the right thread), and acceptance steps with real evidence baked into the process instead of mere verbal instructions. The boundary to state clearly: this is one individual's working method and self-built tool, not a public product or an independently validated research result — lob-brain is a tool the author wrote for himself, and the post doesn't say it has been publicly released.
Context management — as the author defines it — is keeping a project's context and the lessons you paid for with your time, selectively, without having to retype every instruction at each new chat turn.
Why does AI "forget"?
The problem has two sides, and both lie beyond any single model's ability:
- A new session = a lost thread: every time you open a new chat session, or when a conversation gets too long and is compressed, the AI loses the detailed thread of what just happened.
- Automatic memory remembers the wrong things: many IDEs and desktop apps (Cursor, Windsurf, the desktop versions of Claude and ChatGPT) have added automatic cross-session memory. It helps remember surface habits — which library you like, how your folders are structured. But it creates another problem: sometimes the AI automatically picks up temporary fragments from an old session (or from another project) and applies them to a new session as noise, while the deep causes of the logic bugs just fixed are never distilled into controllable rules.
The practical consequence is easy to see: yesterday you spent the whole afternoon fixing an API permission leak, or a bug where reloading the page wiped all data — but today, when you ask the AI to build one more screen, it runs back into the same problem you fixed yesterday.
How is the community solving this?
Before his own method, the author surveys 3 common approaches — each with strengths and limits depending on project size:
| Approach | Strengths | Limits as projects grow |
|---|---|---|
| 1. A fixed rules file at the project root (.cursorrules, CLAUDE.md, GEMINI.md) | Most common, easiest to start; the AI reads it automatically at the start of each session | The file balloons to thousands of lines: context dilutes (the AI skims and misses the most important rules in the middle of the file) and wastes tokens (changing a button's colour still loads the payment-reconciliation rules, database structure and deploy process) |
| 2. A documentation folder — Memory Bank (project overview, technical architecture, current progress, work in progress — updated after each session) | Clear structure, easy to read with the naked eye, no dependency on external tools | Depends on the AI's "self-discipline": in the middle of fixing a bug, both you and the AI forget to update; files multiply fast when working on several projects at once, and keeping them in sync is painful |
| 3. A linked notes store like Obsidian + indexing/RAG (a "second brain"; the system finds relevant documents as the chat goes) | Handy early on when you need to look up static information | Notes balloon out of control: after a few months the store grows to hundreds or thousands of tangled files; stale early drafts sit mixed with the latest architecture decisions; keyword search easily grabs outdated documents that are no longer correct; and it only "finds information" — it can't control the AI's execution steps |
There really is no single approach that is absolutely right for every case. If you're just building a small tool over a few days, a rules file of a few dozen lines is more than enough.
The author's approach: a 3-layer memory with a "forgetting" mechanism
As the number of projects he worked on at once grew — from a personal website, to a data-analysis tool, to enterprise management systems — the author realized he needed a mechanism that keeps each chat session's context lean while carrying experience from one project to the next without drowning in a sea of old files. So he built his own local context-management tool (named lob-brain) that connects to his code editor, with 3 layers and a natural filtering algorithm.
Layer 1: Separate "background context" from "per-task rules". Instead of stuffing everything into one giant config file, the default information loaded at the start of each chat session is kept very short — just enough for the AI to grasp the overall picture of the open project. Then, depending on what is being asked in that turn (fix a bug, build a new feature, write business-analysis docs, or configure a server), the system classifies the task and loads only that task's own rules and procedures into the session. UI work loads only UI rules; database work loads only data-check rules. Thanks to this on-demand loading, each session's context window stays light, wastes no tokens, and the AI focuses entirely on the work at hand.
Layer 2: A lesson store with a "forget – remember" mechanism. This is the part the author is most proud of, and the one that keeps the system from ballooning out of control like ordinary file storage. Every time he finishes a real incident that cost a lot of time — like the cases from his previous post (a UI data-loading bug that sent an empty list up and wiped all configuration, or a permission-convention change that locked all old accounts) — he spends about one extra minute having the AI distill the incident into a short record in the shared store, in 3 points: Symptom → Root cause → Verified fix.
But saving forever across hundreds of bug fixes would overload the store too. To solve this, he added a "forgetting" (decay) algorithm to lob-brain, inspired by how the human brain stores memories:
- Reinforced when used often: lessons and foundation rules frequently called upon in daily work get their scores reinforced so they always sit in the priority layer.
- Sink when unused for a long time: memories or notes specific to a situation that haven't been touched for a long time gradually lose weight and automatically "sink" to a deep layer, no longer jumping out to pollute the context of ordinary chat sessions.
- Resurface when they touch the right thread: they are not deleted entirely. When you start a new task and it touches the context or specific keywords of that problem (for example, half a year later you work on a payment-reconciliation flow via webhook again), the sunken memory automatically "floats" back up to warn the AI about the blind spots that once caused bugs.
Thanks to this sink-when-unused and resurface-when-called mechanism, even though he has gathered lessons from many projects into one place for over a year, the working memory of each session stays light and close to current reality.
Layer 3: Bake acceptance steps into the process instead of just asking in words. AI has a strong tendency to conclude early to finish the chat turn. If you only write one line in the rules file — "remember to check the database carefully before reporting done" — very often the AI reads it, ignores it, and just looks at the HTTP 200 OK on the interface and reports completion. To fix this, for important flows like system bug fixes or large feature rollouts, the author splits the process into sequential check steps. To move from the code-writing step to the "done" conclusion, the AI is forced to run a verification step and extract real evidence (for example, a direct database query, or test results through a real API endpoint) as confirmation.
This is the same principle share 137 calls "don't loop on confidence, loop on evidence" and share 144 calls "AI is not allowed to declare itself right" (every proof must pass Lean 4 and an independent blind audit) — only here it is applied to everyday software bug-fixing, not mathematical research.
The downsides and trade-offs
To keep the view objective, the author states clearly that his approach also has drawbacks:
- It costs effort to build the habit at first. The tool doesn't get smart on its own if you don't feed it data. At the start you must spend effort defining the process flows and training yourself: every time you finish a hard bug, pause for a beat and ask the AI to summarize the lesson into the store before moving on.
- Overkill for small tasks. At one stage he set the process too strict, so that changing one word on screen or a button's colour forced the AI to run through context loading, task classification and step-by-step checks — killing the flexibility that makes vibe coding fun. He later loosened it: small and surface changes run straight through; control gates are kept only for flows touching data structure and core business logic.
- Still needs periodic merging and cleaning. Despite the mechanism that sinks rarely used memories, a high-intensity week can produce many notes saying the same thing. Periodically he still has to run a review pass to merge similar lessons into one cleaner standard rule.
How to start if you don't want to build your own tool?
You don't necessarily have to spend time coding your own tool right away. You can apply the same spirit to the files already in your project:
- Trim the root rules file. Keep the default config file (.cursorrules or CLAUDE.md) really short, under about 100 lines. Only write there the project's overall architecture and an index pointing to the more detailed rules files.
- Split rules per task. Create a separate folder in the project for specialized guides: one file for UI rules, one for how to write APIs and databases, one for the testing and deploy process. When starting a task, you only need to tell the AI to read the right file for that task.
- Keep an error logbook (LESSONS.md) and clean it monthly. Every time you spend more than 30 minutes fixing a bug the AI created, have the AI itself summarize it into the logbook in exactly 3 points: What bug – Why it happened – How to check next time. At the end of each month, move rules that have stabilized in the code into an archive section so the main logbook stays short and readable.
Managing context when working with AI is, in the end, very much like writing handover documentation for members of a software development team. Each person who builds products, depending on project size and personal habits, will find their own balance between the speed and comfort of vibe coding and the discipline of a control process.
Apply it now
- Keep the root rules file under 100 lines: only the overall architecture + an index pointing to the detailed rules files. Don't let it balloon to thousands of lines — the AI will skim and miss exactly the most important rule in the middle of the file.
- Split rules per task, load on demand: one file for UI, one for APIs + databases, one for testing + deploy. When starting a task, tell the AI to read only that task's file — don't load the whole rule set for a small change.
- Every bug costing over 30 minutes gets recorded immediately: have the AI summarize it in 3 points — What bug → Why it happened → How to check next time — into LESSONS.md. One minute of recording today saves a whole afternoon tomorrow.
- Don't just say "remember to check carefully" — demand evidence: for important flows, split the process into sequential check steps; to report "done", the AI must extract real results (a direct database query, real API test results) — don't accept "I saw a 200 OK and reported complete".
- Let small jobs run straight through: changing one word or a button's colour shouldn't force the AI through context loading and step-by-step checks — keep the control gates only for flows touching data structure and core business logic.
Frequently asked questions
1. Is the real problem that AI is "dumb" or that AI "forgets"? According to the author: it "forgets". The model can be very smart, but each new chat session or each conversation compression loses the detailed thread. And the automatic memory features of IDEs only remember surface habits — they don't distill the root cause of a bug just fixed into a controllable rule — so a bug fixed yesterday gets repeated today.
2. What's wrong with a fixed rules file (.cursorrules, CLAUDE.md)? Nothing wrong — it's the most common and easiest way to start, and for a small project a few dozen lines are more than enough. The problem only appears as the project grows: the file balloons to thousands of lines, the AI skims and misses important rules, and it wastes tokens loading rules unrelated to the current task.
3. How does the "forgetting" (decay) mechanism work? Inspired by how the human brain stores memories: lessons used often get reinforced and stay in the priority layer; lessons unused for a long time lose weight and "sink" to a deep layer, no longer polluting ordinary chat sessions; but they are not deleted — when a new task touches the context or keywords of that problem, the sunken memory "floats" back up to warn the AI about blind spots that once caused bugs.
4. Can I download "lob-brain" and use it? According to the post, it is a tool the author built himself to run locally and connect to his code editor — the article doesn't say it has been publicly released. If you want to apply it, follow the 3 "no need to build your own tool" steps above: a lean root rules file, rules split per task, and a LESSONS.md cleaned monthly.
5. How does this article relate to earlier harness articles on Wotech? The same concept family: share 137 (Harness, Loop, Graph — "don't loop on confidence, loop on evidence"), share 139 (Anthropic's 3-agent harness), share 21 (the 5-layer harness/loop/graph/factory). This article is a narrower practical angle: just context and memory management — the "memory" part of share 137's Harness layer — with a concrete "forgetting" mechanism and 3 steps to start without coding an extra tool.
Source: Facebook post by Tank Mentor in the Sắc Màu Cuộc Sống Xa Quê group (25/11/2026), the continuation of the same author's previous post on 5 break points in AI's reasoning chain. This is one individual's working method and self-built tool (lob-brain), recorded as the post states it — not a public product or an independently validated research result. The cover is the author's desk photo attached to the post.
Bài viết liên quan

28 tháng 11, 2026 · 14 phut doc
Claude Code's Creator Hasn't Written a Single Line of Code by Hand in 2026, Record 150 Pull Requests a Day: 16 Lessons for Building Products in the AI Era
While many programmers are still debating whether AI writes code as well as humans, the creator of Claude Code has moved to an entirely different stage: he no longer writes code directly. Boris Chern…

28 tháng 11, 2026 · 13 phut doc
As AI Reshapes IT, What Value Should Tech People Keep and Develop?
A business manager who also works in HR has written a long post about the 2026 wave of IT layoffs, along with a question many in the industry are probably asking themselves: if AI can do the job inst…

28 tháng 11, 2026 · 17 phut doc
History Is Repeating Itself, Only Much Faster This Time: Young People Lose the First Rung, Tiny Companies Earn Hundreds of Millions
Entry-level job postings in the US fell 35% in just 18 months. Youth aged 15–24 in Canada face 13.7% unemployment, double the general rate. Meanwhile, there are companies with only a handful of peopl…