class-ai-agent 1.3.0 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agent/SESSION.md +18 -13
- package/.claude/CLAUDE.md +26 -0
- package/.claude/agents/business-analyst.md +380 -0
- package/.claude/references/codegraph.md +26 -14
- package/.claude/references/supabase.md +55 -0
- package/.claude/rules/agent-continuity.md +3 -2
- package/.claude/rules/api-conventions.md +1 -0
- package/.claude/rules/clean-code.md +1 -0
- package/.claude/rules/code-style.md +1 -0
- package/.claude/rules/codegraph.md +43 -0
- package/.claude/rules/database.md +2 -1
- package/.claude/rules/error-handling.md +1 -0
- package/.claude/rules/git-workflow.md +1 -0
- package/.claude/rules/monitoring.md +1 -0
- package/.claude/rules/naming-conventions.md +1 -0
- package/.claude/rules/project-structure.md +1 -0
- package/.claude/rules/security.md +1 -0
- package/.claude/rules/system-design.md +1 -0
- package/.claude/rules/tech-stack.md +3 -1
- package/.claude/rules/testing.md +1 -0
- package/.claude/settings.json +3 -1
- package/.claude/skills/supabase/SKILL.md +135 -0
- package/.claude/skills/supabase/UPSTREAM.md +16 -0
- package/.claude/skills/supabase/assets/feedback-issue-template.md +17 -0
- package/.claude/skills/supabase/references/skill-feedback.md +17 -0
- package/.claude/skills/supabase-postgres-best-practices/SKILL.md +64 -0
- package/.claude/skills/supabase-postgres-best-practices/UPSTREAM.md +16 -0
- package/.claude/skills/supabase-postgres-best-practices/references/_contributing.md +170 -0
- package/.claude/skills/supabase-postgres-best-practices/references/_sections.md +39 -0
- package/.claude/skills/supabase-postgres-best-practices/references/_template.md +34 -0
- package/.claude/skills/supabase-postgres-best-practices/references/advanced-full-text-search.md +55 -0
- package/.claude/skills/supabase-postgres-best-practices/references/advanced-jsonb-indexing.md +49 -0
- package/.claude/skills/supabase-postgres-best-practices/references/conn-idle-timeout.md +46 -0
- package/.claude/skills/supabase-postgres-best-practices/references/conn-limits.md +44 -0
- package/.claude/skills/supabase-postgres-best-practices/references/conn-pooling.md +41 -0
- package/.claude/skills/supabase-postgres-best-practices/references/conn-prepared-statements.md +46 -0
- package/.claude/skills/supabase-postgres-best-practices/references/data-batch-inserts.md +54 -0
- package/.claude/skills/supabase-postgres-best-practices/references/data-n-plus-one.md +53 -0
- package/.claude/skills/supabase-postgres-best-practices/references/data-pagination.md +50 -0
- package/.claude/skills/supabase-postgres-best-practices/references/data-upsert.md +50 -0
- package/.claude/skills/supabase-postgres-best-practices/references/lock-advisory.md +56 -0
- package/.claude/skills/supabase-postgres-best-practices/references/lock-deadlock-prevention.md +68 -0
- package/.claude/skills/supabase-postgres-best-practices/references/lock-short-transactions.md +50 -0
- package/.claude/skills/supabase-postgres-best-practices/references/lock-skip-locked.md +54 -0
- package/.claude/skills/supabase-postgres-best-practices/references/monitor-explain-analyze.md +45 -0
- package/.claude/skills/supabase-postgres-best-practices/references/monitor-pg-stat-statements.md +55 -0
- package/.claude/skills/supabase-postgres-best-practices/references/monitor-vacuum-analyze.md +55 -0
- package/.claude/skills/supabase-postgres-best-practices/references/query-composite-indexes.md +44 -0
- package/.claude/skills/supabase-postgres-best-practices/references/query-covering-indexes.md +40 -0
- package/.claude/skills/supabase-postgres-best-practices/references/query-index-types.md +48 -0
- package/.claude/skills/supabase-postgres-best-practices/references/query-missing-indexes.md +43 -0
- package/.claude/skills/supabase-postgres-best-practices/references/query-partial-indexes.md +45 -0
- package/.claude/skills/supabase-postgres-best-practices/references/schema-constraints.md +80 -0
- package/.claude/skills/supabase-postgres-best-practices/references/schema-data-types.md +46 -0
- package/.claude/skills/supabase-postgres-best-practices/references/schema-foreign-key-indexes.md +59 -0
- package/.claude/skills/supabase-postgres-best-practices/references/schema-lowercase-identifiers.md +55 -0
- package/.claude/skills/supabase-postgres-best-practices/references/schema-partitioning.md +55 -0
- package/.claude/skills/supabase-postgres-best-practices/references/schema-primary-keys.md +61 -0
- package/.claude/skills/supabase-postgres-best-practices/references/security-privileges.md +54 -0
- package/.claude/skills/supabase-postgres-best-practices/references/security-rls-basics.md +50 -0
- package/.claude/skills/supabase-postgres-best-practices/references/security-rls-performance.md +63 -0
- package/.claude/skills/ui-ux-pro-max/SKILL.md +1 -90
- package/.cursor/CURSOR.md +4 -1
- package/.cursor/agents/business-analyst.md +380 -0
- package/.cursor/mcp.json +4 -0
- package/.cursor/references/supabase.md +55 -0
- package/.cursor/rules/cursor-overview.mdc +1 -1
- package/.cursor/rules/database.mdc +2 -2
- package/.cursor/rules/tech-stack.mdc +2 -1
- package/.cursor/settings.json +6 -1
- package/.cursor/skills/supabase/SKILL.md +135 -0
- package/.cursor/skills/supabase/UPSTREAM.md +16 -0
- package/.cursor/skills/supabase/assets/feedback-issue-template.md +17 -0
- package/.cursor/skills/supabase/references/skill-feedback.md +17 -0
- package/.cursor/skills/supabase-postgres-best-practices/SKILL.md +64 -0
- package/.cursor/skills/supabase-postgres-best-practices/UPSTREAM.md +16 -0
- package/.cursor/skills/supabase-postgres-best-practices/references/_contributing.md +170 -0
- package/.cursor/skills/supabase-postgres-best-practices/references/_sections.md +39 -0
- package/.cursor/skills/supabase-postgres-best-practices/references/_template.md +34 -0
- package/.cursor/skills/supabase-postgres-best-practices/references/advanced-full-text-search.md +55 -0
- package/.cursor/skills/supabase-postgres-best-practices/references/advanced-jsonb-indexing.md +49 -0
- package/.cursor/skills/supabase-postgres-best-practices/references/conn-idle-timeout.md +46 -0
- package/.cursor/skills/supabase-postgres-best-practices/references/conn-limits.md +44 -0
- package/.cursor/skills/supabase-postgres-best-practices/references/conn-pooling.md +41 -0
- package/.cursor/skills/supabase-postgres-best-practices/references/conn-prepared-statements.md +46 -0
- package/.cursor/skills/supabase-postgres-best-practices/references/data-batch-inserts.md +54 -0
- package/.cursor/skills/supabase-postgres-best-practices/references/data-n-plus-one.md +53 -0
- package/.cursor/skills/supabase-postgres-best-practices/references/data-pagination.md +50 -0
- package/.cursor/skills/supabase-postgres-best-practices/references/data-upsert.md +50 -0
- package/.cursor/skills/supabase-postgres-best-practices/references/lock-advisory.md +56 -0
- package/.cursor/skills/supabase-postgres-best-practices/references/lock-deadlock-prevention.md +68 -0
- package/.cursor/skills/supabase-postgres-best-practices/references/lock-short-transactions.md +50 -0
- package/.cursor/skills/supabase-postgres-best-practices/references/lock-skip-locked.md +54 -0
- package/.cursor/skills/supabase-postgres-best-practices/references/monitor-explain-analyze.md +45 -0
- package/.cursor/skills/supabase-postgres-best-practices/references/monitor-pg-stat-statements.md +55 -0
- package/.cursor/skills/supabase-postgres-best-practices/references/monitor-vacuum-analyze.md +55 -0
- package/.cursor/skills/supabase-postgres-best-practices/references/query-composite-indexes.md +44 -0
- package/.cursor/skills/supabase-postgres-best-practices/references/query-covering-indexes.md +40 -0
- package/.cursor/skills/supabase-postgres-best-practices/references/query-index-types.md +48 -0
- package/.cursor/skills/supabase-postgres-best-practices/references/query-missing-indexes.md +43 -0
- package/.cursor/skills/supabase-postgres-best-practices/references/query-partial-indexes.md +45 -0
- package/.cursor/skills/supabase-postgres-best-practices/references/schema-constraints.md +80 -0
- package/.cursor/skills/supabase-postgres-best-practices/references/schema-data-types.md +46 -0
- package/.cursor/skills/supabase-postgres-best-practices/references/schema-foreign-key-indexes.md +59 -0
- package/.cursor/skills/supabase-postgres-best-practices/references/schema-lowercase-identifiers.md +55 -0
- package/.cursor/skills/supabase-postgres-best-practices/references/schema-partitioning.md +55 -0
- package/.cursor/skills/supabase-postgres-best-practices/references/schema-primary-keys.md +61 -0
- package/.cursor/skills/supabase-postgres-best-practices/references/security-privileges.md +54 -0
- package/.cursor/skills/supabase-postgres-best-practices/references/security-rls-basics.md +50 -0
- package/.cursor/skills/supabase-postgres-best-practices/references/security-rls-performance.md +63 -0
- package/.kiro/KIRO.md +6 -3
- package/.kiro/agents/business-analyst.md +380 -0
- package/.kiro/references/supabase.md +55 -0
- package/.kiro/settings/mcp.json +4 -0
- package/.kiro/skills/supabase/SKILL.md +135 -0
- package/.kiro/skills/supabase/UPSTREAM.md +16 -0
- package/.kiro/skills/supabase/assets/feedback-issue-template.md +17 -0
- package/.kiro/skills/supabase/references/skill-feedback.md +17 -0
- package/.kiro/skills/supabase-postgres-best-practices/SKILL.md +64 -0
- package/.kiro/skills/supabase-postgres-best-practices/UPSTREAM.md +16 -0
- package/.kiro/skills/supabase-postgres-best-practices/references/_contributing.md +170 -0
- package/.kiro/skills/supabase-postgres-best-practices/references/_sections.md +39 -0
- package/.kiro/skills/supabase-postgres-best-practices/references/_template.md +34 -0
- package/.kiro/skills/supabase-postgres-best-practices/references/advanced-full-text-search.md +55 -0
- package/.kiro/skills/supabase-postgres-best-practices/references/advanced-jsonb-indexing.md +49 -0
- package/.kiro/skills/supabase-postgres-best-practices/references/conn-idle-timeout.md +46 -0
- package/.kiro/skills/supabase-postgres-best-practices/references/conn-limits.md +44 -0
- package/.kiro/skills/supabase-postgres-best-practices/references/conn-pooling.md +41 -0
- package/.kiro/skills/supabase-postgres-best-practices/references/conn-prepared-statements.md +46 -0
- package/.kiro/skills/supabase-postgres-best-practices/references/data-batch-inserts.md +54 -0
- package/.kiro/skills/supabase-postgres-best-practices/references/data-n-plus-one.md +53 -0
- package/.kiro/skills/supabase-postgres-best-practices/references/data-pagination.md +50 -0
- package/.kiro/skills/supabase-postgres-best-practices/references/data-upsert.md +50 -0
- package/.kiro/skills/supabase-postgres-best-practices/references/lock-advisory.md +56 -0
- package/.kiro/skills/supabase-postgres-best-practices/references/lock-deadlock-prevention.md +68 -0
- package/.kiro/skills/supabase-postgres-best-practices/references/lock-short-transactions.md +50 -0
- package/.kiro/skills/supabase-postgres-best-practices/references/lock-skip-locked.md +54 -0
- package/.kiro/skills/supabase-postgres-best-practices/references/monitor-explain-analyze.md +45 -0
- package/.kiro/skills/supabase-postgres-best-practices/references/monitor-pg-stat-statements.md +55 -0
- package/.kiro/skills/supabase-postgres-best-practices/references/monitor-vacuum-analyze.md +55 -0
- package/.kiro/skills/supabase-postgres-best-practices/references/query-composite-indexes.md +44 -0
- package/.kiro/skills/supabase-postgres-best-practices/references/query-covering-indexes.md +40 -0
- package/.kiro/skills/supabase-postgres-best-practices/references/query-index-types.md +48 -0
- package/.kiro/skills/supabase-postgres-best-practices/references/query-missing-indexes.md +43 -0
- package/.kiro/skills/supabase-postgres-best-practices/references/query-partial-indexes.md +45 -0
- package/.kiro/skills/supabase-postgres-best-practices/references/schema-constraints.md +80 -0
- package/.kiro/skills/supabase-postgres-best-practices/references/schema-data-types.md +46 -0
- package/.kiro/skills/supabase-postgres-best-practices/references/schema-foreign-key-indexes.md +59 -0
- package/.kiro/skills/supabase-postgres-best-practices/references/schema-lowercase-identifiers.md +55 -0
- package/.kiro/skills/supabase-postgres-best-practices/references/schema-partitioning.md +55 -0
- package/.kiro/skills/supabase-postgres-best-practices/references/schema-primary-keys.md +61 -0
- package/.kiro/skills/supabase-postgres-best-practices/references/security-privileges.md +54 -0
- package/.kiro/skills/supabase-postgres-best-practices/references/security-rls-basics.md +50 -0
- package/.kiro/skills/supabase-postgres-best-practices/references/security-rls-performance.md +63 -0
- package/.kiro/steering/database.md +2 -2
- package/.kiro/steering/kiro-overview.md +1 -1
- package/.kiro/steering/tech-stack.md +2 -1
- package/AGENTS.md +20 -1
- package/README.md +26 -13
- package/bin/class-ai-agent.cjs +8 -2
- package/package.json +6 -2
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Partition Large Tables for Better Performance
|
|
3
|
+
impact: MEDIUM-HIGH
|
|
4
|
+
impactDescription: 5-20x faster queries and maintenance on large tables
|
|
5
|
+
tags: partitioning, large-tables, time-series, performance
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Partition Large Tables for Better Performance
|
|
9
|
+
|
|
10
|
+
Partitioning splits a large table into smaller pieces, improving query performance and maintenance operations.
|
|
11
|
+
|
|
12
|
+
**Incorrect (single large table):**
|
|
13
|
+
|
|
14
|
+
```sql
|
|
15
|
+
create table events (
|
|
16
|
+
id bigint generated always as identity,
|
|
17
|
+
created_at timestamptz,
|
|
18
|
+
data jsonb
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
-- 500M rows, queries scan everything
|
|
22
|
+
select * from events where created_at > '2024-01-01'; -- Slow
|
|
23
|
+
vacuum events; -- Takes hours, locks table
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
**Correct (partitioned by time range):**
|
|
27
|
+
|
|
28
|
+
```sql
|
|
29
|
+
create table events (
|
|
30
|
+
id bigint generated always as identity,
|
|
31
|
+
created_at timestamptz not null,
|
|
32
|
+
data jsonb
|
|
33
|
+
) partition by range (created_at);
|
|
34
|
+
|
|
35
|
+
-- Create partitions for each month
|
|
36
|
+
create table events_2024_01 partition of events
|
|
37
|
+
for values from ('2024-01-01') to ('2024-02-01');
|
|
38
|
+
|
|
39
|
+
create table events_2024_02 partition of events
|
|
40
|
+
for values from ('2024-02-01') to ('2024-03-01');
|
|
41
|
+
|
|
42
|
+
-- Queries only scan relevant partitions
|
|
43
|
+
select * from events where created_at > '2024-01-15'; -- Only scans events_2024_01+
|
|
44
|
+
|
|
45
|
+
-- Drop old data instantly
|
|
46
|
+
drop table events_2023_01; -- Instant vs DELETE taking hours
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
When to partition:
|
|
50
|
+
|
|
51
|
+
- Tables > 100M rows
|
|
52
|
+
- Time-series data with date-based queries
|
|
53
|
+
- Need to efficiently drop old data
|
|
54
|
+
|
|
55
|
+
Reference: [Table Partitioning](https://www.postgresql.org/docs/current/ddl-partitioning.html)
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Select Optimal Primary Key Strategy
|
|
3
|
+
impact: HIGH
|
|
4
|
+
impactDescription: Better index locality, reduced fragmentation
|
|
5
|
+
tags: primary-key, identity, uuid, serial, schema
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Select Optimal Primary Key Strategy
|
|
9
|
+
|
|
10
|
+
Primary key choice affects insert performance, index size, and replication
|
|
11
|
+
efficiency.
|
|
12
|
+
|
|
13
|
+
**Incorrect (problematic PK choices):**
|
|
14
|
+
|
|
15
|
+
```sql
|
|
16
|
+
-- identity is the SQL-standard approach
|
|
17
|
+
create table users (
|
|
18
|
+
id serial primary key -- Works, but IDENTITY is recommended
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
-- Random UUIDs (v4) cause index fragmentation
|
|
22
|
+
create table orders (
|
|
23
|
+
id uuid default gen_random_uuid() primary key -- UUIDv4 = random = scattered inserts
|
|
24
|
+
);
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
**Correct (optimal PK strategies):**
|
|
28
|
+
|
|
29
|
+
```sql
|
|
30
|
+
-- Use IDENTITY for sequential IDs (SQL-standard, best for most cases)
|
|
31
|
+
create table users (
|
|
32
|
+
id bigint generated always as identity primary key
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
-- For distributed systems needing UUIDs, use UUIDv7 (time-ordered)
|
|
36
|
+
-- Requires pg_uuidv7 extension: create extension pg_uuidv7;
|
|
37
|
+
create table orders (
|
|
38
|
+
id uuid default uuid_generate_v7() primary key -- Time-ordered, no fragmentation
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
-- Alternative: time-prefixed IDs for sortable, distributed IDs (no extension needed)
|
|
42
|
+
create table events (
|
|
43
|
+
id text default concat(
|
|
44
|
+
to_char(now() at time zone 'utc', 'YYYYMMDDHH24MISSMS'),
|
|
45
|
+
gen_random_uuid()::text
|
|
46
|
+
) primary key
|
|
47
|
+
);
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Guidelines:
|
|
51
|
+
|
|
52
|
+
- Single database: `bigint identity` (sequential, 8 bytes, SQL-standard)
|
|
53
|
+
- Distributed/exposed IDs: UUIDv7 (requires pg_uuidv7) or ULID (time-ordered, no
|
|
54
|
+
fragmentation)
|
|
55
|
+
- `serial` works but `identity` is SQL-standard and preferred for new
|
|
56
|
+
applications
|
|
57
|
+
- Avoid random UUIDs (v4) as primary keys on large tables (causes index
|
|
58
|
+
fragmentation)
|
|
59
|
+
|
|
60
|
+
Reference:
|
|
61
|
+
[Identity Columns](https://www.postgresql.org/docs/current/sql-createtable.html#SQL-CREATETABLE-PARMS-GENERATED-IDENTITY)
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Apply Principle of Least Privilege
|
|
3
|
+
impact: MEDIUM
|
|
4
|
+
impactDescription: Reduced attack surface, better audit trail
|
|
5
|
+
tags: privileges, security, roles, permissions
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Apply Principle of Least Privilege
|
|
9
|
+
|
|
10
|
+
Grant only the minimum permissions required. Never use superuser for application queries.
|
|
11
|
+
|
|
12
|
+
**Incorrect (overly broad permissions):**
|
|
13
|
+
|
|
14
|
+
```sql
|
|
15
|
+
-- Application uses superuser connection
|
|
16
|
+
-- Or grants ALL to application role
|
|
17
|
+
grant all privileges on all tables in schema public to app_user;
|
|
18
|
+
grant all privileges on all sequences in schema public to app_user;
|
|
19
|
+
|
|
20
|
+
-- Any SQL injection becomes catastrophic
|
|
21
|
+
-- drop table users; cascades to everything
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
**Correct (minimal, specific grants):**
|
|
25
|
+
|
|
26
|
+
```sql
|
|
27
|
+
-- Create role with no default privileges
|
|
28
|
+
create role app_readonly nologin;
|
|
29
|
+
|
|
30
|
+
-- Grant only SELECT on specific tables
|
|
31
|
+
grant usage on schema public to app_readonly;
|
|
32
|
+
grant select on public.products, public.categories to app_readonly;
|
|
33
|
+
|
|
34
|
+
-- Create role for writes with limited scope
|
|
35
|
+
create role app_writer nologin;
|
|
36
|
+
grant usage on schema public to app_writer;
|
|
37
|
+
grant select, insert, update on public.orders to app_writer;
|
|
38
|
+
grant usage on sequence orders_id_seq to app_writer;
|
|
39
|
+
-- No DELETE permission
|
|
40
|
+
|
|
41
|
+
-- Login role inherits from these
|
|
42
|
+
create role app_user login password 'xxx';
|
|
43
|
+
grant app_writer to app_user;
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Revoke public defaults:
|
|
47
|
+
|
|
48
|
+
```sql
|
|
49
|
+
-- Revoke default public access
|
|
50
|
+
revoke all on schema public from public;
|
|
51
|
+
revoke all on all tables in schema public from public;
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Reference: [Roles and Privileges](https://supabase.com/blog/postgres-roles-and-privileges)
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Enable Row Level Security for Multi-Tenant Data
|
|
3
|
+
impact: CRITICAL
|
|
4
|
+
impactDescription: Database-enforced tenant isolation, prevent data leaks
|
|
5
|
+
tags: rls, row-level-security, multi-tenant, security
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Enable Row Level Security for Multi-Tenant Data
|
|
9
|
+
|
|
10
|
+
Row Level Security (RLS) enforces data access at the database level, ensuring users only see their own data.
|
|
11
|
+
|
|
12
|
+
**Incorrect (application-level filtering only):**
|
|
13
|
+
|
|
14
|
+
```sql
|
|
15
|
+
-- Relying only on application to filter
|
|
16
|
+
select * from orders where user_id = $current_user_id;
|
|
17
|
+
|
|
18
|
+
-- Bug or bypass means all data is exposed!
|
|
19
|
+
select * from orders; -- Returns ALL orders
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
**Correct (database-enforced RLS):**
|
|
23
|
+
|
|
24
|
+
```sql
|
|
25
|
+
-- Enable RLS on the table
|
|
26
|
+
alter table orders enable row level security;
|
|
27
|
+
|
|
28
|
+
-- Create policy for users to see only their orders
|
|
29
|
+
create policy orders_user_policy on orders
|
|
30
|
+
for all
|
|
31
|
+
using (user_id = current_setting('app.current_user_id')::bigint);
|
|
32
|
+
|
|
33
|
+
-- Force RLS even for table owners
|
|
34
|
+
alter table orders force row level security;
|
|
35
|
+
|
|
36
|
+
-- Set user context and query
|
|
37
|
+
set app.current_user_id = '123';
|
|
38
|
+
select * from orders; -- Only returns orders for user 123
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Policy for authenticated role:
|
|
42
|
+
|
|
43
|
+
```sql
|
|
44
|
+
create policy orders_user_policy on orders
|
|
45
|
+
for all
|
|
46
|
+
to authenticated
|
|
47
|
+
using (user_id = auth.uid());
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Reference: [Row Level Security](https://supabase.com/docs/guides/database/postgres/row-level-security)
|
package/.claude/skills/supabase-postgres-best-practices/references/security-rls-performance.md
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Optimize RLS Policies for Performance
|
|
3
|
+
impact: HIGH
|
|
4
|
+
impactDescription: 5-10x faster RLS queries with proper patterns
|
|
5
|
+
tags: rls, performance, security, optimization
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Optimize RLS Policies for Performance
|
|
9
|
+
|
|
10
|
+
Poorly written RLS policies can cause severe performance issues. Use subqueries and indexes strategically.
|
|
11
|
+
|
|
12
|
+
**Incorrect (function called for every row):**
|
|
13
|
+
|
|
14
|
+
```sql
|
|
15
|
+
create policy orders_policy on orders
|
|
16
|
+
using (auth.uid() = user_id); -- auth.uid() called per row!
|
|
17
|
+
|
|
18
|
+
-- With 1M rows, auth.uid() is called 1M times
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
**Correct (wrap functions in SELECT):**
|
|
22
|
+
|
|
23
|
+
```sql
|
|
24
|
+
create policy orders_policy on orders
|
|
25
|
+
using ((select auth.uid()) = user_id); -- Called once, cached
|
|
26
|
+
|
|
27
|
+
-- 100x+ faster on large tables
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Use security definer functions for complex checks:
|
|
31
|
+
|
|
32
|
+
`SECURITY DEFINER` functions run with the creator's privileges and bypass RLS on any tables they touch — which is what makes them useful for internal lookups, but also what makes them dangerous if misused. Always include an explicit `auth.uid()` check inside the function body, keep them in a non-exposed schema, and revoke `EXECUTE` from any role that shouldn't call them directly.
|
|
33
|
+
|
|
34
|
+
```sql
|
|
35
|
+
-- Create helper function in a private schema
|
|
36
|
+
create or replace function private.is_team_member(team_id bigint)
|
|
37
|
+
returns boolean
|
|
38
|
+
language sql
|
|
39
|
+
security definer
|
|
40
|
+
set search_path = ''
|
|
41
|
+
as $$
|
|
42
|
+
select exists (
|
|
43
|
+
select 1 from public.team_members
|
|
44
|
+
-- always check the calling user's identity inside the function
|
|
45
|
+
where team_id = $1 and user_id = (select auth.uid())
|
|
46
|
+
);
|
|
47
|
+
$$;
|
|
48
|
+
|
|
49
|
+
-- Revoke direct execution from public roles
|
|
50
|
+
revoke execute on function private.is_team_member(bigint) from PUBLIC, anon, authenticated, service_role;
|
|
51
|
+
|
|
52
|
+
-- Use in policy (indexed lookup, not per-row check)
|
|
53
|
+
create policy team_orders_policy on orders
|
|
54
|
+
using ((select private.is_team_member(team_id)));
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Always add indexes on columns used in RLS policies:
|
|
58
|
+
|
|
59
|
+
```sql
|
|
60
|
+
create index orders_user_id_idx on orders (user_id);
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Reference: [RLS Performance](https://supabase.com/docs/guides/database/postgres/row-level-security#rls-performance-recommendations)
|
|
@@ -1,96 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
name: ui-ux-pro-max
|
|
3
|
-
description: "UI/UX design intelligence. 67 styles, 96 palettes, 57 font pairings, 25 charts, 13 stacks (React, Next.js, Vue, Svelte, SwiftUI, React Native, Flutter, Tailwind, shadcn/ui). Actions: plan, build, create, design, implement, review, fix, improve, optimize, enhance, refactor, check UI/UX code. Projects: website, landing page, dashboard, admin panel, e-commerce, SaaS, portfolio, blog, mobile app, .html, .tsx, .vue, .svelte. Elements: button, modal, navbar, sidebar, card, table, form, chart. Styles: glassmorphism, claymorphism, minimalism, brutalism, neumorphism, bento grid, dark mode, responsive, skeuomorphism, flat design. Topics: color palette, accessibility, animation, layout, typography, font pairing, spacing, hover, shadow, gradient. Integrations: shadcn/ui MCP for component search and examples."
|
|
4
|
-
---
|
|
5
|
-
# UI/UX Pro Max - Design Intelligence
|
|
1
|
+
# ui-ux-pro-max
|
|
6
2
|
|
|
7
3
|
Comprehensive design guide for web and mobile applications. Contains 67 styles, 96 color palettes, 57 font pairings, 99 UX guidelines, and 25 chart types across 13 technology stacks. Searchable database with priority-based recommendations.
|
|
8
4
|
|
|
9
|
-
## When to Apply
|
|
10
|
-
|
|
11
|
-
Reference these guidelines when:
|
|
12
|
-
- Designing new UI components or pages
|
|
13
|
-
- Choosing color palettes and typography
|
|
14
|
-
- Reviewing code for UX issues
|
|
15
|
-
- Building landing pages or dashboards
|
|
16
|
-
- Implementing accessibility requirements
|
|
17
|
-
|
|
18
|
-
## Rule Categories by Priority
|
|
19
|
-
|
|
20
|
-
| Priority | Category | Impact | Domain |
|
|
21
|
-
|----------|----------|--------|--------|
|
|
22
|
-
| 1 | Accessibility | CRITICAL | `ux` |
|
|
23
|
-
| 2 | Touch & Interaction | CRITICAL | `ux` |
|
|
24
|
-
| 3 | Performance | HIGH | `ux` |
|
|
25
|
-
| 4 | Layout & Responsive | HIGH | `ux` |
|
|
26
|
-
| 5 | Typography & Color | MEDIUM | `typography`, `color` |
|
|
27
|
-
| 6 | Animation | MEDIUM | `ux` |
|
|
28
|
-
| 7 | Style Selection | MEDIUM | `style`, `product` |
|
|
29
|
-
| 8 | Charts & Data | LOW | `chart` |
|
|
30
|
-
|
|
31
|
-
## Quick Reference
|
|
32
|
-
|
|
33
|
-
### 1. Accessibility (CRITICAL)
|
|
34
|
-
|
|
35
|
-
- `color-contrast` - Minimum 4.5:1 ratio for normal text
|
|
36
|
-
- `focus-states` - Visible focus rings on interactive elements
|
|
37
|
-
- `alt-text` - Descriptive alt text for meaningful images
|
|
38
|
-
- `aria-labels` - aria-label for icon-only buttons
|
|
39
|
-
- `keyboard-nav` - Tab order matches visual order
|
|
40
|
-
- `form-labels` - Use label with for attribute
|
|
41
|
-
|
|
42
|
-
### 2. Touch & Interaction (CRITICAL)
|
|
43
|
-
|
|
44
|
-
- `touch-target-size` - Minimum 44x44px touch targets
|
|
45
|
-
- `hover-vs-tap` - Use click/tap for primary interactions
|
|
46
|
-
- `loading-buttons` - Disable button during async operations
|
|
47
|
-
- `error-feedback` - Clear error messages near problem
|
|
48
|
-
- `cursor-pointer` - Add cursor-pointer to clickable elements
|
|
49
|
-
|
|
50
|
-
### 3. Performance (HIGH)
|
|
51
|
-
|
|
52
|
-
- `image-optimization` - Use WebP, srcset, lazy loading
|
|
53
|
-
- `reduced-motion` - Check prefers-reduced-motion
|
|
54
|
-
- `content-jumping` - Reserve space for async content
|
|
55
|
-
|
|
56
|
-
### 4. Layout & Responsive (HIGH)
|
|
57
|
-
|
|
58
|
-
- `viewport-meta` - width=device-width initial-scale=1
|
|
59
|
-
- `readable-font-size` - Minimum 16px body text on mobile
|
|
60
|
-
- `horizontal-scroll` - Ensure content fits viewport width
|
|
61
|
-
- `z-index-management` - Define z-index scale (10, 20, 30, 50)
|
|
62
|
-
|
|
63
|
-
### 5. Typography & Color (MEDIUM)
|
|
64
|
-
|
|
65
|
-
- `line-height` - Use 1.5-1.75 for body text
|
|
66
|
-
- `line-length` - Limit to 65-75 characters per line
|
|
67
|
-
- `font-pairing` - Match heading/body font personalities
|
|
68
|
-
|
|
69
|
-
### 6. Animation (MEDIUM)
|
|
70
|
-
|
|
71
|
-
- `duration-timing` - Use 150-300ms for micro-interactions
|
|
72
|
-
- `transform-performance` - Use transform/opacity, not width/height
|
|
73
|
-
- `loading-states` - Skeleton screens or spinners
|
|
74
|
-
|
|
75
|
-
### 7. Style Selection (MEDIUM)
|
|
76
|
-
|
|
77
|
-
- `style-match` - Match style to product type
|
|
78
|
-
- `consistency` - Use same style across all pages
|
|
79
|
-
- `no-emoji-icons` - Use SVG icons, not emojis
|
|
80
|
-
|
|
81
|
-
### 8. Charts & Data (LOW)
|
|
82
|
-
|
|
83
|
-
- `chart-type` - Match chart type to data type
|
|
84
|
-
- `color-guidance` - Use accessible color palettes
|
|
85
|
-
- `data-table` - Provide table alternative for accessibility
|
|
86
|
-
|
|
87
|
-
## How to Use
|
|
88
|
-
|
|
89
|
-
Search specific domains using the CLI tool below.
|
|
90
|
-
|
|
91
|
-
---
|
|
92
|
-
|
|
93
|
-
|
|
94
5
|
## Prerequisites
|
|
95
6
|
|
|
96
7
|
Check if Python is installed:
|
package/.cursor/CURSOR.md
CHANGED
|
@@ -88,7 +88,7 @@ Instructions live in **`.cursor/agents/`**. Invoke by **@ mentioning** the file
|
|
|
88
88
|
|------|------|
|
|
89
89
|
| Frontend, backend, architecture | `frontend.md`, `backend.md`, `systems-architect.md` |
|
|
90
90
|
| Quality | `code-reviewer.md`, `test-engineer.md`, `qa.md`, `security-auditor.md` |
|
|
91
|
-
| Product & content | `project-manager.md`, `ui-ux-designer.md`, `copywriter-seo.md` |
|
|
91
|
+
| Product & content | `business-analyst.md`, `project-manager.md`, `ui-ux-designer.md`, `copywriter-seo.md` |
|
|
92
92
|
|
|
93
93
|
---
|
|
94
94
|
|
|
@@ -104,6 +104,8 @@ Reusable playbooks: **`.cursor/skills/*/SKILL.md`** (and related `.md` files whe
|
|
|
104
104
|
| `deploy` | Deployment pipeline |
|
|
105
105
|
| `security-review` | Security audit |
|
|
106
106
|
| `agent-continuity` | Cross-tool session handoff via `.agent/SESSION.md` |
|
|
107
|
+
| `supabase` | Supabase products, Auth, CLI, MCP, migrations, RLS |
|
|
108
|
+
| `supabase-postgres-best-practices` | Postgres performance, indexes, RLS tuning |
|
|
107
109
|
|
|
108
110
|
---
|
|
109
111
|
|
|
@@ -119,6 +121,7 @@ Reusable playbooks: **`.cursor/skills/*/SKILL.md`** (and related `.md` files whe
|
|
|
119
121
|
| `accessibility-checklist.md` | WCAG-oriented checks |
|
|
120
122
|
| `codegraph.md` | CodeGraph install and Claude Code setup |
|
|
121
123
|
| `agent-continuity.md` | Session handoff and `/resume` / `/handoff` |
|
|
124
|
+
| `supabase.md` | Supabase skills, MCP OAuth, secrets |
|
|
122
125
|
|
|
123
126
|
---
|
|
124
127
|
|