class-ai-agent 1.2.3 → 1.4.0

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.
Files changed (242) hide show
  1. package/.agent/README.md +33 -0
  2. package/.agent/SESSION.md +54 -0
  3. package/.agent/SESSION.template.md +46 -0
  4. package/.claude/CLAUDE.md +24 -6
  5. package/.claude/commands/build.md +5 -4
  6. package/.claude/commands/debug.md +2 -1
  7. package/.claude/commands/handoff.md +94 -0
  8. package/.claude/commands/plan.md +1 -0
  9. package/.claude/commands/publish-npm.md +119 -0
  10. package/.claude/commands/resume.md +107 -0
  11. package/.claude/commands/spec.md +2 -1
  12. package/.claude/references/agent-continuity.md +42 -0
  13. package/.claude/references/codegraph.md +50 -0
  14. package/.claude/references/supabase.md +55 -0
  15. package/.claude/rules/agent-continuity.md +39 -0
  16. package/.claude/rules/tech-stack.md +2 -1
  17. package/.claude/skills/agent-continuity/SKILL.md +70 -0
  18. package/.claude/skills/supabase/SKILL.md +135 -0
  19. package/.claude/skills/supabase/UPSTREAM.md +16 -0
  20. package/.claude/skills/supabase/assets/feedback-issue-template.md +17 -0
  21. package/.claude/skills/supabase/references/skill-feedback.md +17 -0
  22. package/.claude/skills/supabase-postgres-best-practices/SKILL.md +64 -0
  23. package/.claude/skills/supabase-postgres-best-practices/UPSTREAM.md +16 -0
  24. package/.claude/skills/supabase-postgres-best-practices/references/_contributing.md +170 -0
  25. package/.claude/skills/supabase-postgres-best-practices/references/_sections.md +39 -0
  26. package/.claude/skills/supabase-postgres-best-practices/references/_template.md +34 -0
  27. package/.claude/skills/supabase-postgres-best-practices/references/advanced-full-text-search.md +55 -0
  28. package/.claude/skills/supabase-postgres-best-practices/references/advanced-jsonb-indexing.md +49 -0
  29. package/.claude/skills/supabase-postgres-best-practices/references/conn-idle-timeout.md +46 -0
  30. package/.claude/skills/supabase-postgres-best-practices/references/conn-limits.md +44 -0
  31. package/.claude/skills/supabase-postgres-best-practices/references/conn-pooling.md +41 -0
  32. package/.claude/skills/supabase-postgres-best-practices/references/conn-prepared-statements.md +46 -0
  33. package/.claude/skills/supabase-postgres-best-practices/references/data-batch-inserts.md +54 -0
  34. package/.claude/skills/supabase-postgres-best-practices/references/data-n-plus-one.md +53 -0
  35. package/.claude/skills/supabase-postgres-best-practices/references/data-pagination.md +50 -0
  36. package/.claude/skills/supabase-postgres-best-practices/references/data-upsert.md +50 -0
  37. package/.claude/skills/supabase-postgres-best-practices/references/lock-advisory.md +56 -0
  38. package/.claude/skills/supabase-postgres-best-practices/references/lock-deadlock-prevention.md +68 -0
  39. package/.claude/skills/supabase-postgres-best-practices/references/lock-short-transactions.md +50 -0
  40. package/.claude/skills/supabase-postgres-best-practices/references/lock-skip-locked.md +54 -0
  41. package/.claude/skills/supabase-postgres-best-practices/references/monitor-explain-analyze.md +45 -0
  42. package/.claude/skills/supabase-postgres-best-practices/references/monitor-pg-stat-statements.md +55 -0
  43. package/.claude/skills/supabase-postgres-best-practices/references/monitor-vacuum-analyze.md +55 -0
  44. package/.claude/skills/supabase-postgres-best-practices/references/query-composite-indexes.md +44 -0
  45. package/.claude/skills/supabase-postgres-best-practices/references/query-covering-indexes.md +40 -0
  46. package/.claude/skills/supabase-postgres-best-practices/references/query-index-types.md +48 -0
  47. package/.claude/skills/supabase-postgres-best-practices/references/query-missing-indexes.md +43 -0
  48. package/.claude/skills/supabase-postgres-best-practices/references/query-partial-indexes.md +45 -0
  49. package/.claude/skills/supabase-postgres-best-practices/references/schema-constraints.md +80 -0
  50. package/.claude/skills/supabase-postgres-best-practices/references/schema-data-types.md +46 -0
  51. package/.claude/skills/supabase-postgres-best-practices/references/schema-foreign-key-indexes.md +59 -0
  52. package/.claude/skills/supabase-postgres-best-practices/references/schema-lowercase-identifiers.md +55 -0
  53. package/.claude/skills/supabase-postgres-best-practices/references/schema-partitioning.md +55 -0
  54. package/.claude/skills/supabase-postgres-best-practices/references/schema-primary-keys.md +61 -0
  55. package/.claude/skills/supabase-postgres-best-practices/references/security-privileges.md +54 -0
  56. package/.claude/skills/supabase-postgres-best-practices/references/security-rls-basics.md +50 -0
  57. package/.claude/skills/supabase-postgres-best-practices/references/security-rls-performance.md +63 -0
  58. package/.cursor/CURSOR.md +40 -5
  59. package/.cursor/commands/build.md +5 -4
  60. package/.cursor/commands/debug.md +2 -1
  61. package/.cursor/commands/handoff.md +94 -0
  62. package/.cursor/commands/plan.md +1 -0
  63. package/.cursor/commands/publish-npm.md +119 -0
  64. package/.cursor/commands/resume.md +107 -0
  65. package/.cursor/commands/spec.md +2 -1
  66. package/.cursor/mcp.json +19 -0
  67. package/.cursor/references/agent-continuity.md +42 -0
  68. package/.cursor/references/codegraph.md +87 -0
  69. package/.cursor/references/supabase.md +55 -0
  70. package/.cursor/rules/agent-continuity.mdc +44 -0
  71. package/.cursor/rules/codegraph.mdc +47 -0
  72. package/.cursor/rules/cursor-overview.mdc +10 -3
  73. package/.cursor/rules/tech-stack.mdc +2 -1
  74. package/.cursor/settings.json +6 -1
  75. package/.cursor/skills/agent-continuity/SKILL.md +70 -0
  76. package/.cursor/skills/supabase/SKILL.md +135 -0
  77. package/.cursor/skills/supabase/UPSTREAM.md +16 -0
  78. package/.cursor/skills/supabase/assets/feedback-issue-template.md +17 -0
  79. package/.cursor/skills/supabase/references/skill-feedback.md +17 -0
  80. package/.cursor/skills/supabase-postgres-best-practices/SKILL.md +64 -0
  81. package/.cursor/skills/supabase-postgres-best-practices/UPSTREAM.md +16 -0
  82. package/.cursor/skills/supabase-postgres-best-practices/references/_contributing.md +170 -0
  83. package/.cursor/skills/supabase-postgres-best-practices/references/_sections.md +39 -0
  84. package/.cursor/skills/supabase-postgres-best-practices/references/_template.md +34 -0
  85. package/.cursor/skills/supabase-postgres-best-practices/references/advanced-full-text-search.md +55 -0
  86. package/.cursor/skills/supabase-postgres-best-practices/references/advanced-jsonb-indexing.md +49 -0
  87. package/.cursor/skills/supabase-postgres-best-practices/references/conn-idle-timeout.md +46 -0
  88. package/.cursor/skills/supabase-postgres-best-practices/references/conn-limits.md +44 -0
  89. package/.cursor/skills/supabase-postgres-best-practices/references/conn-pooling.md +41 -0
  90. package/.cursor/skills/supabase-postgres-best-practices/references/conn-prepared-statements.md +46 -0
  91. package/.cursor/skills/supabase-postgres-best-practices/references/data-batch-inserts.md +54 -0
  92. package/.cursor/skills/supabase-postgres-best-practices/references/data-n-plus-one.md +53 -0
  93. package/.cursor/skills/supabase-postgres-best-practices/references/data-pagination.md +50 -0
  94. package/.cursor/skills/supabase-postgres-best-practices/references/data-upsert.md +50 -0
  95. package/.cursor/skills/supabase-postgres-best-practices/references/lock-advisory.md +56 -0
  96. package/.cursor/skills/supabase-postgres-best-practices/references/lock-deadlock-prevention.md +68 -0
  97. package/.cursor/skills/supabase-postgres-best-practices/references/lock-short-transactions.md +50 -0
  98. package/.cursor/skills/supabase-postgres-best-practices/references/lock-skip-locked.md +54 -0
  99. package/.cursor/skills/supabase-postgres-best-practices/references/monitor-explain-analyze.md +45 -0
  100. package/.cursor/skills/supabase-postgres-best-practices/references/monitor-pg-stat-statements.md +55 -0
  101. package/.cursor/skills/supabase-postgres-best-practices/references/monitor-vacuum-analyze.md +55 -0
  102. package/.cursor/skills/supabase-postgres-best-practices/references/query-composite-indexes.md +44 -0
  103. package/.cursor/skills/supabase-postgres-best-practices/references/query-covering-indexes.md +40 -0
  104. package/.cursor/skills/supabase-postgres-best-practices/references/query-index-types.md +48 -0
  105. package/.cursor/skills/supabase-postgres-best-practices/references/query-missing-indexes.md +43 -0
  106. package/.cursor/skills/supabase-postgres-best-practices/references/query-partial-indexes.md +45 -0
  107. package/.cursor/skills/supabase-postgres-best-practices/references/schema-constraints.md +80 -0
  108. package/.cursor/skills/supabase-postgres-best-practices/references/schema-data-types.md +46 -0
  109. package/.cursor/skills/supabase-postgres-best-practices/references/schema-foreign-key-indexes.md +59 -0
  110. package/.cursor/skills/supabase-postgres-best-practices/references/schema-lowercase-identifiers.md +55 -0
  111. package/.cursor/skills/supabase-postgres-best-practices/references/schema-partitioning.md +55 -0
  112. package/.cursor/skills/supabase-postgres-best-practices/references/schema-primary-keys.md +61 -0
  113. package/.cursor/skills/supabase-postgres-best-practices/references/security-privileges.md +54 -0
  114. package/.cursor/skills/supabase-postgres-best-practices/references/security-rls-basics.md +50 -0
  115. package/.cursor/skills/supabase-postgres-best-practices/references/security-rls-performance.md +63 -0
  116. package/.kiro/KIRO.md +149 -0
  117. package/.kiro/agents/backend.md +395 -0
  118. package/.kiro/agents/code-reviewer.md +110 -0
  119. package/.kiro/agents/copywriter-seo.md +236 -0
  120. package/.kiro/agents/frontend.md +384 -0
  121. package/.kiro/agents/project-manager.md +201 -0
  122. package/.kiro/agents/qa.md +221 -0
  123. package/.kiro/agents/security-auditor.md +143 -0
  124. package/.kiro/agents/systems-architect.md +211 -0
  125. package/.kiro/agents/test-engineer.md +123 -0
  126. package/.kiro/agents/ui-ux-designer.md +210 -0
  127. package/.kiro/commands/build.md +133 -0
  128. package/.kiro/commands/debug.md +243 -0
  129. package/.kiro/commands/deploy.md +40 -0
  130. package/.kiro/commands/fix-issue.md +42 -0
  131. package/.kiro/commands/handoff.md +94 -0
  132. package/.kiro/commands/plan.md +126 -0
  133. package/.kiro/commands/publish-npm.md +119 -0
  134. package/.kiro/commands/resume.md +107 -0
  135. package/.kiro/commands/review.md +50 -0
  136. package/.kiro/commands/simplify.md +222 -0
  137. package/.kiro/commands/spec.md +96 -0
  138. package/.kiro/commands/test.md +214 -0
  139. package/.kiro/references/accessibility-checklist.md +174 -0
  140. package/.kiro/references/agent-continuity.md +42 -0
  141. package/.kiro/references/codegraph.md +86 -0
  142. package/.kiro/references/performance-checklist.md +150 -0
  143. package/.kiro/references/security-checklist.md +94 -0
  144. package/.kiro/references/supabase.md +55 -0
  145. package/.kiro/references/testing-patterns.md +183 -0
  146. package/.kiro/settings/mcp.json +19 -0
  147. package/.kiro/settings.json +8 -0
  148. package/.kiro/skills/agent-continuity/SKILL.md +70 -0
  149. package/.kiro/skills/code-review/SKILL.md +208 -0
  150. package/.kiro/skills/deploy/SKILL.md +68 -0
  151. package/.kiro/skills/deploy/deploy.md +735 -0
  152. package/.kiro/skills/incremental-implementation/SKILL.md +210 -0
  153. package/.kiro/skills/security-review/SKILL.md +71 -0
  154. package/.kiro/skills/supabase/SKILL.md +135 -0
  155. package/.kiro/skills/supabase/UPSTREAM.md +16 -0
  156. package/.kiro/skills/supabase/assets/feedback-issue-template.md +17 -0
  157. package/.kiro/skills/supabase/references/skill-feedback.md +17 -0
  158. package/.kiro/skills/supabase-postgres-best-practices/SKILL.md +64 -0
  159. package/.kiro/skills/supabase-postgres-best-practices/UPSTREAM.md +16 -0
  160. package/.kiro/skills/supabase-postgres-best-practices/references/_contributing.md +170 -0
  161. package/.kiro/skills/supabase-postgres-best-practices/references/_sections.md +39 -0
  162. package/.kiro/skills/supabase-postgres-best-practices/references/_template.md +34 -0
  163. package/.kiro/skills/supabase-postgres-best-practices/references/advanced-full-text-search.md +55 -0
  164. package/.kiro/skills/supabase-postgres-best-practices/references/advanced-jsonb-indexing.md +49 -0
  165. package/.kiro/skills/supabase-postgres-best-practices/references/conn-idle-timeout.md +46 -0
  166. package/.kiro/skills/supabase-postgres-best-practices/references/conn-limits.md +44 -0
  167. package/.kiro/skills/supabase-postgres-best-practices/references/conn-pooling.md +41 -0
  168. package/.kiro/skills/supabase-postgres-best-practices/references/conn-prepared-statements.md +46 -0
  169. package/.kiro/skills/supabase-postgres-best-practices/references/data-batch-inserts.md +54 -0
  170. package/.kiro/skills/supabase-postgres-best-practices/references/data-n-plus-one.md +53 -0
  171. package/.kiro/skills/supabase-postgres-best-practices/references/data-pagination.md +50 -0
  172. package/.kiro/skills/supabase-postgres-best-practices/references/data-upsert.md +50 -0
  173. package/.kiro/skills/supabase-postgres-best-practices/references/lock-advisory.md +56 -0
  174. package/.kiro/skills/supabase-postgres-best-practices/references/lock-deadlock-prevention.md +68 -0
  175. package/.kiro/skills/supabase-postgres-best-practices/references/lock-short-transactions.md +50 -0
  176. package/.kiro/skills/supabase-postgres-best-practices/references/lock-skip-locked.md +54 -0
  177. package/.kiro/skills/supabase-postgres-best-practices/references/monitor-explain-analyze.md +45 -0
  178. package/.kiro/skills/supabase-postgres-best-practices/references/monitor-pg-stat-statements.md +55 -0
  179. package/.kiro/skills/supabase-postgres-best-practices/references/monitor-vacuum-analyze.md +55 -0
  180. package/.kiro/skills/supabase-postgres-best-practices/references/query-composite-indexes.md +44 -0
  181. package/.kiro/skills/supabase-postgres-best-practices/references/query-covering-indexes.md +40 -0
  182. package/.kiro/skills/supabase-postgres-best-practices/references/query-index-types.md +48 -0
  183. package/.kiro/skills/supabase-postgres-best-practices/references/query-missing-indexes.md +43 -0
  184. package/.kiro/skills/supabase-postgres-best-practices/references/query-partial-indexes.md +45 -0
  185. package/.kiro/skills/supabase-postgres-best-practices/references/schema-constraints.md +80 -0
  186. package/.kiro/skills/supabase-postgres-best-practices/references/schema-data-types.md +46 -0
  187. package/.kiro/skills/supabase-postgres-best-practices/references/schema-foreign-key-indexes.md +59 -0
  188. package/.kiro/skills/supabase-postgres-best-practices/references/schema-lowercase-identifiers.md +55 -0
  189. package/.kiro/skills/supabase-postgres-best-practices/references/schema-partitioning.md +55 -0
  190. package/.kiro/skills/supabase-postgres-best-practices/references/schema-primary-keys.md +61 -0
  191. package/.kiro/skills/supabase-postgres-best-practices/references/security-privileges.md +54 -0
  192. package/.kiro/skills/supabase-postgres-best-practices/references/security-rls-basics.md +50 -0
  193. package/.kiro/skills/supabase-postgres-best-practices/references/security-rls-performance.md +63 -0
  194. package/.kiro/skills/tdd/SKILL.md +217 -0
  195. package/.kiro/skills/ui-ux-pro-max/SKILL.md +288 -0
  196. package/.kiro/skills/ui-ux-pro-max/data/charts.csv +26 -0
  197. package/.kiro/skills/ui-ux-pro-max/data/colors.csv +97 -0
  198. package/.kiro/skills/ui-ux-pro-max/data/icons.csv +101 -0
  199. package/.kiro/skills/ui-ux-pro-max/data/landing.csv +31 -0
  200. package/.kiro/skills/ui-ux-pro-max/data/products.csv +97 -0
  201. package/.kiro/skills/ui-ux-pro-max/data/react-performance.csv +45 -0
  202. package/.kiro/skills/ui-ux-pro-max/data/stacks/astro.csv +54 -0
  203. package/.kiro/skills/ui-ux-pro-max/data/stacks/flutter.csv +53 -0
  204. package/.kiro/skills/ui-ux-pro-max/data/stacks/html-tailwind.csv +56 -0
  205. package/.kiro/skills/ui-ux-pro-max/data/stacks/jetpack-compose.csv +53 -0
  206. package/.kiro/skills/ui-ux-pro-max/data/stacks/nextjs.csv +53 -0
  207. package/.kiro/skills/ui-ux-pro-max/data/stacks/nuxt-ui.csv +51 -0
  208. package/.kiro/skills/ui-ux-pro-max/data/stacks/nuxtjs.csv +59 -0
  209. package/.kiro/skills/ui-ux-pro-max/data/stacks/react-native.csv +52 -0
  210. package/.kiro/skills/ui-ux-pro-max/data/stacks/react.csv +54 -0
  211. package/.kiro/skills/ui-ux-pro-max/data/stacks/shadcn.csv +61 -0
  212. package/.kiro/skills/ui-ux-pro-max/data/stacks/svelte.csv +54 -0
  213. package/.kiro/skills/ui-ux-pro-max/data/stacks/swiftui.csv +51 -0
  214. package/.kiro/skills/ui-ux-pro-max/data/stacks/vue.csv +50 -0
  215. package/.kiro/skills/ui-ux-pro-max/data/styles.csv +68 -0
  216. package/.kiro/skills/ui-ux-pro-max/data/typography.csv +58 -0
  217. package/.kiro/skills/ui-ux-pro-max/data/ui-reasoning.csv +101 -0
  218. package/.kiro/skills/ui-ux-pro-max/data/ux-guidelines.csv +100 -0
  219. package/.kiro/skills/ui-ux-pro-max/data/web-interface.csv +31 -0
  220. package/.kiro/skills/ui-ux-pro-max/scripts/core.py +253 -0
  221. package/.kiro/skills/ui-ux-pro-max/scripts/design_system.py +1067 -0
  222. package/.kiro/skills/ui-ux-pro-max/scripts/search.py +114 -0
  223. package/.kiro/steering/agent-continuity.md +44 -0
  224. package/.kiro/steering/api-conventions.md +85 -0
  225. package/.kiro/steering/clean-code.md +211 -0
  226. package/.kiro/steering/code-style.md +92 -0
  227. package/.kiro/steering/codegraph.md +47 -0
  228. package/.kiro/steering/database.md +66 -0
  229. package/.kiro/steering/error-handling.md +98 -0
  230. package/.kiro/steering/git-workflow.md +83 -0
  231. package/.kiro/steering/kiro-overview.md +38 -0
  232. package/.kiro/steering/monitoring.md +317 -0
  233. package/.kiro/steering/naming-conventions.md +266 -0
  234. package/.kiro/steering/project-structure.md +71 -0
  235. package/.kiro/steering/security.md +95 -0
  236. package/.kiro/steering/system-design.md +168 -0
  237. package/.kiro/steering/tech-stack.md +463 -0
  238. package/.kiro/steering/testing.md +110 -0
  239. package/AGENTS.md +13 -7
  240. package/README.md +126 -18
  241. package/bin/class-ai-agent.cjs +171 -11
  242. package/package.json +12 -4
