DEV Community

Cover image for How I Configured Cursor to Stop Breaking My Codebase
NewtechFiend
NewtechFiend

Posted on

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

That last pattern — explicit anti-patterns — is what separates a config that works from one that gets ignored.

The DO NOT section is the secret weapon

AI assistants are optimizers. They want to "improve" things. Without guardrails, improvement means refactoring your working code.

The DO NOT section tells the model what not to touch. Be specific:

❌ Vague

✅ Specific

"Don't break things"

"Do NOT rewrite route handlers in app/api/"

"Follow best practices"

"Do NOT add "use client" without browser API need"

"Be careful"

"Do NOT delete DB columns without a migration"

Add 5–10 rules from your own worst AI disasters. Update monthly as the model finds new ways to "help."

Prompts for tasks, configs for sessions

Configs handle always-on rules. Prompts handle specific jobs:

Debug an error → minimal diff, read stack trace first

Scaffold a feature → match existing patterns, list files before coding

Ship checklist → lint, types, secrets, mobile, tenant scoping

Keep prompts in a folder. Copy-paste into chat when needed. Don't retype the same instructions every time.

Free sample you can use today

I'm sharing a free sample — Next.js stack config + 3 prompts:

GitHub: https://github.com/js91tech/ship-faster-ai-free-sample

Quick start:

Copy CLAUDE.md and .cursorrules to your Next.js project root

Search for [CUSTOMIZE] — update 3 lines (project name, description, deploy target)

Next time something breaks, paste 01-debug-error.md into chat

Takes about two minutes.

Full toolkit (if you want all stacks)

I packaged the complete system for Gumroad:

5 stack configs — Next.js, React + Vite, FastAPI, Express, SaaS generic

15 battle-tested prompts

DO NOT anti-patterns guide

One-time $29, instant ZIP download: Get the toolkit

Landing page with FAQ: https://shipfasterdevkit.netlify.app/

(Not affiliated with Cursor or Anthropic — just a dev who got tired of re-prompting.)

Results I've seen

After using configs consistently:

Fewer "why did it rewrite my entire API" sessions

Less time explaining stack basics in every chat

Prompts actually work because the base context is already loaded

Ship checklist catches things I'd miss late at night

Your mileage varies — but the free sample costs nothing to try.

Takeaways

Configs > prompts for session-level context

DO NOT sections are the highest-ROI part

Be stack-specific — generic rules get ignored

Customize 3 lines and ship — don't over-engineer on day one

If you try the sample, let me know what you'd add to the DO NOT list. I'm collecting the best ones.

What's the #1 thing you wish your AI copilot would stop doing? Drop it in the comments.

Top comments (0)