Cursor is a capable AI coding editor, but out of the box it's working with limited context. It knows the files you've opened, the code you've written in this session, and whatever you've told it in chat. If it doesn't know what your database looks like, what patterns your codebase follows, or what your project conventions are — it guesses. And guesses compound.
The setup described here isn't complex. It's a few configuration decisions that give Cursor durable context: context it can read at the start of every session, without you having to repeat yourself.
Think of Cursor's accuracy as a function of three things: what it knows about your project conventions, what it knows about your data model, and whether it reasons through a task before acting on it.
Each of the tools below addresses one of those layers.
.cursor/rules — Project Conventions.cursor/rules/ (the successor to .cursorrules) is a folder of Markdown files that Cursor reads as persistent instructions. Unlike chat context, rules survive across sessions. Unlike comments in code, rules are structured for the agent rather than for human readers.
Format: Each file in .cursor/rules/ uses the .mdc extension and follows an imperative structure:
---
description: Database query conventions
globs: ["src/**/*.ts", "src/**/*.tsx"]
---
# Database Rules
Always introspect the GraphQL schema before writing any database query.
Reference only fields that appear in the schema. If a field name is uncertain, call the introspection tool.
Use the typed operation wrappers in /src/lib/api rather than raw fetch calls.
The globs field tells Cursor when to load this rule — so your database rules apply when editing TypeScript files, not when editing CSS. This keeps the active context small and relevant.
What to put in rules:
Field naming conventions (snake_case vs camelCase, ID field names)
Which files to import from vs. which to avoid
The pattern for calling your backend (typed operations, not raw fetch)
Error handling conventions
Testing patterns
The rule that produces the biggest quality jump for database work: "Always introspect the schema before writing any database operation." When combined with a connected backend (see Layer 2), this single rule eliminates the majority of column-name and type errors.
AGENTS.md (at the repo root) is a plain Markdown file that AI coding tools — Cursor, Claude Code, and Codex — read as the canonical description of your project. Think of it as the README the agent actually uses.
A minimal AGENTS.md for a project with a connected backend:
# Project Overview
This is a [describe your app] built with React + Vite on the frontend and Momen as the backend.
## Backend
- Backend: Momen (visual Postgres-native BaaS)
- API: GraphQL, auto-generated from the data model
- Authentication: Momen's built-in auth system
- Schema: Introspect via the MCP connection before writing any queries
## Conventions
- Components: functional, TypeScript
- State: React Query for server state
- Styles: Tailwind CSS
- Mutations: always go through typed Actionflow calls, not direct table writes
## What to read before starting
1. Introspect the GraphQL schema
2. Check /src/lib/api for existing typed operations before writing new ones
3. Check existing component patterns in /src/components before creating new ones
The key principle: put information in AGENTS.md that changes slowly (architecture, conventions, tool choices) and leave information that changes quickly (current task, recent decisions) in chat context where it belongs.
When Cursor starts a session, it reads AGENTS.md before the first prompt. Every session starts with the same baseline understanding of your project.
Cursor's Plan Mode (activated with Shift+Tab) separates the planning step from the execution step. Instead of immediately writing code, Cursor outlines what it intends to do and waits for your confirmation.
This matters for multi-step tasks — and database operations almost always are multi-step. A mutation that creates a record and triggers a server-side flow involves several operations that should be reviewed as a sequence before any code is written.
When to use Plan Mode:
Any task that touches the database or API layer
Refactoring existing logic (to catch unintended side effects before they happen)
New feature development that crosses multiple components
Any time you're uncertain whether the agent has understood the full scope
Plan Mode is not always faster — the planning step adds time. But it catches misunderstandings before they become bugs, and a caught misunderstanding costs less than debugging generated code.
.cursor/rules, AGENTS.md, and Plan Mode all improve Cursor's reasoning about your backend. But they depend on having accurate backend information to reason with.
If your data model lives in a spreadsheet, a rough ERD, or your own head — Cursor can't read it. The agent's rules say "introspect the schema" and there's nothing to introspect.
A schema-first backend makes all three layers work better by giving Cursor something real to read.
Momen exposes your entire data model — tables, relations, types, server-side Actionflows, and permissions — as a typed GraphQL API with introspection enabled. Connect it to Cursor by adding the Momen Plugin to your MCP config (.cursor/mcp.json):
{
"mcpServers": {
"momen": {
"command": "npx",
"args": ["-y", "momen-mcp@latest", "mcp"]
}
}
}
Cursor reads the actual schema at the start of each session. Every column name, field type, and relationship is available. Your .cursor/rules instruction to "introspect before querying" becomes meaningful because there's a real schema to introspect. Your AGENTS.md can reference "the Momen backend" and Cursor knows what that means because the connection is live.
The result: Cursor writes queries against columns that exist, mutations that call the correct Actionflow endpoints, and auth logic that matches the actual permissions model. You're not debugging hallucinated field names.
For an example of this configuration in action, see Building a Full-Stack AI Trip Planner with Momen and Cursor — a step-by-step walkthrough of how the data model, rules, and agent connection fit together in a real project.
Momen's Actionflow documentation covers the server-side logic layer that the agent learns to call correctly once the schema is connected.
.cursor/rules SnippetCopy this into .cursor/rules/backend.mdc for any project using a GraphQL backend:
---
description: Backend and API conventions
globs: ["src/**/*.ts", "src/**/*.tsx", "src/**/*.js"]
---
# Backend Rules
1. Before writing any query or mutation, call the GraphQL introspection tool to confirm field names and types.
2. Import typed operation wrappers from /src/lib/api — do not write raw fetch calls to the API.
3. All mutations must go through Actionflow endpoints. Do not write directly to the database.
4. Auth state is handled by the backend; never store tokens in localStorage.
5. If a required field is uncertain, read the schema rather than guessing.
Adjust the paths to match your project structure. The imperative format ("do X, not Y") produces more consistent results than descriptive format ("the project uses X").
Three configuration decisions — .cursor/rules for conventions, AGENTS.md for project context, and Plan Mode for reasoning before acting — give Cursor durable context that survives across sessions. The fourth piece, a schema-first backend, is what makes those rules meaningful: when Cursor is told to introspect before querying, it actually has something real to introspect.
The configuration takes about 20 minutes to set up once and pays for itself on the first session where the agent correctly references a field name without being told what it is.