@@ -0,0 +1,55 @@
1
+ ---
2
+ title: Use Lowercase Identifiers for Compatibility
3
+ impact: MEDIUM
4
+ impactDescription: Avoid case-sensitivity bugs with tools, ORMs, and AI assistants
5
+ tags: naming, identifiers, case-sensitivity, schema, conventions
6
+ ---
7
+
8
+ ## Use Lowercase Identifiers for Compatibility
9
+
10
+ PostgreSQL folds unquoted identifiers to lowercase. Quoted mixed-case identifiers require quotes forever and cause issues with tools, ORMs, and AI assistants that may not recognize them.
11
+
12
+ **Incorrect (mixed-case identifiers):**
13
+
14
+ ```sql
15
+ -- Quoted identifiers preserve case but require quotes everywhere
16
+ CREATE TABLE "Users" (
17
+ "userId" bigint PRIMARY KEY,
18
+ "firstName" text,
19
+ "lastName" text
20
+ );
21
+
22
+ -- Must always quote or queries fail
23
+ SELECT "firstName" FROM "Users" WHERE "userId" = 1;
24
+
25
+ -- This fails - Users becomes users without quotes
26
+ SELECT firstName FROM Users;
27
+ -- ERROR: relation "users" does not exist
28
+ ```
29
+
30
+ **Correct (lowercase snake_case):**
31
+
32
+ ```sql
33
+ -- Unquoted lowercase identifiers are portable and tool-friendly
34
+ CREATE TABLE users (
35
+ user_id bigint PRIMARY KEY,
36
+ first_name text,
37
+ last_name text
38
+ );
39
+
40
+ -- Works without quotes, recognized by all tools
41
+ SELECT first_name FROM users WHERE user_id = 1;
42
+ ```
43
+
44
+ Common sources of mixed-case identifiers:
45
+
46
+ ```sql
47
+ -- ORMs often generate quoted camelCase - configure them to use snake_case
48
+ -- Migrations from other databases may preserve original casing
49
+ -- Some GUI tools quote identifiers by default - disable this
50
+
51
+ -- If stuck with mixed-case, create views as a compatibility layer
52
+ CREATE VIEW users AS SELECT "userId" AS user_id, "firstName" AS first_name FROM "Users";
53
+ ```
54
+
55
+ Reference: [Identifiers and Key Words](https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS)
@@ -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)
@@ -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)
package/.cursor/CURSOR.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  ## Overview
4
4
 
