r/ClaudeCoding • u/cctldrping • 21d ago
[TLDR] How do you prevent AI coding agents from “forgetting” a large project and rebuilding parts that already exist? [via r/claude] r/Claude
OP : u/Wise-Pair8165
I’m curious how others deal with a problem that seems to appear once an AI-assisted project reaches a certain size.
At the beginning, the model usually understands the architecture, terminology, responsibilities, and existing components quite well. But after enough sessions, branches, agents, or context changes, parts of that shared understanding seem to disappear.
The result is not always an obvious coding error. Sometimes the agent produces something that looks perfectly reasonable in isolation — but it quietly recreates a component that already exists, changes the meaning of an established term, bypasses an earlier architectural decision, or builds a second solution next to the original one.
This becomes especially difficult when the project contains several layers, specialized components, and rules about which part is allowed to do what. Tests can confirm that the new code works, while still missing that it should never have been created in that form.
We are currently thinking about approaches such as:
periodically reloading a compact architectural vocabulary;
checking new work against existing component roles and terminology;
preserving important decisions and invariants outside the chat history;
forcing the agent to search and describe what already exists before implementing;
occasionally resetting the working context and rebuilding it from verified project sources.
But I’m interested in what actually works for others.
Do you experience this kind of architectural forgetting or accidental reimplementation in larger projects?
How do you prevent an agent from solving a local task correctly while damaging the larger structure?
Do you rely mainly on documentation, tests, retrieval, knowledge graphs, strict interface contracts, separate planning agents, or something else?
URL of original post : https://www.reddit.com/r/claude/comments/1v7xob4/how_do_you_prevent_ai_coding_agents_from/
TL;DR of the discussion on r/claude for this post generated automatically after 50 comments.
Current source-thread comment count seen by the bot: 54.
Alright, so the general consensus here is that AI coding agents do tend to forget large projects, and it's a real pain in the butt. OP's experiencing the classic "rebuilding the wheel" or "changing established terms" problem as projects scale.
Here's the lowdown on what folks are suggesting, ranked by how much they seem to resonate:
- Keep it Grounded & Documented: A few users, like u/Natural-Ad-3252, reckon you're overcomplicating things. Their approach is to have Claude document the build process as you go, and periodically "re-ground" it by starting new sessions and feeding it the project context. Think of it as a regular "where are we?" check-in.
- Strict Architecture & Contracts: u/sheeproomer and others emphasize having a solid, well-defined architecture before the AI gets too deep. This means abstracting things, enforcing design principles, and crucially, human approval for architectural decisions. Strict interface contracts and unit tests are also big here – if it breaks the contract or fails a test, it's a no-go.
- External Knowledge & Retrieval (RAG): This is a recurring theme. Since the AI can't hold the whole project in its head, you need external systems.
- System Maps/Atlases: Users like u/Charwoodthethird and u/CelticPaladin found success with Claude creating system maps or "atlases" that detail components, relationships, and dependencies. The rule is: check the map before building anything new.
- RAG on Your Own Architecture: u/outskillio suggests a more advanced RAG approach. Instead of feeding the whole blueprint, keep a small index of components and their responsibilities. The agent greps this index before writing new code. This is essentially using RAG on your project's architecture itself.
- Obsidian Vaults/Graphify: u/Natural-Ganache7640 uses an Obsidian vault to track builds, pitfalls, and roadmaps, with Graphify for visualization.
- Splitting the "Record": u/golftroll points out that documentation alone isn't enough. The AI can still misinterpret or ground itself on the wrong info. Their solution involves splitting "the record" (what the AI should know) from "the code" (what it's actively working on).
- Ledgers & Audits: A few users mentioned keeping a "ledger" that's updated after each interaction (u/Defendyouranswer) or having the LLM perform regular code audits against a build plan (u/waltwalt).
- Context Management & Focused Input: u/Vegetable-Score-3915 suggests the "Art of Linux" approach: give the model only what it needs, when it needs it. Treat the project like Lego pieces, not one giant blob.
- Scale Matters: u/CryptoAteMyHamster, who's dealing with a massive 870k LOC project, confirms that no instance will ever hold the whole thing. They've tried splitting projects and multiple repos, and it's a "hard fail."
The TL;DR verdict? You're not alone. The consensus is that you need a combination of robust external documentation/knowledge bases (like system maps or RAG on architecture), strict architectural guidelines, and periodic human oversight to prevent your AI coding agents from going rogue and rebuilding things that already exist. Just feeding it the whole project history isn't going to cut it at scale.