AddThisFeature

User Roles

Not everyone should be able to do everything.

involved User Accounts

What it adds

Role-based permissions, enforced on the server, with a UI that reflects them.

What your agent is told to do

4
  1. 1

    Define roles and their permissions in ONE place. Scattering if user.admin? through the codebase is how authorization bugs happen.

  2. 2

    Enforce every permission server-side, at the controller or service layer.

  3. 3

    Hide UI the user can't use — but never rely on hiding as the enforcement.

  4. 4

    Default to deny. A new endpoint should be inaccessible until explicitly permitted.

Edge cases it handles

5
  • Test every endpoint as a LOW-privilege user, not just as an admin. This is where the bugs are.
  • A role change must take effect immediately, not on next login.
  • Object-level permissions matter: a user may edit their own record but not someone else's. Role alone isn't enough.
  • API endpoints and background jobs need the same checks as the UI.
  • The last admin must not be able to demote themselves.

Definition of done

8
  • Permissions are defined in one place.
  • Every endpoint is enforced server-side and defaults to deny.
  • Object-level ownership is checked, not just the role.
  • Requesting a forbidden endpoint directly is refused.
  • Role changes take effect immediately.
  • The system cannot be left without an admin.
  • 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.