5
- This project uses **Cursor** with the same structured workflows, specialized agent personas, and coding standards as the Claude-oriented **`.claude/`** tree. Cursor-specific files live under **`.cursor/`**.
5
+ This project uses **Cursor** with the same structured workflows, specialized agent personas, and coding standards as **`.claude/`** and **`.kiro/`**. Cursor-specific files live under **`.cursor/`**.
6
6
 
7
7
  ---
8
8
 
@@ -30,6 +30,9 @@ Follow this workflow for feature development:
30
30
  | `commands/debug.md` | Systematic diagnosis |
31
31
  | `commands/simplify.md` | Reduce complexity, same behavior |
32
32
  | `commands/fix-issue.md` | Analyze and fix reported issues |
33
+ | `commands/handoff.md` | End session — update `.agent/SESSION.md` for cross-tool continuity |
34
+ | `commands/resume.md` | Start session — load `.agent/SESSION.md` and continue prior work |
35
+ | `commands/publish-npm.md` | **Maintainers:** draft release notes, bump version, update README, publish to npm |
33
36
 
34
37
  **How to use:** Open the markdown file, copy the section you need, or **@ mention** the file in Chat/Composer so the model loads it.
35
38
 
@@ -56,6 +59,24 @@ Project rules are **`.cursor/rules/*.mdc`**. They use YAML frontmatter:
56
59
  | Stack, structure, APIs | `tech-stack`, `project-structure`, `api-conventions` |
