Workflow to reduce drift in Cursor sessions

Hey, cool workflow. The DbC approach for AI agents is a nice angle.

What you’re describing with CONTRACT.md as invariants lines up well with Cursor’s Project Rules system Rules | Cursor Docs. You can create .cursor/rules/ files with the Always Apply type. These get injected at the start of every agent session. So you could put your invariants directly into an always-applied rule file instead of relying on the agent to read CONTRACT.md.

Quick setup:

  1. Cmd+Shift+P or Ctrl+Shift+P, then Cursor Settings > Rules
  2. Click + Add Rule or use /create-rule in chat
  3. Set the rule type to Always Apply
  4. Put your invariants there

That said, the rule drift problem in long sessions is real and known. Rules can get pushed out of context as the conversation grows. A few related discussions:

Current workarounds for long sessions are starting a new chat when rules stop working, using models with longer context, or reminding critical rules inline in the prompt.

As for first-class support for prioritizing an invariants file before edits, the team is aware this is a common pain point. Your report helps with visibility on this.