## Problem
Fixes#53776
We hit this while adding team-scoped RLS to a project from the guide.
Creating the policy fails with:
```text
ERROR: operator does not exist: uuid = jsonb
```
The example uses `team_id in (select auth.jwt() -> 'app_metadata' ->
'teams')`. `->` returns a single `jsonb` value, so `in (select ...)`
compares `team_id` to that jsonb value.
## Solution
Expand the claim with `jsonb_array_elements_text`, cast each team ID to
`uuid`, and compare it with `= any (array(...))`:
```sql
using (
team_id = any (
array(
select (jsonb_array_elements_text((select auth.jwt()) -> 'app_metadata' -> 'teams'))::uuid
)
)
);
```
`app_metadata.teams` must be an array of UUID strings, for example
`{"app_metadata": {"teams": ["22222222-2222-2222-2222-222222222222"]}}`.
Objects such as `[{"id": "..."}]` fail the cast.
Comparing UUID to UUID means uppercase values in the claim still match
and Postgres can use an index on `team_id`. The guide and the AI prompt
in `examples/prompts/database-rls-policies.md` both document the
expected claim shape and that `team_id` is a `uuid`; for other ID types,
cast the array element to that type instead.
## Review instructions
1. Open the `auth.jwt()` section of the [RLS
guide](https://supabase.com/docs/guides/database/postgres/row-level-security#auth-jwt).
2. Run the updated `create policy` statement against Postgres. It should
create without error.
3. Check that a user whose `app_metadata.teams` is an array of UUID
strings containing the row's `team_id` sees the row, including when the
claim uses an uppercase UUID, and that a user without it does not.
I checked these steps on Postgres 14.
## Checklist
- [x] I have read
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
- [x] If I wrote a new docs topic or edited an existing topic, I used
the `/write-the-docs` or `/edit-the-docs` skill, which applies the docs
[style
guide](https://github.com/supabase/supabase/tree/master/apps/docs/style-guide)
I used AI to help debug this. The fix and this pull request are mine; I
reviewed the change before opening it.
---------
Co-authored-by: Nik Richers <nrichers@gmail.com>
* remove glob from all examples
* Add declarative schema instructions
* run prettier
* update file extension for declarative-database-schema rule
* update the example prompts in the examples folder
* remove displaying heading for the AI prompts
* remove the prompt note for test
* revert the change for not displaying the heading for the menu
* Add back the title for each prompt
* allow putting frontmatter before heading
---------
Co-authored-by: Charis Lam <26616127+charislam@users.noreply.github.com>
* Update the instruction to add to project
* bringing Cursor at the front, because that is the most popular one of all
* Add sample description and globs for all sample prompt within the docs
* remove the cursor rule I created by mistake
* fix typo