57
60
  | Data & naming | `naming-conventions`, `database` |
58
61
  | Ops & quality | `security`, `monitoring`, `testing`, `git-workflow`, `system-design` |
62
+ | Code intelligence | `codegraph` (MCP usage; see below) |
63
+
64
+ ---
65
+
66
+ ## Code intelligence (CodeGraph)
67
+
68
+ This project includes **[CodeGraph](https://github.com/colbymchenry/codegraph)** for local, structural code search via MCP.
69
+
70
+ | Item | Location |
71
+ |------|----------|
72
+ | MCP server config | `.cursor/mcp.json` |
73
+ | Usage rules | `.cursor/rules/codegraph.mdc` |
74
+ | Symbol index (generated) | `.codegraph/` (gitignored) |
75
+ | Setup reference | `.cursor/references/codegraph.md` |
76
+
77
+ After installing scaffolding, **reload the Cursor window** (or restart Cursor) so the CodeGraph MCP server connects. Use `codegraph_*` tools for structural questions (callers, callees, traces, impact); use grep/read for literal text in comments or strings.
78
+
79
+ If the index is missing, run `npx @colbymchenry/codegraph init -i` in the project root.
59
80
 
60
81
  ---
61
82
 
@@ -82,6 +103,9 @@ Reusable playbooks: **`.cursor/skills/*/SKILL.md`** (and related `.md` files whe
82
103
  | `incremental-implementation` | Vertical slices |
83
104
  | `deploy` | Deployment pipeline |
84
105
  | `security-review` | Security audit |
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 |
85
109
 
86
110
  ---
87
111
 
@@ -95,18 +119,29 @@ Reusable playbooks: **`.cursor/skills/*/SKILL.md`** (and related `.md` files whe
95
119
  | `testing-patterns.md` | Test structure |
96
120
  | `performance-checklist.md` | Performance |
97
121
  | `accessibility-checklist.md` | WCAG-oriented checks |
122
+ | `codegraph.md` | CodeGraph install and Claude Code setup |
123
+ | `agent-continuity.md` | Session handoff and `/resume` / `/handoff` |
124
+ | `supabase.md` | Supabase skills, MCP OAuth, secrets |
98
125
 
99
126
  ---
100
127
 
101
128
  ## Config parity
102
129
 
103
- **`.cursor/settings.json`** lists directories (mirrors `.claude/settings.json` for Claude Code). Cursor natively loads **`.cursor/rules/*.mdc`**; other paths are documentation for humans and for `@` includes.
130
+ **`.cursor/settings.json`** lists directories (mirrors `.claude/settings.json` for Claude Code). Cursor natively loads **`.cursor/rules/*.mdc`** and **`.cursor/mcp.json`** for MCP servers; other paths are documentation for humans and for `@` includes.
131
+
132
+ ---
133
+
134
+ ## Agent continuity
135
+
136
+ Cross-tool handoff lives in **`.agent/SESSION.md`** (committed). Use **`/resume`** at session start and **`/handoff`** at session end when switching chats or tools (Cursor, Claude Code, Kiro). See **`.cursor/references/agent-continuity.md`** and **`.cursor/rules/agent-continuity.mdc`**.
104
137
 
105
138
  ---
106
139
 
107
140
  ## Agent behavior
108
141
 
109
142
  1. Follow the workflow and use the command prompts when starting a phase.
110
- 2. Apply **`.cursor/rules/`**; treat **`security.mdc`** as non-negotiable.
111
- 3. Prefer tests first and small, buildable changes.
112
- 4. **@ mention** the right **`.cursor/agents/`** file when the task matches that role.
143
+ 2. If **`.agent/SESSION.md`** exists, read it before planning or coding; run **`/resume`** when continuing prior work.
144
+ 3. Apply **`.cursor/rules/`**; treat **`security.mdc`** as non-negotiable.
145
+ 4. Prefer tests first and small, buildable changes.
146
+ 5. **@ mention** the right **`.cursor/agents/`** file when the task matches that role.
147
+ 6. Update **`.agent/SESSION.md`** (or **`/handoff`**) before ending a session.
@@ -23,9 +23,10 @@ Implement tasks one at a time using Test-Driven Development. Each increment leav
23
23
  #### Step 1: Load Context
24
24
 
25
25
  ```
26
- 1. Read the task's acceptance criteria
27
- 2. Identify relevant existing code and patterns
28
- 3. Understand types and interfaces involved
26
+ 1. Read `.agent/SESSION.md` if present (or run `/resume` at session start)
27
+ 2. Read the task's acceptance criteria from `tasks/todo.md`
28
+ 3. Identify relevant existing code and patterns
29
+ 4. Understand types and interfaces involved
29
30
  ```
30
31
 
31
32
  #### Step 2: RED — Write Failing Test
@@ -86,7 +87,7 @@ git commit -m "feat(tasks): add createTask function"
86
87
 
87
88
  #### Step 6: Mark Complete
88
89
 
89
- Update `tasks/todo.md`:
90
+ Update `tasks/todo.md` and `.agent/SESSION.md` (**Done**, **In progress**, **Next**):
90
91
  ```markdown
91
92
  - [x] Task 1.1: Create task endpoint
92
93
  ```
@@ -20,7 +20,7 @@ When unexpected failures occur:
20
20
  3. **DIAGNOSE** — Follow the 6-step triage process
21
21
  4. **FIX** — Address root cause, not symptoms
22
22
  5. **GUARD** — Add tests to prevent recurrence
23
- 6. **RESUME** — Only continue after verification
23
+ 6. **RESUME** — Only continue after verification; update `.agent/SESSION.md` with root cause, guard tests, and **Next**
24
24
 
25
25
  ---
26
26
 
@@ -236,6 +236,7 @@ git bisect reset # When done
236
236
  - Regression test added
237
237
  - All tests passing
238
238
  - Clear commit message explaining the fix
239
+ - **`.agent/SESSION.md`** updated (Gotchas, Decisions, **Next**)
239
240
 
240
241
  ## Next Step
241
242
 
@@ -0,0 +1,94 @@
1
+ ---
2
+ name: handoff
3
+ description: End-of-session — update .agent/SESSION.md for the next agent or tool
4
+ ---
5
+
6
+ # /handoff — Session handoff
7
+
8
+ > "Leave the next agent a map, not a maze."
9
+
10
+ ## Purpose
11
+
12
+ Capture current work in **`.agent/SESSION.md`** so another chat, persona, or tool (Cursor, Claude Code, Kiro) can continue without re-discovering context.
13
+
14
+ ## When to use
15
+
16
+ - End of a work session (before closing chat)
17
+ - Switching tools (Cursor → Claude Code → Kiro)
18
+ - Switching persona (e.g. architect → backend)
19
+ - After completing a workflow phase (spec, plan, build, test, review)
20
+ - Before opening a PR (document what reviewers should know)
21
+
22
+ ## Prerequisites
23
+
24
+ - `.agent/SESSION.md` exists (created by `npx class-ai-agent` or copy from `.agent/SESSION.template.md`)
25
+ - You have context on what was done this session
26
+
27
+ ## Workflow
28
+
29
+ ### Phase 1: Gather state
30
+
31
+ 1. **Review git** — branch name, uncommitted files, last commits
32
+ 2. **Review tasks** — open `tasks/todo.md`; sync checkboxes with reality
33
+ 3. **Review spec** — note linked `SPEC.md` or `docs/specs/...` path
34
+ 4. **Scan decisions** — what did we choose that is not obvious from code alone?
35
+ 5. **Scan gotchas** — what failed, env quirks, commands that matter
36
+
37
+ ### Phase 2: Update `.agent/SESSION.md`
38
+
39
+ Refresh every section (use `.agent/SESSION.template.md` as schema):
40
+
41
+ | Section | Content |
42
+ |---------|---------|
43
+ | **Meta** | `Updated` (today), `Phase`, `Tool` (cursor/claude/kiro), optional `Persona` |
44
+ | **Goal** | One paragraph — still accurate? |
45
+ | **Done** | Bullets with file paths or commit refs |
46
+ | **In progress** | Current task; **Blockers** (none or describe) |
47
+ | **Next** | Numbered steps for the *next* agent |
48
+ | **Decisions** | Non-obvious choices made this session |
49
+ | **Gotchas** | Failed attempts, test commands, env notes |
50
+ | **Pointers** | Spec path, `tasks/todo.md`, branch, key files |
51
+
52
+ ### Phase 3: Sync `tasks/todo.md`
53
+
54
+ - Mark completed items `[x]`
55
+ - Add new tasks discovered during work
56
+ - Remove or defer items that are out of scope
57
+
58
+ ### Phase 4: Risk note (if applicable)
59
+
60
+ If work is **not** safe to pick up blindly, add under **Gotchas** or **In progress**:
61
+
62
+ - Uncommitted changes and why
63
+ - Failing tests or broken build
64
+ - External blockers (API, review, dependency)
65
+
66
+ ### Phase 5: Optional milestone archive
67
+
68
+ For major milestones, copy `SESSION.md` to:
69
+
70
+ ```
71
+ .agent/history/YYYY-MM-DD-short-slug.md
72
+ ```
73
+
74
+ Commit both `SESSION.md` and the history file when ready.
75
+
76
+ ## Security
77
+
78
+ **Never** write to `SESSION.md`:
79
+
80
+ - API keys, passwords, tokens, credentials
81
+ - PII or customer data
82
+ - Full stack traces with secrets
83
+
84
+ Use issue links or commit SHAs instead.
85
+
86
+ ## Output
87
+
88
+ - Updated **`.agent/SESSION.md`**
89
+ - Updated **`tasks/todo.md`** (if it exists)
90
+ - Short summary for the user: phase, next steps, blockers
91
+
92
+ ## Next step
93
+
94
+ Tell the user to run **`/resume`** in the next session or tool, or commit and share the branch.
@@ -100,6 +100,7 @@ Save to `tasks/` directory:
100
100
 
101
101
  - `tasks/plan.md` — Full planning document with context
102
102
  - `tasks/todo.md` — Actionable task checklist
103
+ - **`.agent/SESSION.md`** — Update Meta `phase` to `build`, **Pointers** → `tasks/todo.md` and spec path, **Next** → first `/build` task
103
104
 
104
105
  ```markdown
105
106
  # TODO: [Feature Name]