postgres-rls

Design PostgreSQL Row-Level Security policies with USING and WITH CHECK.

1|Updated Feb 19, 2026
One-click install
npx skills add https://github.com/juburr/mad-skills --skill postgres-rls-juburr
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: postgres-rls
Source: https://github.com/juburr/mad-skills/tree/main/postgres-rls
Command: npx skills add https://github.com/juburr/mad-skills --skill postgres-rls-juburr

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

PostgreSQL Row-Level Security (RLS) enables per-row access control by policies, ensuring sensitive data is only visible or modifiable by authorized users.

Core Features & Use Cases

  • Design and implement RLS policies using USING and WITH CHECK for row visibility and write validation.
  • Evaluate policy combinations (permissive vs restrictive) and implement ownership, group-based access, and classification-like gates across tables and views.
  • Provide testing and auditing guidance, including enabling row-level security, verifying with row_security_active(), and using EXPLAIN ANALYZE to validate plans and security barriers.

Quick Start

Enable RLS on a sample table and implement a basic owner-based policy to observe row-level filtering.

Frequently Asked Questions about postgres-rls

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

FAQPage Schema
How do I implement row-level security in PostgreSQL for owner-based access?

PostgreSQL row-level security filters rows per user by combining USING and WITH CHECK policies. You enable RLS on a table and define policies that evaluate ownership constraints to restrict row visibility and validate writes.

What is the difference between permissive and restrictive RLS policies?

Permissive RLS policies use OR logic, allowing access if any policy passes, while restrictive policies use AND logic, requiring all conditions to be met. Combining them enforces complex classification-like gates across tables and views.

How do I test PostgreSQL RLS policies to verify they work correctly?

Test PostgreSQL RLS policies by enabling row-level security, checking active status with row_security_active(), and running EXPLAIN ANALYZE to validate query plans and security barriers under diverse roles and environments.

Can I use PostgreSQL row-level security with views and partitions?

PostgreSQL row-level security applies to views and partitions by enforcing policies across underlying data structures. You can implement ownership, group-based access, and classification-like gates spanning tables, views, and partitions.

What are the performance considerations when using RLS in PostgreSQL?

PostgreSQL RLS performance depends on indexing strategies and security barrier optimization. Use EXPLAIN ANALYZE to validate query plans, ensuring policies do not degrade performance when filtering rows across diverse roles and environments.

How do I enforce group-based permissions with PostgreSQL RLS?

Group-based permissions in PostgreSQL RLS are enforced by writing policies that evaluate role membership. Combining permissive and restrictive policies implements fine-grained access control for groups across tables and views.