rls-policy

Automate creation, auditing, and enforcement of PostgreSQL row-level security policies.

Updated Nov 17, 2025
One-click install
npx skills add https://github.com/Valynt/ValueOS --skill rls-policy-valynt
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: rls-policy
Source: https://github.com/Valynt/ValueOS/tree/main/.windsurf/skills/rls-policy
Command: npx skills add https://github.com/Valynt/ValueOS --skill rls-policy-valynt

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

All tenant-scoped tables must have RLS enabled and four policies covering SELECT, INSERT, UPDATE, and DELETE. The canonical authorization function is security.user_has_tenant_access(organization_id::text) and enables tenant-aware access checks across the schema.

Core Features & Use Cases

  • Enable RLS on tables with deterministic policy templates.
  • Add four policies for tenant isolation: select, insert, update, delete.
  • Audit and validate security schema using test:rls and audit queries.

Quick Start

Enable RLS on a target table, add the four standard policies using the organization_id column, and verify with pnpm run test:rls.

Frequently Asked Questions about rls-policy

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I enforce row-level security for tenant isolation in PostgreSQL?▼

Row-level security for tenant isolation is enforced by enabling RLS on tables and applying four standard policies for SELECT, INSERT, UPDATE, and DELETE using the organization_id column for access checks.

What do I need to set up before applying row-level security policies to my database?▼

Before applying row-level security policies, your database requires the security.user_has_tenant_access(organization_id::text) function, an organization_id column on target tables, and accompanying references templates and migrations.

How do I validate that my row-level security policies are working correctly?▼

Validate row-level security policies by running the test:rls command and executing audit queries to verify the security schema and ensure tenant-aware access checks are properly applied across your tables.

Can I apply row-level security policies across existing database schemas?▼

Yes, row-level security policies can be applied across existing schemas. The process guides developers through enabling RLS, adding the four standard tenant policies, and validating them with test:rls.

What is the best way to automate tenant isolation policy creation in PostgreSQL?▼

Automate tenant isolation policy creation by using deterministic policy templates to add the four standard policies for SELECT, INSERT, UPDATE, and DELETE on all tenant-scoped tables.

Why does row-level security require an organization_id column on my tables?▼

Row-level security requires an organization_id column because it serves as the tenant identifier that the security.user_has_tenant_access function checks to determine access permissions for each row.