AI coding: stop duplicating your effort!
Teaching AI to read before it writes
When coding with AI assistance, one of the recurring problems I’ve seen is that it duplicates work all the time. It builds multiple functions that do the same thing, or creates multiple versions of a file in different directories. The problem comes from how models “search.” Each time you ask them to implement a feature, they don’t truly read your codebase—they scan it for keywords, like a student looking for answers before understanding the chapter.
Once they think they’ve found the right spot, they zoom in and start building. The problem arises when they guess wrong. If they don’t find what already exists, they simply make a new version. I’ve seen AI assistants duplicate functions, classes, and even entire systems.
In one project, the model created two separate SQLite databases because it couldn’t locate the first one. To its mind, “no database found” meant “create a database.” It just hadn’t looked properly.
I realised that what it lacked wasn’t logic—it lacked context. So I built a system to give it that.
In my workflow with Claude Code, I created a sub-agent—a kind of documentation guru. Its only job is to review and update all documentation before every commit. That includes the README, which maps out the app’s structure and functional areas.
Inside Claude.MD, there’s a list of pre-commit instructions. One tells the documentation agent to verify and update the README. Another tells any coding agent to read that README before starting work on a new feature.
This approach works equally well in other AI coding environments. In Cursor, for instance, you can include similar pre-commit or pre-action checks inside your .cursor/rules file. The same principle applies to GitHub Copilot Workspaces, Replit Agents, or even Windsurf, which all support rule-based or agentic preflight instructions. The goal stays the same: give your AI a structural overview before it writes, so it doesn’t have to guess what already exists.
That one habit—reading before writing—eliminated duplication. Now, whenever I ask Claude to add a feature, it first understands the project’s full structure. It doesn’t search blindly; it acts with awareness.
In other words, I taught it the same rule every good developer learns early: read the docs first.

