How I Configured Cursor to Stop Breaking My Codebase
If you use Cursor, Claude Code, or Windsurf daily, you've probably had this experience: You open a fresh chat, ask for a small fix, and twenty minutes later the AI has rewritten your API layer, added three new dependencies, and switched your data-fetching pattern "for consistency." The model isn't broken. It's contextless. Every new session starts from zero. It doesn't know your stack, your conventions, or the things it must never touch. So you spend the first ten minutes re-explaining — and the last hour undoing. Here's what fixed it for me. The real problem isn't prompts Most devs collect prompts. Notes app, Slack snippets, old chat threads. That helps for one-off tasks, but it doesn't solve the session problem. What you need is persistent context — rules that load automatically before you type anything. Two files do this: CLAUDE.md — read by Claude Code (and usable as project context elsewhere) .cursorrules — loaded by Cursor on every session (rename to .windsurfrules for Windsurf) Drop them in your project root. Done. What goes in a good config file A useful config is not ten lines of "use TypeScript and write clean code." That's too vague to change behavior. Mine include: Project structure — where pages, components, and API routes live Stack + versions — Next.js 14 App Router, not Pages; Zod; shadcn/ui Commands — npm run dev, npm run typecheck, npm run test Coding conventions — naming, import aliases, Server vs Client Components DO NOT section — the most important part (more on this below) Workflow notes — use @folder, prefer editing existing files, minimal diffs Here's an excerpt from the DO NOT section that saved me the most time: DO NOT — Critical Anti-Patterns Do NOT create a pages/ directory or use the Pages Router Do NOT rewrite the entire API layer — extend existing route handlers Do NOT add new npm dependencies without stating why Do NOT make drive-by refactors in unrelated files Do NOT fetch data in useEffect when Server Components can fetch directly T