I use a simple documentation pattern to reduce context drift and comment/rule drift across agent sessions, based on Bertrand Meyer’s - DbC (Design by Contract) adapted for the epoch of AI Agents.
- `QUICKSTART.md` — run steps + verification checks
Optional planning queue
- `FUTURE.md` — planned ideas only (non-binding until implemented)
Update rule
After each meaningful change, update the narrowest owning file:
- invariant change → `CONTRACT.md`
- run/verification change → `QUICKSTART.md`
- governance/ownership change → `WHY.md`
- planning-only idea → `FUTURE.md`
This has reduced drift for me in long sessions and handoffs.
HOW-TO:
E.g. “contract-style comments for the AI coding agent github” Highlight those keywords, right-click, search.
tell Your Cursor agent to clone it into your project (contains ONLY .md files and illustrations)
tell the agent your project goal, and have it produce the corresponding CONTRACT.md files.
Question: Would Cursor consider first-class support for prioritizing a project invariants file before edits?
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:
Cmd+Shift+P or Ctrl+Shift+P, then Cursor Settings > Rules
Click + Add Rule or use /create-rule in chat
Set the rule type to Always Apply
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.
The platform and tooling agnostic nature of the methodology makes it portable to any development enviroment. E.g. you can work with MS Copilot in notepad, at no co$t.
It’s just markdown files. Unless agents change the way we interact, and how the ML etc interprets input, I don’t see there being much need for anything else in terms of drift. An occasional “Please step-back and re-read CONTRACTs” seems to improve the reliability.