create-monolayer-app 0.5.1 → 0.6.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.
Files changed (85) hide show
  1. package/bin/index.js +91 -59
  2. package/package.json +19 -16
  3. package/template/.agents/skills/{monolayer-application-permissions → application-permissions}/SKILL.md +2 -2
  4. package/template/.agents/skills/application-permissions/agents/openai.yaml +4 -0
  5. package/template/.agents/skills/kysely/SKILL.md +48 -0
  6. package/template/.agents/skills/kysely/agents/openai.yaml +4 -0
  7. package/template/.agents/skills/kysely/references/execution-plugins-and-runtime.md +67 -0
  8. package/template/.agents/skills/kysely/references/expressions-and-helpers.md +102 -0
  9. package/template/.agents/skills/kysely/references/migrations.md +43 -0
  10. package/template/.agents/skills/kysely/references/official-docs-map.md +97 -0
  11. package/template/.agents/skills/kysely/references/query-building.md +119 -0
  12. package/template/.agents/skills/kysely/references/transactions.md +47 -0
  13. package/template/.agents/skills/kysely/references/troubleshooting-and-boundaries.md +67 -0
  14. package/template/.agents/skills/kysely/references/types.md +58 -0
  15. package/template/.agents/skills/persistent-app-data/SKILL.md +74 -0
  16. package/template/.agents/skills/persistent-app-data/agents/openai.yaml +4 -0
  17. package/template/.agents/skills/persistent-app-data/references/generated-types.md +23 -0
  18. package/template/.agents/skills/persistent-app-data/references/migrations.md +68 -0
  19. package/template/.agents/skills/vitest/GENERATION.md +25 -0
  20. package/template/.agents/skills/vitest/SKILL.md +59 -0
  21. package/template/.agents/skills/vitest/references/advanced-environments.md +26 -0
  22. package/template/.agents/skills/vitest/references/advanced-projects.md +31 -0
  23. package/template/.agents/skills/vitest/references/advanced-type-testing.md +30 -0
  24. package/template/.agents/skills/vitest/references/advanced-vi.md +23 -0
  25. package/template/.agents/skills/vitest/references/core-cli.md +23 -0
  26. package/template/.agents/skills/vitest/references/core-config.md +24 -0
  27. package/template/.agents/skills/vitest/references/core-describe.md +24 -0
  28. package/template/.agents/skills/vitest/references/core-expect.md +35 -0
  29. package/template/.agents/skills/vitest/references/core-hooks.md +26 -0
  30. package/template/.agents/skills/vitest/references/core-test-api.md +29 -0
  31. package/template/.agents/skills/vitest/references/features-benchmarking.md +25 -0
  32. package/template/.agents/skills/vitest/references/features-concurrency.md +20 -0
  33. package/template/.agents/skills/vitest/references/features-context.md +27 -0
  34. package/template/.agents/skills/vitest/references/features-coverage.md +17 -0
  35. package/template/.agents/skills/vitest/references/features-filtering.md +24 -0
  36. package/template/.agents/skills/vitest/references/features-mocking.md +32 -0
  37. package/template/.agents/skills/vitest/references/features-reporters.md +22 -0
  38. package/template/.agents/skills/vitest/references/features-snapshots.md +23 -0
  39. package/template/.agents/skills/vitest/references/features-test-tags.md +30 -0
  40. package/template/.agents/skills/vitest/references/version-compatibility.md +19 -0
  41. package/template/.claude/CLAUDE.md +2 -2
  42. package/template/.react-router/types/+routes.ts +41 -0
  43. package/template/.react-router/types/+server-build.d.ts +18 -0
  44. package/template/.react-router/types/app/+types/root.ts +68 -0
  45. package/template/.react-router/types/app/routes/+types/files.ts +71 -0
  46. package/template/.react-router/types/app/routes/+types/home.ts +71 -0
  47. package/template/AGENTS.md +6 -2
  48. package/template/app/routes/files.ts +3 -3
  49. package/template/build/client/assets/entry.client-Bc58m2-m.js +9 -0
  50. package/template/build/client/assets/errorBoundaries-CQxPIuVU.js +16 -0
  51. package/template/build/client/assets/files-BvRk9kiK.js +0 -0
  52. package/template/build/client/assets/home-CH2INc5e.js +1 -0
  53. package/template/build/client/assets/jsx-runtime-eLCqVKHJ.js +1 -0
  54. package/template/build/client/assets/logo-dark-pX2395Y0.svg +23 -0
  55. package/template/build/client/assets/logo-light-CVbx2LBR.svg +23 -0
  56. package/template/build/client/assets/manifest-2d65dd0f.js +1 -0
  57. package/template/build/client/assets/root-BeNS6njP.css +2 -0
  58. package/template/build/client/assets/root-C1tmjS9o.js +1 -0
  59. package/template/build/client/favicon.ico +0 -0
  60. package/template/build/server/index.js +1096 -0
  61. package/template/lib/db/client.ts +1 -27
  62. package/template/package-lock.json +8221 -0
  63. package/template/package.json +7 -3
  64. package/template/vendor/file-bucket/{client.ts → index.client.ts} +11 -9
  65. package/template/vendor/file-bucket/{server.ts → index.server.ts} +13 -8
  66. package/template/vendor/file-bucket/{index.ts → lib/file-bucket.ts} +2 -1
  67. package/template/vendor/file-bucket/{react-router.ts → react-router.server.ts} +15 -13
  68. package/template/vendor/kysely-dsql/dsql/dsql-kysely.ts +31 -3
  69. package/template/vendor/kysely-dsql/generator/migration-file.ts +3 -3
  70. package/template/vendor/kysely-dsql/plugins/index.ts +0 -2
  71. package/template/vendor/package-app/package-app.mjs +2 -2
  72. package/template/vite.config.ts +3 -1
  73. package/template/vitest.config.ts +1 -1
  74. package/template/.agents/skills/monolayer-application-permissions/agents/openai.yaml +0 -4
  75. package/template/vendor/kysely-dsql/plugins/soft-delete.plugin.ts +0 -217
  76. /package/template/.agents/skills/{monolayer-application-permissions → application-permissions}/references/development-and-verification.md +0 -0
  77. /package/template/.agents/skills/{monolayer-application-permissions → application-permissions}/references/interface-examples.md +0 -0
  78. /package/template/.agents/skills/{monolayer-application-permissions → application-permissions}/references/server-examples.md +0 -0
  79. /package/template/vendor/file-bucket/{errors.ts → lib/errors.server.ts} +0 -0
  80. /package/template/vendor/file-bucket/{multipart.ts → lib/multipart.ts} +0 -0
  81. /package/template/vendor/file-bucket/{protocol.ts → lib/protocol.ts} +0 -0
  82. /package/template/vendor/file-bucket/{transport.ts → lib/transport.client.ts} +0 -0
  83. /package/template/vendor/file-bucket/{types.ts → lib/types.ts} +0 -0
  84. /package/template/vendor/file-bucket/{transfers.ts → lib/upload-signed-url.ts} +0 -0
  85. /package/template/vendor/file-bucket/{xml.ts → lib/xml.ts} +0 -0
