AddThisFeature

Record Locking

Reserve a record while you edit it so nobody else can start editing at the same time.

involved Collaboration

What it adds

Pessimistic locks on high-risk records: one editor at a time, with expiry and a supervised takeover path.

What your agent is told to do

5
  1. 1

    Acquire the lock on the server when a user opens the edit view, storing the holder, the acquisition time, and an expiry.

  2. 2

    Keep the lock alive with a heartbeat from the open editor and release it on save, cancel, or navigation away.

  3. 3

    Enforce the lock on every write path, not just in the UI. A client-side lock is a courtesy, not a guarantee — the server must reject writes from anyone who does not hold it.

  4. 4

    Let an authorized user force-release a lock they do not own, and record who broke which lock and when.

  5. 5

    Do NOT lock reading. Viewers must always get through; only the edit action is gated.

Edge cases it handles

6
  • A crashed browser or closed laptop leaves a lock with no owner. Expire on missed heartbeats, not only on an absolute timeout.
  • The same user opening a second tab should take over their own lock, not be blocked by themselves.
  • Show who holds the lock and since when. 'Locked by another user' with no name is a support ticket.
  • A force-release must notify the displaced editor while they still have their unsaved work on screen.
  • The lock holder must be warned before their lock expires mid-edit, with a way to extend it.
  • Deleting or archiving a locked record has to release the lock rather than strand it.

Definition of done

8
  • Opening the editor acquires a server-side lock and closing it releases one.
  • Writes from a non-holder are rejected by the server.
  • Locks expire after missed heartbeats without manual cleanup.
  • A user's own second session takes over rather than being blocked.
  • The lock holder's identity and start time are shown to anyone blocked.
  • Force-releases are permission-checked and recorded.
  • The feature matches the existing design system.
  • No existing functionality is broken.

Related features

How it works

  1. 1

    Copy the link

    Grab the Markdown instruction URL for this feature.

  2. 2

    Give it to your AI

    Paste it into Claude Code, Cursor, v0, Lovable — whatever you build with.

  3. 3

    It inspects, then implements

    Your agent reads your existing app first, then adds the feature to fit it.

Works with your stack

These instructions are written to adapt. They tell the agent to detect your framework, match your existing design system, and reuse what you already have — rather than assuming a particular stack.

Need it tighter than that? Customize the feature and tell it exactly what you're running.