ChatGPT community, AI Questions and Answers, Curso

CameronOwl Expert 2h ago 223 views 3 likes 4 min read

How I finally stopped Cursor from hallucinating my project structure

ChatGPT community, AI Questions and Answers, Curso

I spent four hours last Tuesday fighting with Cursor (v0.42.x) because it kept trying to import components from a /components folder that didn't exist. I’m using a feature-sliced design where everything is in /features, but the LLM had this obsession with standard Next.js layouts. It was rewriting my imports every single time I hit "Apply," turning a 2-second fix into a 10-minute manual cleanup.

The fix wasn't a better prompt. It was a .cursorrules file.

Why your prompt isn't enough for project consistency

Most people treat AI coding like a chat session. You tell it "I'm using FSD," it says "Got it," and then three prompts later, it's back to suggesting import { Button } from '@/components/ui/button' when my buttons are actually in @/shared/ui.

The bottleneck is the context window. Even with the best RAG, the model occasionally drifts toward the "average" of its training data—which is usually the most common (and often generic) project structure on GitHub.

I tried adding these instructions to my system prompt, but that's a global setting. I needed something project-specific. That's where a local rules file comes in.

Fixing the "Wrong Path" hallucination with .cursorrules

I created a .cursorrules file in my root directory. I didn't write a polite request; I wrote a set of constraints.

Here is the exact block that stopped the import madness:

# Project Architecture Constraints
- This project uses Feature-Sliced Design (FSD).
- NEVER suggest imports from a top-level `/components` or `/hooks` folder.
- Components must reside in `/features/[feature-name]/ui` or `/shared/ui`.
- Always check the file tree before suggesting an import path.
- If you are unsure of the path, use `ls` to verify the directory structure before writing code.

The moment I saved that, the behavior shifted. When I asked it to create a new user profile card, it actually looked at /features/user-profile/ui instead of inventing a /components/UserCard.tsx.

ChatGPT community, AI Questions and Answers, Cursor rules setup

The trade-off between strict rules and creativity

There is a risk here. If you make your .cursorrules too rigid, the AI stops suggesting architectural improvements.

Last month, I tried to force a very specific naming convention for hooks (prefixing everything with useCustom-). I found that Cursor stopped suggesting the built-in React hooks that actually solved my problem because it was too focused on following my naming rule.

I've since learned to categorize my rules into "Hard Constraints" (folder paths, types) and "Preferences" (naming, style).

| Type | Example | Impact |
| :--- | :--- | :--- |
| Hard Constraint | "Use Tailwind, never CSS modules" | High - Prevents broken builds |
| Preference | "Prefer arrow functions over declarations" | Low - Purely aesthetic |
| Logic Rule | "Always wrap async calls in a try-catch block" | Medium - Improves stability |

Getting out of the "Solo Dev" loop

The wild part is that I didn't find the .cursorrules trick in the official documentation. I found it by digging through a thread in a ChatGPT community where a few of us were comparing how to keep Claude 3.5 Sonnet from forgetting the tech stack in large repos.

Being part of an AI-focused group is basically a shortcut to avoiding the "trial and error" phase of a new tool. Instead of spending a week guessing why the AI is ignoring my file structure, someone else has usually already posted the exact configuration that works.

If you're tired of guessing, you can dive into the Resources section of PromptCube to see how other devs are structuring their AI workflows. It's less about "how to prompt" and more about "how to build a system" where the AI doesn't fight you.

A better way to handle AI Questions and Answers

Stop asking the AI "How do I do X?" and start asking "Given my current project structure in .cursorrules, what is the most efficient way to implement X?"

When you frame the question around your constraints, the AI is less likely to give you a generic tutorial answer and more likely to give you code you can actually commit.

If you're still seeing hallucinations, check these three things:
1. Is your .cursorrules file in the root? (It must be).
2. Are you using "Composer" mode? (Rules apply more consistently there).
3. Are you contradicting yourself in the chat? (If you tell the AI to "just ignore the rules for a second," it often forgets them for the rest of the session).

Join the PromptCube community if you want to stop treating AI as a magic box and start treating it as a configurable compiler. The gap between a "good" AI developer and a "frustrated" one is usually just a few lines of configuration in a hidden text file.

All Replies (0)

No replies yet — be the first!

Write a Reply

Markdown supported