@@ -0,0 +1,97 @@
1
+ # Official Kysely PostgreSQL documentation map
2
+
3
+ This map points to the PostgreSQL sections represented in `https://kysely.dev/llms-full.txt`.
4
+
5
+ The source was retrieved on 2026-08-22. Open the source page when an exact API detail can change the implementation.
6
+
7
+ ## Start and setup
8
+
9
+ | Topic | Official source | Use |
10
+ | --- | --- | --- |
11
+ | Introduction | https://kysely.dev/docs/intro.md | Product scope and type inference |
12
+ | Getting started | https://kysely.dev/docs/getting-started.md | PostgreSQL installation, types, instance, and CRUD |
13
+ | PostgreSQL dialect | https://kysely-org.github.io/kysely-apidoc/classes/PostgresDialect.html | `PostgresDialect` setup and configuration |
14
+ | Generating types | https://kysely.dev/docs/generating-types.md | Schema type generators |
15
+ | Supabase | https://kysely.dev/docs/integrations/supabase.md | Supabase type translation |
16
+ | LLM documents | https://kysely.dev/docs/integrations/llms.md | Official LLM document policy |
17
+
18
+ ## Query examples
19
+
20
+ | Group | Example | Official source |
21
+ | --- | --- | --- |
22
+ | CTE | Data changes | https://kysely.dev/docs/examples/cte/inserts-updates-and-deletions.md |
23
+ | CTE | Selects | https://kysely.dev/docs/examples/cte/simple-selects.md |
24
+ | Delete | One row | https://kysely.dev/docs/examples/delete/single-row.md |
25
+ | Insert | Complex values | https://kysely.dev/docs/examples/insert/complex-values.md |
26
+ | Insert | Subquery | https://kysely.dev/docs/examples/insert/insert-subquery.md |
27
+ | Insert | Multiple rows | https://kysely.dev/docs/examples/insert/multiple-rows.md |
28
+ | Insert | Returning data | https://kysely.dev/docs/examples/insert/returning-data.md |
29
+ | Insert | One row | https://kysely.dev/docs/examples/insert/single-row.md |
30
+ | Join | Aliased inner join | https://kysely.dev/docs/examples/join/aliased-inner-join.md |
31
+ | Join | Complex join | https://kysely.dev/docs/examples/join/complex-join.md |
32
+ | Join | Simple inner join | https://kysely.dev/docs/examples/join/simple-inner-join.md |
33
+ | Join | Subquery join | https://kysely.dev/docs/examples/join/subquery-join.md |
34
+ | Merge | Source row existence | https://kysely.dev/docs/examples/merge/source-row-existence.md |
35
+ | Merge | Temporary changes table | https://kysely.dev/docs/examples/merge/temporary-changes-table.md |
36
+ | Select | One column | https://kysely.dev/docs/examples/select/a-single-column.md |
37
+ | Select | Aliases | https://kysely.dev/docs/examples/select/aliases.md |
38
+ | Select | All columns | https://kysely.dev/docs/examples/select/all-columns.md |
39
+ | Select | All table columns | https://kysely.dev/docs/examples/select/all-columns-of-a-table.md |
40
+ | Select | Qualified column | https://kysely.dev/docs/examples/select/column-with-a-table.md |
41
+ | Select | Complex selections | https://kysely.dev/docs/examples/select/complex-selections.md |
42
+ | Select | Distinct | https://kysely.dev/docs/examples/select/distinct.md |
43
+ | Select | Distinct on | https://kysely.dev/docs/examples/select/distinct-on.md |
44
+ | Select | Function calls | https://kysely.dev/docs/examples/select/function-calls.md |
45
+ | Select | Generic find query | https://kysely.dev/docs/examples/select/generic-find-query.md |
46
+ | Select | Multiple columns | https://kysely.dev/docs/examples/select/multiple-columns.md |
47
+ | Select | Nested array | https://kysely.dev/docs/examples/select/nested-array.md |
48
+ | Select | Nested object | https://kysely.dev/docs/examples/select/nested-object.md |
49
+ | Select | Not null | https://kysely.dev/docs/examples/select/not-null.md |
50
+ | Transaction | Controlled | https://kysely.dev/docs/examples/transactions/controlled-transaction.md |
51
+ | Transaction | Savepoints | https://kysely.dev/docs/examples/transactions/controlled-transaction-w-savepoints.md |
52
+ | Transaction | Callback | https://kysely.dev/docs/examples/transactions/simple-transaction.md |
53
+ | Update | Complex values | https://kysely.dev/docs/examples/update/complex-values.md |
54
+ | Update | One row | https://kysely.dev/docs/examples/update/single-row.md |
55
+ | Where | Complex clause | https://kysely.dev/docs/examples/where/complex-where-clause.md |
56
+ | Where | Conditional calls | https://kysely.dev/docs/examples/where/conditional-where-calls.md |
57
+ | Where | Object filter | https://kysely.dev/docs/examples/where/object-filter.md |
58
+ | Where | OR | https://kysely.dev/docs/examples/where/or-where.md |
59
+ | Where | Simple clause | https://kysely.dev/docs/examples/where/simple-where-clause.md |
60
+ | Where | IN | https://kysely.dev/docs/examples/where/where-in.md |
61
+
62
+ Each official page links to exact builder signatures in the generated API documentation.
63
+
64
+ ## System behavior
65
+
66
+ | Topic | Official source | Use |
67
+ | --- | --- | --- |
68
+ | Execution flow | https://kysely.dev/docs/execution.md | Query transformation, compilation, `pg` work, and result transformation |
69
+ | Migrations | https://kysely.dev/docs/migrations.md | Migration files, order, providers, and locks |
70
+ | Plugin system | https://kysely.dev/docs/plugins.md | Plugin registration and built-in plugins |
71
+ | Playground | https://kysely.dev/docs/playground.md | Query experiments and examples |
72
+
73
+ ## Recipes
74
+
75
+ | Topic | Official source |
76
+ | --- | --- |
77
+ | Conditional selects | https://kysely.dev/docs/recipes/conditional-selects.md |
78
+ | Data types | https://kysely.dev/docs/recipes/data-types.md |
79
+ | Deduplicate joins | https://kysely.dev/docs/recipes/deduplicate-joins.md |
80
+ | Deep TypeScript types | https://kysely.dev/docs/recipes/excessively-deep-types.md |
81
+ | Expressions | https://kysely.dev/docs/recipes/expressions.md |
82
+ | Extending Kysely | https://kysely.dev/docs/recipes/extending-kysely.md |
83
+ | Introspection | https://kysely.dev/docs/recipes/introspecting-relation-metadata.md |
84
+ | Logging | https://kysely.dev/docs/recipes/logging.md |
85
+ | Raw SQL | https://kysely.dev/docs/recipes/raw-sql.md |
86
+ | Reusable helpers | https://kysely.dev/docs/recipes/reusable-helpers.md |
87
+ | Database schemas | https://kysely.dev/docs/recipes/schemas.md |
88
+ | Split build and execution | https://kysely.dev/docs/recipes/splitting-query-building-and-execution.md |
89
+
90
+ ## Exact APIs
91
+
92
+ Use the generated API documentation for classes, interfaces, overloads, and version-specific examples:
93
+
94
+ - https://kysely-org.github.io/kysely-apidoc/
95
+ - The declaration files in the installed `kysely` package
96
+
97
+ Prefer local declarations when the installed package version differs from the current website.
@@ -0,0 +1,119 @@
1
+ # Query building
2
+
3
+ Use this reference for query structure and execution methods. Check the official API types for exact overloads.
4
+
5
+ ## Selects
6
+
7
+ Start with `selectFrom`. Select only the columns required by the consumer.
8
+
9
+ ```typescript
10
+ const person = await db
11
+ .selectFrom("person")
12
+ .select(["id", "first_name", "last_name"])
13
+ .where("id", "=", personId)
14
+ .executeTakeFirst()
15
+ ```
16
+
17
+ Use `selectAll("table")` when a consumer requires every table column. Use `as` aliases for stable result property names.
18
+
19
+ Use these execution methods intentionally:
20
+
21
+ | Method | Result |
22
+ | --- | --- |
23
+ | `execute()` | All result rows |
24
+ | `executeTakeFirst()` | The first row or `undefined` |
25
+ | `executeTakeFirstOrThrow()` | The first row or an exception |
26
+
27
+ ## Filters
28
+
29
+ Repeated `where` calls use `AND`. Use the expression builder for grouped Boolean logic.
30
+
31
+ ```typescript
32
+ const rows = await db
33
+ .selectFrom("person")
34
+ .selectAll()
35
+ .where(({ and, eb, or }) =>
36
+ or([
37
+ eb("status", "=", "active"),
38
+ and([
39
+ eb("status", "=", "pending"),
40
+ eb("created_at", ">", cutoff),
41
+ ]),
42
+ ])
43
+ )
44
+ .execute()
45
+ ```
46
+
47
+ Use `whereRef` when both operands are column references. Use `is` and `is not` for explicit null comparisons.
48
+
49
+ Reassign immutable builders when conditions add filters:
50
+
51
+ ```typescript
52
+ let query = db.selectFrom("person").selectAll()
53
+
54
+ if (firstName !== undefined) {
55
+ query = query.where("first_name", "=", firstName)
56
+ }
57
+ ```
58
+
59
+ ## Joins and subqueries
60
+
61
+ Use the short join overload for simple equality joins.
62
+
63
+ ```typescript
64
+ const rows = await db
65
+ .selectFrom("person")
66
+ .innerJoin("pet", "pet.owner_id", "person.id")
67
+ .select(["person.id", "pet.name as pet_name"])
68
+ .execute()
69
+ ```
70
+
71
+ Use a join callback for grouped conditions. Alias joined tables and subqueries when names can conflict.
72
+
73
+ Correlate subqueries with `whereRef`. Add `as` when a selected expression needs a result property.
74
+
75
+ ## Inserts, updates, and deletes
76
+
77
+ ```typescript
78
+ const inserted = await db
79
+ .insertInto("person")
80
+ .values(newPerson)
81
+ .returningAll()
82
+ .executeTakeFirstOrThrow()
83
+
84
+ await db
85
+ .updateTable("person")
86
+ .set(personUpdate)
87
+ .where("id", "=", personId)
88
+ .executeTakeFirst()
89
+
90
+ await db
91
+ .deleteFrom("person")
92
+ .where("id", "=", personId)
93
+ .executeTakeFirst()
94
+ ```
95
+
96
+ Use PostgreSQL `RETURNING` through `returning` or `returningAll`. Check mutation metadata when the query returns no row data.
97
+
98
+ Use an expression callback in `values` or `set` for subqueries, column calculations, or database functions.
99
+
100
+ ## CTEs and merge queries
101
+
102
+ Use `with` for common table expressions. PostgreSQL CTEs can contain supported data changes.
103
+
104
+ Use `withRecursive` for recursive CTEs. Keep the anchor and recursive member types compatible.
105
+
106
+ Use `mergeInto` only when the PostgreSQL server supports `MERGE`. Model every matched and unmatched branch explicitly.
107
+
108
+ ## PostgreSQL checks
109
+
110
+ Confirm these features before a query uses them:
111
+
112
+ - `RETURNING`
113
+ - `DISTINCT ON`
114
+ - Data-changing CTEs
115
+ - `MERGE` support in the server version
116
+ - `UPDATE FROM`
117
+ - JSON and JSONB functions
118
+ - Row lock clauses
119
+ - PostgreSQL data types, defaults, and extensions
@@ -0,0 +1,47 @@
1
+ # Transactions
2
+
3
+ Use this reference for atomic work, controlled transactions, and savepoints.
4
+
5
+ ## Callback transactions
6
+
7
+ Use a callback transaction for normal atomic work.
8
+
9
+ ```typescript
10
+ const pet = await db.transaction().execute(async (trx) => {
11
+ const person = await trx
12
+ .insertInto("person")
13
+ .values(newPerson)
14
+ .returning("id")
15
+ .executeTakeFirstOrThrow()
16
+
17
+ return trx
18
+ .insertInto("pet")
19
+ .values({ ...newPet, owner_id: person.id })
20
+ .returningAll()
21
+ .executeTakeFirstOrThrow()
22
+ })
23
+ ```
24
+
25
+ The callback commits when it returns. An exception rolls back the transaction and returns the exception to the caller.
26
+
27
+ Pass `trx` to all repository functions that participate in the transaction. Avoid accidental calls through the root `db` instance.
28
+
29
+ ## Controlled transactions
30
+
31
+ Use a controlled transaction when the code must select the commit or rollback point.
32
+
33
+ ```typescript
34
+ const trx = await db.startTransaction().execute()
35
+
36
+ try {
37
+ await doWork(trx)
38
+ await trx.commit().execute()
39
+ } catch (error) {
40
+ await trx.rollback().execute()
41
+ throw error
42
+ }
43
+ ```
44
+
45
+ Use `savepoint`, `rollbackToSavepoint`, and `releaseSavepoint` for a recoverable part of a controlled transaction.
46
+
47
+ Confirm PostgreSQL and `pg` behavior for transaction settings, savepoints, isolation levels, and access modes.
@@ -0,0 +1,67 @@
1
+ # Troubleshooting and boundaries
2
+
3
+ Use this reference when TypeScript output, `pg` output, PostgreSQL behavior, or Kysely scope is unclear.
4
+
5
+ ## Type and runtime mismatch
6
+
7
+ Kysely types cannot convert `pg` values. First inspect the PostgreSQL value and the `pg` parser.
8
+
9
+ Then align the `Database` type with the observed runtime value. Configure a `pg` parser when the application requires another value type.
10
+
11
+ ## Nullable results
12
+
13
+ A SQL predicate can prove a column is not null while Kysely keeps its nullable type.
14
+
15
+ Use `$narrowType<{ column: NotNull }>()` for a proven row property. Use `$notNull()` for a proven selected expression.
16
+
17
+ Keep the proof next to the narrowing call. Joins, subqueries, and aggregate behavior can invalidate an assumed proof.
18
+
19
+ ## Deep TypeScript types
20
+
21
+ Complex CTEs and nested helpers can cause TypeScript error TS2589. Use `$assertType<Shape>()` at a stable subquery boundary.
22
+
23
+ Kysely requires the asserted type to be structurally equal. This method removes the complex internal type without reducing type safety.
24
+
25
+ A display-only `Simplify<T>` helper does not remove the underlying complex type.
26
+
27
+ ## Conditional row shapes
28
+
29
+ Direct reassignment loses added type information when `select`, `returning`, or a join changes the builder type.
30
+
31
+ Use `$if` for optional row properties. Use separate code branches for distinct result unions.
32
+
33
+ ## Duplicate joins
34
+
35
+ Independent conditional selections can add the same join more than once. Use `DeduplicateJoinsPlugin` when this dynamic design is necessary.
36
+
37
+ The plugin compares query structures and can miss complex equivalent joins. Prefer one explicit join when the query can express that design clearly.
38
+
39
+ ## Relation loading
40
+
41
+ Kysely has no relation model or automatic relation loader. Build the required SQL shape explicitly.
42
+
43
+ Import `jsonArrayFrom` and `jsonObjectFrom` from `kysely/helpers/postgres`.
44
+
45
+ These helpers use PostgreSQL JSON functions. Confirm that the `pg` configuration returns JSON and JSONB values with the expected runtime types.
46
+
47
+ ## Database schemas
48
+
49
+ For a fixed schema set, use qualified table keys such as `user.permission` in the `Database` interface.
50
+
51
+ For tenant schemas, use `db.withSchema(tenant)` after the application validates the tenant identifier.
52
+
53
+ Explicitly qualified tables keep their schema under `withSchema`. Add those qualified names to the `Database` interface.
54
+
55
+ ## Raw SQL boundary
56
+
57
+ Normal `sql` interpolation parameterizes values. Identifier and raw-text helpers insert SQL structure.
58
+
59
+ Map external input to a fixed identifier allowlist before it reaches `sql.ref`, `sql.table`, `sql.id`, or `db.dynamic.ref`.
60
+
61
+ Keep `sql.raw` for static or trusted SQL text. Give every `sql<T>` result the actual database output type.
62
+
63
+ ## PostgreSQL boundary
64
+
65
+ When a query compiles but fails, compare the generated SQL with the PostgreSQL version and documentation.
66
+
67
+ Check aliases, placeholders, `RETURNING`, JSON functions, `UPDATE FROM`, CTE behavior, merge clauses, and PostgreSQL data types.
@@ -0,0 +1,58 @@
1
+ # PostgreSQL types
2
+
3
+ Use this reference for schema types, operation types, generated types, and `pg` runtime values.
4
+
5
+ ## Database type
6
+
7
+ The `Database` interface maps each table name to one table interface.
8
+
9
+ ```typescript
10
+ import type {
11
+ ColumnType,
12
+ Generated,
13
+ Insertable,
14
+ Selectable,
15
+ Updateable,
16
+ } from "kysely"
17
+
18
+ interface PersonTable {
19
+ id: Generated<number>
20
+ first_name: string
21
+ last_name: string | null
22
+ created_at: ColumnType<Date, string | undefined, never>
23
+ }
24
+
25
+ interface Database {
26
+ person: PersonTable
27
+ }
28
+
29
+ type Person = Selectable<PersonTable>
30
+ type NewPerson = Insertable<PersonTable>
31
+ type PersonUpdate = Updateable<PersonTable>
32
+ ```
33
+
34
+ Table properties describe columns. Use `null` for a nullable PostgreSQL column.
35
+
36
+ Keep table properties required. Kysely calculates operation-specific optional properties from column wrappers.
37
+
38
+ Use `Generated<T>` for values that PostgreSQL generates. Use `ColumnType<Select, Insert, Update>` when operation types differ.
39
+
40
+ Use `Selectable`, `Insertable`, and `Updateable` for application data. Keep table interfaces inside the `Database` type boundary.
41
+
42
+ ## Runtime values
43
+
44
+ Kysely controls TypeScript types only. `pg` controls runtime JavaScript values.
45
+
46
+ Align each column type with the value that `pg` returns. Configure `pg` parsers when the application requires different runtime values.
47
+
48
+ ## Generated types
49
+
50
+ Production systems usually generate the `Database` type from the deployed PostgreSQL schema. Official documentation lists these third-party generators:
51
+
52
+ - `kysely-codegen` for PostgreSQL schema introspection
53
+ - `prisma-kysely` for Prisma schemas
54
+ - `kanel-kysely` for PostgreSQL
55
+
56
+ Verify generated types against `pg` output. Generator output cannot change runtime values.
57
+
58
+ Supabase projects can translate generated Supabase types with `kysely-supabase` and `KyselifyDatabase`.
@@ -0,0 +1,74 @@
1
+ ---
2
+ name: persistent-app-data
3
+ description: >
4
+ Add persistent data to applications through the existing DSQLKysely client.
5
+ ---
6
+
7
+ # Persistent App Data
8
+
9
+ Use Kysely through the existing `DSQLKysely` client for persistent application records.
10
+ Keep database access in server code.
11
+
12
+ ## Sources and related skills
13
+
14
+ Paths below refer to the application root, including applications copied from this template.
15
+
16
+ - Read [lib/db/client.ts](../../../lib/db/client.ts) for the shared `db` export.
17
+ - Read [migrations](references/migrations.md) when you create, apply, or reverse a schema migration.
18
+ - Read [generated types](references/generated-types.md) when you generate or inspect database types after a schema change.
19
+ - Use the adjacent [Kysely skill](../kysely/SKILL.md) for queries, expressions, transactions, and general migration guidance.
20
+ - Use [Application Permissions](../application-permissions/SKILL.md) for shared content access and server writes.
21
+
22
+ The application client and migration commands define the template-specific behavior.
23
+ Apply these constraints when general Kysely guidance permits more PostgreSQL features.
24
+
25
+ ## Client and environment
26
+
27
+ Import the shared `db` from `lib/db/client.ts` in server modules.
28
+ Use the application import conventions for the relative path or alias.
29
+ Do not create a separate client, pool, dialect, or ORM for feature code.
30
+ Do not replace persistent records with browser storage, JSON files, or process memory.
31
+
32
+ The [client implementation](../../../vendor/kysely-dsql/dsql/dsql-kysely.ts) selects the database from `NODE_ENV`:
33
+
34
+ | `NODE_ENV` | Database | Configuration |
35
+ | ---------------------- | ------------ | --------------------------- |
36
+ | `development` or unset | Local PGlite | `./.pglite_development` |
37
+ | `test` | Local PGlite | `./.pglite_test` |
38
+ | `production` | Aurora DSQL | Required `CLUSTER_ENDPOINT` |
39
+
40
+ Other non-production values also select the development database.
41
+ Local database paths depend on the process working directory.
42
+ Run application commands from the application root.
43
+ Keep local PGlite directories out of commits.
44
+
45
+ ## Schema and plugin rules
46
+
47
+ Require an `updated_at` column with `timestamptz NOT NULL DEFAULT now()` on each application table.
48
+ The default supplies the initial timestamp.
49
+
50
+ The [plugin list](../../../vendor/kysely-dsql/plugins/index.ts) applies to the shared client.
51
+ Do not disable these plugins to avoid the required column.
52
+
53
+ - `CamelCasePlugin` maps camelCase application identifiers to snake_case SQL identifiers.
54
+ - `AutoUpdatedAtPlugin` supplies `updated_at` on updates unless the query supplies that column.
55
+
56
+ Use camelCase names in application queries and generated types, including `updatedAt`.
57
+
58
+ Use the restricted schema builders from `DSQLKysely`.
59
+ Keep schema changes within the restrictions in [compatibility-rules.ts](../../../vendor/kysely-dsql/dsql/compatibility-rules.ts).
60
+ Do not bypass restrictions through casts, another dialect, or raw SQL.
61
+ Check UUID identifiers when a design would otherwise need auto-increment columns.
62
+
63
+ The local PGlite dialect does not use the production DSQL query compiler.
64
+ A successful local query does not prove production SQL compatibility.
65
+ Inspect the production compiler and restricted builders when a change needs indexes or uncommon SQL.
66
+ The current compiler supplies asynchronous index syntax in production.
67
+
68
+ ## Verification
69
+
70
+ Verify that saved records survive the required reload or restart.
71
+ Verify viewer denial and permitted writer behavior when server writes change.
72
+
73
+ Report local results separately from production DSQL verification.
74
+ Identify any unverified SQL compatibility or migration behavior in the completion report.
@@ -0,0 +1,4 @@
1
+ interface:
2
+ display_name: "Persistent App Data"
3
+ short_description: "Use the existing DSQL client and migrations"
4
+ default_prompt: "Use $persistent-app-data to add persistent data to this application."
@@ -0,0 +1,23 @@
1
+ # Generated types
2
+
3
+ Generate the database types from the migrated development database before test or production use.
4
+ Run the commands from the application root.
5
+
6
+ ## Generator behavior
7
+
8
+ The [generator](../../../../vendor/kysely-dsql/generator/generate-types-from-pglite.ts) reads `./.pglite_development`.
9
+ It writes `lib/db/db.ts` and table files under `lib/db/tables/`.
10
+ It skips type generation when `NODE_ENV` equals `test` or `production`.
11
+ The post-migration hooks still call the generator in those environments.
12
+
13
+ Use `NODE_ENV=development npm run db:create-types` to generate types separately.
14
+ For schema changes, use the [migration procedure](migrations.md#creating-and-applying-a-migration).
15
+ Its post-migration hook generates the types after a successful migration.
16
+
17
+ ## Generated files
18
+
19
+ Use the same generated types in all environments.
20
+ Do not hand-edit `db.ts` or generated table files.
21
+ Include generated changes with their schema migrations.
22
+ Use the generated row, insert, and update types when applicable.
23
+ Check that the generated types match the migrated schema.
@@ -0,0 +1,68 @@
1
+ # Migrations
2
+
3
+ Use the application migration commands to create, apply, or reverse schema changes.
4
+ Run the commands from the application root.
5
+
6
+ ## Sources and constraints
7
+
8
+ Read [package.json](../../../../package.json) for the database commands and lifecycle hooks.
9
+ Read [.config/kysely.config.ts](../../../../.config/kysely.config.ts) for migration configuration.
10
+
11
+ Inspect the existing migrations before a schema change.
12
+ Keep the generated `DSQLKysely<any>` parameter in `up` and `down`.
13
+ Do not import the current `Database` type into historical migrations.
14
+ Implement the forward change in `up` and the reverse change in `down`.
15
+ Report any reverse operation that can remove saved data.
16
+
17
+ The migration configuration disables transactions around migrations.
18
+ Do not assume that a failed migration rolls back earlier statements.
19
+ Check reverse migrations only against disposable local data.
20
+
21
+ ## Commands
22
+
23
+ Use `npm run` so the existing post-migration hooks execute.
24
+
25
+ | Command | Result |
26
+ | ----------------------------------- | ---------------------------------------------------------------------------- |
27
+ | `npm run migrate:make -- add-tasks` | Creates an empty timestamped migration in `lib/db/migrations/`. |
28
+ | `npm run migrate:latest` | Applies all pending migrations. Runs the type generation hook after success. |
29
+ | `npm run migrate:up` | Applies one pending migration. Runs the type generation hook after success. |
30
+ | `npm run migrate:down` | Reverses one applied migration. Runs the type generation hook after success. |
31
+ | `npm run migrate:list` | Lists migrations and their status. |
32
+
33
+ Use lowercase letters, digits, and single hyphens for migration names.
34
+ Replace `add-tasks` with the name of the required change.
35
+
36
+ ## Creating and applying a migration
37
+
38
+ Use this procedure for a schema change in the development database.
39
+
40
+ 1. **Create the migration** with `npm run migrate:make -- <name>`.
41
+ 2. **Implement `up` and `down`** with the restricted schema API.
42
+ 3. **Run `NODE_ENV=development npm run migrate:latest`.**
43
+ 4. **Inspect the generated database and table types.** See [generated types](generated-types.md).
44
+ 5. If the requested feature needs server queries, **implement them through the shared `db`.**
45
+ 6. **Run the checks** that cover the changed behavior.
46
+
47
+ The development database contains the schema changes.
48
+ The post-migration hook generates the types from that database.
49
+
50
+ ## Deployed database
51
+
52
+ The built image decides the deployed database. The `pg` dependency adds the `monolayer/postgres` buildpack, so the deployment creates one Aurora DSQL cluster for the application. The `lib/db/migrations/` directory adds the `monolayer/kysely-migrations` buildpack. Each deployment then runs `migrate:latest` before it changes the web function.
53
+
54
+ A failed migration stops the deployment, and the previous version continues to serve traffic. Do not remove `pg` from a deployed application. The deployment fails, and the database stays.
55
+
56
+ Apply these rules to each migration:
57
+
58
+ - Use one DDL statement in each migration. DSQL permits one DDL statement in a transaction and no DDL with DML.
59
+ - Write DDL that can run again, for example `ifNotExists()` on a table.
60
+ - Write additive changes only. The previous version continues to use the database during the migration.
61
+ - Do not use `migrate:down` to undo a deployment.
62
+ - Wait for asynchronous index jobs when later code needs the index.
63
+
64
+ ## Verification
65
+
66
+ Run `NODE_ENV=development npm run migrate:list` after a development migration.
67
+ Apply migrations separately with `NODE_ENV=test npm run migrate:latest` before tests that need the local test database.
68
+ Check that schema changes generate the expected types without manual edits.
@@ -0,0 +1,25 @@
1
+ # Generation information
2
+
3
+ - Refresh date: 2026-10-17.
4
+ - Target: Vitest 5.
5
+ - Template installation: Vitest 5.0.5.
6
+ - Primary source: [official Vitest documentation](https://vitest.dev/).
7
+ - Source index: [documentation for agents](https://vitest.dev/llms.txt).
8
+ - Version changes: [Vitest 5 migration guide](https://vitest.dev/guide/migration/).
9
+
10
+ The previous skill records generation on 2026-06-22 from commit `3f60d0893affbda989404555136fe20a6086d4e6`. This refresh uses the published documentation and the installed package types. It does not claim a Git commit for the published website. The original skill credits Anthony Fu.
11
+
12
+ Each reference links to its applicable official sources. The summaries use Simplified Technical English. Existing reference filenames remain available.
13
+
14
+ ## Refresh procedure
15
+
16
+ 1. Check the target manifest, lockfile, installed version, configuration, and adjacent tests.
17
+ 2. Read the applicable official documentation.
18
+ 3. Compare version changes with the installed package types.
19
+ 4. Update the affected summaries and examples.
20
+ 5. Record the refresh date and verified version here.
21
+ 6. Validate the skill frontmatter and local links.
22
+ 7. Format the changed Markdown files.
23
+ 8. Review the full diff for architecture canvas impact.
24
+
25
+ Do not change application dependencies or test configuration as part of a documentation refresh.
@@ -0,0 +1,59 @@
1
+ ---
2
+ name: vitest
3
+ description: Write, debug, and configure Vitest tests. Use for assertions, mocks, fixtures, coverage, filtering, environments, projects, snapshots, benchmarks, and type tests.
4
+ metadata:
5
+ author: Anthony Fu
6
+ version: "2026.10.17"
7
+ source: Regenerated from official Vitest documentation at https://vitest.dev
8
+ ---
9
+
10
+ # Vitest
11
+
12
+ Write tests that check observable behavior. Use the installed Vitest version and the application configuration as the API authority.
13
+
14
+ ## Workflow
15
+
16
+ 1. Read the application guide, package manifest, lockfile, Vitest configuration, and adjacent tests.
17
+ 2. Check the installed Vitest version and its package exports.
18
+ 3. Select the applicable reference below.
19
+ 4. Write tests for the changed behavior and its relevant failure conditions.
20
+ 5. Run the focused tests with the application's local Vitest installation.
21
+ 6. Complete the checks that the repository requires for the change.
22
+
23
+ Use explicit imports from `vitest` unless the application enables globals. Keep assertions inside test callbacks. Use `async` callbacks for asynchronous tests. Await promise assertions and asynchronous cleanup.
24
+
25
+ Keep committed tests free of `.only` and `.skip`. Use typed mocks at external service boundaries. Keep coverage thresholds and source boundaries unchanged.
26
+
27
+ A focused run gives development feedback. It does not replace complete coverage when the repository requires coverage. Report assertion failures, execution restrictions, and missing dependencies separately.
28
+
29
+ ## Version boundary
30
+
31
+ These references target Vitest 5. The template manifest declares `^5.0.0`. Its lockfile and installed package resolve to `5.0.5` at regeneration. The parent monorepo uses a separate Vitest 4 catalog.
32
+
33
+ Use the target application's installation for commands. Do not infer its version from the parent workspace. Read [version compatibility](references/version-compatibility.md) before migration work or work with another major version. Read [generation information](GENERATION.md) for the source and refresh procedure.
34
+
35
+ ## Reference map
36
+
37
+ Read only the references that apply to the task.
38
+
39
+ | Task | Reference |
40
+ | ----------------------------------------- | --------------------------------------------------- |
41
+ | Configure discovery, aliases, or setup | [Configuration](references/core-config.md) |
42
+ | Run tests or inspect CLI options | [CLI](references/core-cli.md) |
43
+ | Define tests, options, or data cases | [Test API](references/core-test-api.md) |
44
+ | Group tests and apply suite options | [Describe API](references/core-describe.md) |
45
+ | Select assertions or await results | [Expect API](references/core-expect.md) |
46
+ | Set up resources and release them | [Hooks](references/core-hooks.md) |
47
+ | Mock modules and service boundaries | [Mocking](references/features-mocking.md) |
48
+ | Select mock cleanup or timer utilities | [Vi utilities](references/advanced-vi.md) |
49
+ | Create or update snapshots | [Snapshots](references/features-snapshots.md) |
50
+ | Configure and verify coverage | [Coverage](references/features-coverage.md) |
51
+ | Share fixtures and test context | [Test context](references/features-context.md) |
52
+ | Select parallel execution settings | [Concurrency](references/features-concurrency.md) |
53
+ | Select files, names, or changed tests | [Filtering](references/features-filtering.md) |
54
+ | Apply category options and tag filters | [Test tags](references/features-test-tags.md) |
55
+ | Configure terminal or CI reports | [Reporters](references/features-reporters.md) |
56
+ | Measure performance | [Benchmarking](references/features-benchmarking.md) |
57
+ | Select Node.js, DOM, or browser execution | [Environments](references/advanced-environments.md) |
58
+ | Check TypeScript contracts | [Type testing](references/advanced-type-testing.md) |
59
+ | Configure multiple test projects | [Projects](references/advanced-projects.md) |