DEV Community

Cover image for Your AI IDE Doesn't Need More Prompts. It Needs Rules.
Hari Manoj
Hari Manoj

Posted on

Your AI IDE Doesn't Need More Prompts. It Needs Rules.

We all have worked in some codebase, be it ours or someone else's. And at some point, we are using AI either with an AI IDE or a GPT chat. Today the focus is on AI IDE, and many times we have encountered the issue where we want to develop a feature in a short span of time. So the first instinct in a fast-paced development environment is to give our IDE a prompt.

The Problem

The AI delivers flawlessly and everything works, until it doesn't. When we say something is "working," it's not only when the code works but also if it follows code quality and principles. In software development, maintaining is considered more difficult than developing. And AI is very good at making assumptions if the context or steps are not followed — and that's exactly what happens.

We give a prompt like:

"Hey, I want feature X to be made, and it should have this functionality."

It creates 4 files, out of which 2 are markdown files and the other 2 are redundant custom logic that's very specific to that file. This defeats the whole purpose of maintainability.

The Solution

I am not giving some revolutionary steps like creating agents or elaborate workflows for them to follow. It just resides in two files:

  1. Agents.md
  2. Rules.md

Agents.md

Consider Agents.md as something our AI IDE will look at first, no matter what the prompt is. It's the file that tells the agent about the context of what needs to be followed.

Inside Agents.md, we simply write a single line:

@Rules.md
Enter fullscreen mode Exit fullscreen mode

This is basically telling the AI to look at Rules.md when it reads Agents.md.

Rules.md

As the name suggests, this is where we define a set of rules for our agents to follow.

The flow:

  1. We give a prompt to the IDE.
  2. The AI looks at Agents.md.
  3. From Agents.md, it knows it needs to look at Rules.md.
  4. Whatever is present in Rules.md becomes the instruction the agent needs to follow.

My Top 5 Rules in Rules.md

  1. Do not assume.
  2. Follow the code structure (this needs to be detailed as per your project).
  3. Stick to what's being asked and make sure to scan through the code to look for already existing functionality and the folder structure. (This assumes shared functions are already set up correctly — we can't expect AI to follow the correct structure if we haven't set it up ourselves. This falls under System Design.)
  4. Do not create unnecessary files that aren't relevant to the ask, and avoid long comments in code.
  5. After implementation, reiterate through the rules again and make sure everything is followed.

Conclusion

This might seem like a very simple, high-level thing to do. But the difference it makes is huge — we are giving AI what it needs most to be accurate: context and rules.

You can add as many rules as you want in Rules.md. My recommendation is to keep it within 500 lines, and then see how it changes your coding pace and quality.


Note: This post wasn't written using AI — everything just came out from my heart. Hope this helps everyone who is reading.

Top comments (0)