@everystack/mcp 0.3.2 → 0.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 (104) hide show
  1. package/dist/adding-database.md +36 -23
  2. package/dist/cli.md +44 -3
  3. package/dist/core.md +19 -1
  4. package/dist/database-operations.md +236 -0
  5. package/dist/derived-objects.md +225 -0
  6. package/dist/gates/detectors/embedded-data-bundle.d.ts +13 -0
  7. package/dist/gates/detectors/embedded-data-bundle.d.ts.map +1 -0
  8. package/dist/gates/detectors/embedded-data-bundle.js +56 -0
  9. package/dist/gates/detectors/hand-written-migration.d.ts +24 -0
  10. package/dist/gates/detectors/hand-written-migration.d.ts.map +1 -0
  11. package/dist/gates/detectors/hand-written-migration.js +54 -0
  12. package/dist/gates/detectors/secret-in-public-env.d.ts +12 -0
  13. package/dist/gates/detectors/secret-in-public-env.d.ts.map +1 -0
  14. package/dist/gates/detectors/secret-in-public-env.js +38 -0
  15. package/dist/gates/engine.d.ts +28 -0
  16. package/dist/gates/engine.d.ts.map +1 -0
  17. package/dist/gates/engine.js +74 -0
  18. package/dist/gates/registry.d.ts +14 -0
  19. package/dist/gates/registry.d.ts.map +1 -0
  20. package/dist/gates/registry.js +21 -0
  21. package/dist/gates/telemetry.d.ts +47 -0
  22. package/dist/gates/telemetry.d.ts.map +1 -0
  23. package/dist/gates/telemetry.js +121 -0
  24. package/dist/gates/types.d.ts +67 -0
  25. package/dist/gates/types.d.ts.map +1 -0
  26. package/dist/gates/types.js +14 -0
  27. package/dist/governance/cli.d.ts +57 -0
  28. package/dist/governance/cli.d.ts.map +1 -0
  29. package/dist/governance/cli.js +169 -0
  30. package/dist/governance/grounding.d.ts +78 -0
  31. package/dist/governance/grounding.d.ts.map +1 -0
  32. package/dist/governance/grounding.js +299 -0
  33. package/dist/index.cjs +119 -107
  34. package/dist/index.d.ts +2 -0
  35. package/dist/index.d.ts.map +1 -0
  36. package/dist/index.js +94 -0
  37. package/dist/project-claude-md.md +35 -18
  38. package/dist/prompts/add-feature.d.ts +3 -0
  39. package/dist/prompts/add-feature.d.ts.map +1 -0
  40. package/dist/prompts/add-feature.js +154 -0
  41. package/dist/prompts/claude-md.d.ts +12 -0
  42. package/dist/prompts/claude-md.d.ts.map +1 -0
  43. package/dist/prompts/claude-md.js +87 -0
  44. package/dist/prompts/debug.d.ts +3 -0
  45. package/dist/prompts/debug.d.ts.map +1 -0
  46. package/dist/prompts/debug.js +129 -0
  47. package/dist/prompts/deploy.d.ts +3 -0
  48. package/dist/prompts/deploy.d.ts.map +1 -0
  49. package/dist/prompts/deploy.js +118 -0
  50. package/dist/prompts/design-schema.d.ts +3 -0
  51. package/dist/prompts/design-schema.d.ts.map +1 -0
  52. package/dist/prompts/design-schema.js +97 -0
  53. package/dist/prompts/governance-setup.d.ts +9 -0
  54. package/dist/prompts/governance-setup.d.ts.map +1 -0
  55. package/dist/prompts/governance-setup.js +76 -0
  56. package/dist/prompts/index.d.ts +3 -0
  57. package/dist/prompts/index.d.ts.map +1 -0
  58. package/dist/prompts/index.js +20 -0
  59. package/dist/prompts/new-app.d.ts +3 -0
  60. package/dist/prompts/new-app.d.ts.map +1 -0
  61. package/dist/prompts/new-app.js +203 -0
  62. package/dist/prompts/runbook.d.ts +12 -0
  63. package/dist/prompts/runbook.d.ts.map +1 -0
  64. package/dist/prompts/runbook.js +70 -0
  65. package/dist/prompts/secure.d.ts +3 -0
  66. package/dist/prompts/secure.d.ts.map +1 -0
  67. package/dist/prompts/secure.js +219 -0
  68. package/dist/resources/index.d.ts +12 -0
  69. package/dist/resources/index.d.ts.map +1 -0
  70. package/dist/resources/index.js +182 -0
  71. package/dist/schema-patterns.md +92 -106
  72. package/dist/tools/check-environment.d.ts +25 -0
  73. package/dist/tools/check-environment.d.ts.map +1 -0
  74. package/dist/tools/check-environment.js +281 -0
  75. package/dist/tools/index.d.ts +3 -0
  76. package/dist/tools/index.d.ts.map +1 -0
  77. package/dist/tools/index.js +18 -0
  78. package/dist/tools/project-status.d.ts +28 -0
  79. package/dist/tools/project-status.d.ts.map +1 -0
  80. package/dist/tools/project-status.js +138 -0
  81. package/dist/tools/project-validate.d.ts +19 -0
  82. package/dist/tools/project-validate.d.ts.map +1 -0
  83. package/dist/tools/project-validate.js +323 -0
  84. package/dist/tools/schema-analyze.d.ts +46 -0
  85. package/dist/tools/schema-analyze.d.ts.map +1 -0
  86. package/dist/tools/schema-analyze.js +336 -0
  87. package/package.json +3 -3
  88. package/src/gates/detectors/hand-written-migration.ts +29 -13
  89. package/src/index.ts +1 -1
  90. package/src/prompts/add-feature.ts +4 -4
  91. package/src/prompts/claude-md.ts +4 -2
  92. package/src/prompts/debug.ts +3 -4
  93. package/src/prompts/deploy.ts +17 -8
  94. package/src/prompts/design-schema.ts +45 -59
  95. package/src/prompts/new-app.ts +21 -19
  96. package/src/prompts/secure.ts +3 -3
  97. package/src/resources/adding-database.md +36 -23
  98. package/src/resources/cli.md +44 -3
  99. package/src/resources/core.md +19 -1
  100. package/src/resources/database-operations.md +236 -0
  101. package/src/resources/derived-objects.md +225 -0
  102. package/src/resources/index.ts +15 -1
  103. package/src/resources/project-claude-md.md +35 -18
  104. package/src/resources/schema-patterns.md +92 -106
@@ -19,12 +19,21 @@ These are enforced (everystack cheat gates) and load-bearing. Do not work around
19
19
  - **Data lives in PostgreSQL, served through the API — never bundle data into the app.** A
20
20
  large `.json`/`.csv` of computed data in the bundle is wrong; model it and serve it, or
21
21
  render an empty state if it does not exist yet.
22
- - **Schema changes have two homes; neither is a hand-written migration.** Tables and authz
23
- are generated from Models: declare with `defineModel` (in `db/models/`), run
24
- `everystack db:generate`never hand-write a SQL migration, never edit the generated
25
- `db/schema.ts`; after any change `db:generate` must be a clean no-op. Functions, views,
26
- and matviews are **authored** in `db/sql/` and **deployed** with `everystack db:reconcile`
27
- edit the SQL file, reconcile, done; `db:reconcile --check` must exit 0.
22
+ - **Nobody authors migrations. Schema work has two homes.** The WHOLE declared database
23
+ lives in `db/models/`: tables and authz with `defineModel`, and the derived layer —
24
+ functions, views, matviews as descriptors (`defineView` / `defineMaterializedView` /
25
+ `defineFunction` / `defineSql`, triggers via `trigger()` on the model). Edit the
26
+ declaration, then `everystack db:sync` moves the dev database to your checkout (state +
27
+ authz + derived, fingerprint-verified). One-shot DATA moves are authored in
28
+ `db/backfills/*.sql` and run via `everystack db:backfill` — deliberately, never as a
29
+ schema side effect. Never hand-write a SQL
30
+ migration, never edit `db/schema.generated.ts`; `everystack db:check` must pass (the CI
31
+ gate: the declared state composes, generated artifacts match regeneration).
32
+ - **Protected stages take plans, not syncs.** `everystack db:plan` mints a reviewable edge
33
+ pinned by fingerprints at both ends; `db:apply` verifies before and after, requires the
34
+ checkout to descend from the commit declaring the target's state ("rebase first"), and
35
+ gates destructive plans: `--confirm` always, snapshot always, the stage's approver set
36
+ (`db:approvers`) when declared.
28
37
  - **Authorization is declared, not hand-written.** Use `can()` abilities on the Model; they
29
38
  compile to RLS + grants. Never hand-write `CREATE POLICY`/`GRANT`. RLS is required.
30
39
  - **Reuse `@everystack/ui`.** Do not hand-roll a component that already exists there. Style
@@ -35,11 +44,12 @@ These are enforced (everystack cheat gates) and load-bearing. Do not work around
35
44
 
36
45
  ## Start Here
37
46
 
38
- - `db/models/` — `defineModel` tables (the source of truth for schema + authz)
39
- - `db/sql/` — functions, views, matviews (authored SQL; deploys via `db:reconcile`)
47
+ - `db/models/` — the declared database: `defineModel` tables + derived descriptors
48
+ (`defineView`/`defineMaterializedView`/`defineFunction`/`defineSql`; deploys via `db:reconcile`/`db:sync`)
49
+ - `db/backfills/` — one-shot data jobs (authored SQL; run via `db:backfill`, own record)
40
50
  - `app/` — Expo Router pages (screens, navigation, API routes)
41
51
  - `server/` — Lambda handlers (api.ts, worker.ts, image.ts)
42
- - `db/schema.generated.ts`, `drizzle/` — generated artifacts (do not edit by hand)
52
+ - `db/schema.generated.ts` — generated artifact (never edit; `db:check` refuses drift)
43
53
  - `lib/` — shared code (auth context, API client)
44
54
  - `sst.config.ts` — AWS infrastructure definition
45
55
  - `docs/RUNBOOK.md` — how to operate this app; regenerate with `everystack runbook`
@@ -54,9 +64,12 @@ These are enforced (everystack cheat gates) and load-bearing. Do not work around
54
64
  pnpm install # Install dependencies
55
65
  pnpm dev # Start the Expo dev server
56
66
  pnpm test # Run all tests (TDD)
57
- everystack db:generate # Models next migration (data + authz)
58
- everystack db:reconcile --apply # Deploy functions/views/matviews from db/sql (no migrations)
59
- everystack db:migrate # Apply migrations on the deployed Lambda
67
+ everystack db:sync # Dev edit loop: the database follows your checkout (state + authz + derived)
68
+ everystack db:check # CI gate: declared state composes; generated artifacts match regeneration
69
+ everystack db:plan | db:apply # Protected stages: reviewable, fingerprint-verified edges
70
+ everystack db:branch # Per-git-branch dev DB from the seeded template (db:template:refresh builds it)
71
+ everystack db:backfill --apply # Run one-shot data jobs from db/backfills/ (own record)
72
+ everystack db:generate # Models → the diff as SQL (review surface)
60
73
  everystack db:seed # Seed the database (dev only)
61
74
  everystack deploy --stage dev # Deploy infrastructure (SST)
62
75
  everystack update --channel production # OTA update (no redeploy)
@@ -69,12 +82,15 @@ everystack bundle:audit <url> # Audit a deployed bundle (weight +
69
82
  ### Models are the source of truth (v3)
70
83
 
71
84
  Declare tables with `defineModel` (`field`, `can`, relations). A package's full DB slice is a
72
- `defineModule`; the app composes Modules. `everystack db:generate` compiles them to one
73
- migration (schema + RLS + grants); `deriveHandlerConfig(models)` derives the API config. You
85
+ `defineModule`; the app composes Modules. The database's own schema is the authority — the
86
+ live state is content-addressed (`db:fingerprint`), and every apply verifies against it. You
74
87
  never hand-write migrations, RLS, or handler access-control — they are derived, so they cannot
75
- drift. The derived layer (functions, views, matviews) is the exception that proves the rule:
76
- that SQL is authored, in `db/sql/`, and *deployed* with `db:reconcile` hand-edits straight
77
- against the database surface as drift, and a comment-only edit is a no-op.
88
+ drift; `deriveHandlerConfig(models)` derives the API config. The derived layer (functions,
89
+ views, matviews) follows the same rule: descriptors declare the structure (identity, deps,
90
+ authz, security posture), the body stays `sql\`\``, and reconcile *deploys* it hand-edits
91
+ straight against the database surface as drift, and a comment-only edit is a no-op. Contraction is a two-step ceremony: `field.deprecated()` first
92
+ (the column stays readable, new writes are rejected, generated types strike it through), the
93
+ physical drop later — a destructive plan, confirmed, snapshotted, approver-gated.
78
94
 
79
95
  ### Security over all else
80
96
 
@@ -104,7 +120,8 @@ Every feature starts with a failing test. Tests in `__tests__/` mirroring source
104
120
 
105
121
  - Don't bundle large data into the app — it lives in the DB, served by the API.
106
122
  - Don't hand-write migrations or edit `db/schema.ts` — edit the Model, run `db:generate`;
107
- for functions/views/matviews edit `db/sql/` and run `db:reconcile`.
123
+ for functions/views/matviews edit the descriptors in `db/models/` and run `db:reconcile`
124
+ (`db/sql/` is retired — the verbs fail on it with the migration path).
108
125
  - Don't hand-write RLS — declare `can()` abilities.
109
126
  - Don't hand-roll a component that exists in `@everystack/ui`; don't use inline `StyleSheet`.
110
127
  - Don't put a secret behind `EXPO_PUBLIC_*` — that ships to the client.
@@ -0,0 +1,3 @@
1
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ export declare function registerAddFeaturePrompt(server: McpServer): void;
3
+ //# sourceMappingURL=add-feature.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"add-feature.d.ts","sourceRoot":"","sources":["../../src/prompts/add-feature.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAmHzE,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CA+ChE"}
@@ -0,0 +1,154 @@
1
+ import { z } from 'zod';
2
+ const FEATURES = {
3
+ auth: {
4
+ resource: 'everystack://auth',
5
+ packages: ['@everystack/auth'],
6
+ steps: [
7
+ 'Install @everystack/auth',
8
+ 'Create auth handlers with createAuthHandlers(db, schema, jwtSecret)',
9
+ 'Add auth routes to Lambda handler (signup, signin, refresh, verify, signout)',
10
+ 'Create lib/auth-context.tsx with AuthProvider and useAuth hook',
11
+ 'Add pgSettings to handler config for RLS claim injection',
12
+ 'Add signup and signin screens in app/',
13
+ 'Set JwtSecret via SST secrets: `pnpm sst secret set JwtSecret "$(openssl rand -base64 32)" --stage dev`',
14
+ ],
15
+ },
16
+ jobs: {
17
+ resource: 'everystack://jobs',
18
+ packages: ['@everystack/jobs'],
19
+ steps: [
20
+ 'Install @everystack/jobs',
21
+ 'Create server/worker.ts with createWorkerHandler',
22
+ 'Define job types and handlers',
23
+ 'Add SQS queue to sst.config.ts',
24
+ 'Create job adapter: createJobAdapter({ type: "sqs", queueUrl: Resource.Jobs.url })',
25
+ 'Publish jobs from API handlers: jobClient.publish(type, payload)',
26
+ 'Add dead letter queue for failed jobs',
27
+ ],
28
+ },
29
+ storage: {
30
+ resource: 'everystack://storage',
31
+ packages: ['@everystack/storage'],
32
+ steps: [
33
+ 'Install @everystack/storage',
34
+ 'Add S3 bucket for uploads to sst.config.ts',
35
+ 'Add storagePlugin to handler plugins with MIME type validation',
36
+ 'Add uploads table to schema (or use @everystack/storage/schema)',
37
+ 'Client flow: request presigned URL → upload to S3 → confirm upload',
38
+ 'Configure CDN delivery for public files',
39
+ ],
40
+ },
41
+ images: {
42
+ resource: 'everystack://images',
43
+ packages: ['@everystack/images'],
44
+ steps: [
45
+ 'Install @everystack/images',
46
+ 'Create server/image.ts with createImageHandler',
47
+ 'Add image Lambda to sst.config.ts (needs sharp layer)',
48
+ 'Add image_variants table to schema',
49
+ 'Configure variant generation (thumb, medium, large)',
50
+ 'Set up CDN delivery with format negotiation (WebP, AVIF)',
51
+ ],
52
+ },
53
+ admin: {
54
+ resource: 'everystack://admin',
55
+ packages: ['@everystack/admin'],
56
+ steps: [
57
+ 'Install @everystack/admin',
58
+ 'Create admin page in app/ using AdminRoot and AdminLayout',
59
+ 'Define resource configs for each table (fields, columns, actions)',
60
+ 'Use EverystackAdapter for API integration',
61
+ 'Add admin role check to protect admin routes',
62
+ 'Add dashboard RPCs via createAllDashboardRpcs',
63
+ ],
64
+ },
65
+ logging: {
66
+ resource: 'everystack://logging',
67
+ packages: ['@everystack/logging'],
68
+ steps: [
69
+ 'Install @everystack/logging',
70
+ 'Add loggingPlugin to handler plugins',
71
+ 'Add logging schema tables to your schema exports',
72
+ 'Configure S3 log storage in sst.config.ts',
73
+ 'Add client SDK: createLoggingClient for crash reports and analytics',
74
+ 'Add admin dashboard RPCs for log viewing',
75
+ ],
76
+ },
77
+ security: {
78
+ resource: 'everystack://security-device',
79
+ packages: ['@everystack/security'],
80
+ steps: [
81
+ 'Install @everystack/security',
82
+ 'Set up Apple App Attest (requires iOS 14+, real device)',
83
+ 'Set up Google Play Integrity (requires Google Play Services)',
84
+ 'Generate RS256 device keys on client',
85
+ 'Add device attestation verification to auth flow',
86
+ 'Store device keys in secure enclave/keystore',
87
+ ],
88
+ },
89
+ ssr: {
90
+ resource: 'everystack://ssr',
91
+ packages: [],
92
+ steps: [
93
+ 'SSR is built into @everystack/server — no extra packages needed',
94
+ 'Create SSR loader functions that query Drizzle directly',
95
+ 'Add getWebHandler to Lambda for HTML rendering',
96
+ 'Set up JSON-LD structured data for SEO',
97
+ 'Add OG meta tags for social sharing',
98
+ 'Configure cache headers per route',
99
+ ],
100
+ },
101
+ events: {
102
+ resource: 'everystack://events',
103
+ packages: [],
104
+ steps: [
105
+ 'Events use PostgreSQL LISTEN/NOTIFY — built into the database',
106
+ 'Create database trigger functions for table change notifications',
107
+ 'Set up a listener Lambda with persistent database connection',
108
+ 'Add WebSocket fan-out for client delivery',
109
+ 'Use the useSignal hook in React components for real-time updates',
110
+ ],
111
+ },
112
+ };
113
+ export function registerAddFeaturePrompt(server) {
114
+ server.prompt('add-feature', 'Add an everystack feature to an existing project. Provides step-by-step instructions for auth, jobs, storage, images, admin, logging, security, SSR, or events.', {
115
+ feature: z.enum(['auth', 'jobs', 'storage', 'images', 'admin', 'logging', 'security', 'ssr', 'events'])
116
+ .describe('Feature to add'),
117
+ projectPath: z.string().optional().describe('Absolute path to project root'),
118
+ }, async ({ feature, projectPath }) => {
119
+ const f = FEATURES[feature];
120
+ return {
121
+ messages: [
122
+ {
123
+ role: 'user',
124
+ content: {
125
+ type: 'text',
126
+ text: [
127
+ `Add ${feature} to ${projectPath ? 'the project at ' + projectPath : 'my everystack project'}.`,
128
+ '',
129
+ '## Instructions',
130
+ '',
131
+ `1. Read the ${f.resource} resource for full documentation.`,
132
+ '2. Read everystack://core for architecture context.',
133
+ feature === 'auth' || feature === 'security' ? '3. Read everystack://security for the security model.' : '',
134
+ projectPath ? `4. Run the project_status tool with projectPath="${projectPath}" to understand the current state.` : '',
135
+ projectPath ? `5. Run the project_validate tool with projectPath="${projectPath}" after making changes.` : '',
136
+ '',
137
+ '## Steps',
138
+ '',
139
+ ...f.steps.map((s, i) => `${i + 1}. ${s}`),
140
+ '',
141
+ f.packages.length > 0 ? `## Install\n\n\`\`\`bash\npnpm add ${f.packages.join(' ')}\n\`\`\`` : '',
142
+ '',
143
+ '## After Setup',
144
+ '',
145
+ '- Run tests to verify the integration',
146
+ '- Run project_validate to check for configuration issues',
147
+ '- Read the relevant resource docs for advanced configuration',
148
+ ].filter(Boolean).join('\n'),
149
+ },
150
+ },
151
+ ],
152
+ };
153
+ });
154
+ }
@@ -0,0 +1,12 @@
1
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ /**
3
+ * `claude_md` — create or reconcile the project's CLAUDE.md.
4
+ *
5
+ * The CLAUDE.md is the project contract. Writing it activates the grounding gate
6
+ * (the nearest project CLAUDE.md is auto-required). But a contract is a living
7
+ * document — it drifts from reality as the project grows. So this prompt is
8
+ * bidirectional: scaffold it when missing, and review + suggest updates when it
9
+ * exists (a drift check on the contract itself), never clobbering human content.
10
+ */
11
+ export declare function registerClaudeMdPrompt(server: McpServer): void;
12
+ //# sourceMappingURL=claude-md.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"claude-md.d.ts","sourceRoot":"","sources":["../../src/prompts/claude-md.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAGzE;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAiF9D"}
@@ -0,0 +1,87 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * `claude_md` — create or reconcile the project's CLAUDE.md.
4
+ *
5
+ * The CLAUDE.md is the project contract. Writing it activates the grounding gate
6
+ * (the nearest project CLAUDE.md is auto-required). But a contract is a living
7
+ * document — it drifts from reality as the project grows. So this prompt is
8
+ * bidirectional: scaffold it when missing, and review + suggest updates when it
9
+ * exists (a drift check on the contract itself), never clobbering human content.
10
+ */
11
+ export function registerClaudeMdPrompt(server) {
12
+ server.prompt('claude_md', 'Create or keep the project CLAUDE.md current. Missing → scaffold from the everystack contract. Exists → review against the project reality + the cheat-gate rules and suggest updates (confirm-first, never clobber). Writing it activates the grounding gate.', {
13
+ projectPath: z.string().optional().describe('Absolute path to the project root (where CLAUDE.md lives)'),
14
+ }, async ({ projectPath }) => {
15
+ const root = projectPath ?? '.';
16
+ return {
17
+ messages: [
18
+ {
19
+ role: 'user',
20
+ content: {
21
+ type: 'text',
22
+ text: [
23
+ `Create or reconcile the CLAUDE.md for the project at ${root}.`,
24
+ '',
25
+ '## Why this matters',
26
+ '',
27
+ 'CLAUDE.md is this project\'s contract. The grounding gate auto-requires the nearest',
28
+ 'project CLAUDE.md — so writing it is what turns grounding ON (the agent must read it',
29
+ 'before editing). A contract also drifts as the project grows, so it must be kept current.',
30
+ '',
31
+ '## Step 1 — detect the project reality',
32
+ '',
33
+ `- Read ${root}/package.json: which @everystack/* packages are installed (tier: V1 server/cli/ui;`,
34
+ ' V2 adds api/auth/admin/logging/security/query; V3 adds jobs/storage/images).',
35
+ `- Check for a models/ directory (defineModel files) and a db/ directory.`,
36
+ `- Note the project name and what the app does.`,
37
+ '',
38
+ '## Step 2 — read the template',
39
+ '',
40
+ 'Read the everystack://project-claude-md resource. It is the everystack contract: the',
41
+ 'Non-negotiables (which mirror the cheat gates), Key Principles, Commands, and the',
42
+ 'What NOT to Do list. Fill {PROJECT_NAME}, {ONE_LINE_DESCRIPTION}, {ANNOTATED_DIRECTORY_TREE}',
43
+ 'and tailor Structure/Commands to the packages actually installed.',
44
+ '',
45
+ `## Step 3 — does ${root}/CLAUDE.md already exist?`,
46
+ '',
47
+ '### If it does NOT exist → scaffold',
48
+ '',
49
+ `- Write ${root}/CLAUDE.md from the template, tailored to the detected reality.`,
50
+ '- Keep it tight and load-bearing — a wall of prose gets read as scenery. Lead with the',
51
+ ' Non-negotiables.',
52
+ '- Tell the human: this activates the grounding gate; new sessions must read it first.',
53
+ '',
54
+ '### If it EXISTS → review and suggest updates (DO NOT clobber)',
55
+ '',
56
+ 'Reconcile the existing CLAUDE.md against three things, and propose a concrete diff:',
57
+ '1. **Framework drift** — does it teach superseded ways (e.g. `drizzle-kit generate`,',
58
+ ' hand-written migrations, a migration journal, "pass your Drizzle schema") instead of',
59
+ ' the migration-authority flow (`defineModel` in db/models/ → `everystack db:sync` on',
60
+ ' dev; `db:plan` → `db:apply` on protected stages; `db:check` in CI; data moves in',
61
+ ' db/backfills/ via `db:backfill`)? Suggest the current conventions.',
62
+ '2. **Project drift** — do the Structure / Commands / package list match what is actually',
63
+ ' installed now (new packages, a new tier, a new models/ dir)? Suggest updates. Also',
64
+ ' check the operations manual: if docs/RUNBOOK.md is missing, or stale per',
65
+ ' `everystack runbook --check`, suggest the `runbook` prompt.',
66
+ '3. **Contract-vs-gates drift** — is it missing any Non-negotiable the cheat gates enforce',
67
+ ' (data→DB, generated migrations, declared authz, reuse @everystack/ui, secrets boundary)?',
68
+ ' Suggest adding it, so the human contract and the enforced rules agree.',
69
+ '',
70
+ 'Rules for reconciling:',
71
+ '- **Preserve all human/project-specific content** — project rules, domain notes, the',
72
+ ' REQUIRED-READS line. Only update the framework/structure/commands sections and flag gaps.',
73
+ '- **Propose, then confirm.** Show the human the suggested changes (a diff) and let them',
74
+ ' approve before writing. The CLAUDE.md is theirs; you assist, you do not own it.',
75
+ '- **Only flag real drift**, not cosmetic rewording.',
76
+ '',
77
+ '## Step 4 — confirm',
78
+ '',
79
+ 'After writing/updating, confirm the file is at the project root so the grounding gate',
80
+ 'picks it up, and summarize what changed.',
81
+ ].join('\n'),
82
+ },
83
+ },
84
+ ],
85
+ };
86
+ });
87
+ }
@@ -0,0 +1,3 @@
1
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ export declare function registerDebugPrompt(server: McpServer): void;
3
+ //# sourceMappingURL=debug.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"debug.d.ts","sourceRoot":"","sources":["../../src/prompts/debug.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAGzE,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAoI3D"}
@@ -0,0 +1,129 @@
1
+ import { z } from 'zod';
2
+ export function registerDebugPrompt(server) {
3
+ server.prompt('debug', 'Systematic debugging for common everystack issues. Provides diagnostic steps based on the symptom.', {
4
+ symptom: z.string().describe('Description of the problem (e.g., "401 on all API requests", "RLS blocking reads", "Lambda timeout")'),
5
+ projectPath: z.string().optional().describe('Absolute path to project root'),
6
+ }, async ({ symptom, projectPath }) => {
7
+ return {
8
+ messages: [
9
+ {
10
+ role: 'user',
11
+ content: {
12
+ type: 'text',
13
+ text: [
14
+ `Debug this issue: ${symptom}`,
15
+ '',
16
+ '## Instructions',
17
+ '',
18
+ '1. Read everystack://core for architecture context.',
19
+ projectPath ? `2. Run project_status with projectPath="${projectPath}" to understand the project.` : '',
20
+ projectPath ? `3. Run project_validate with projectPath="${projectPath}" to find configuration issues.` : '',
21
+ projectPath ? `4. Run schema_analyze with projectPath="${projectPath}" to check schema/handler alignment.` : '',
22
+ '',
23
+ '## Diagnostic Framework',
24
+ '',
25
+ 'Work through these categories systematically:',
26
+ '',
27
+ '### 1. Authentication Issues (401/403)',
28
+ '',
29
+ 'If the symptom involves authentication or authorization:',
30
+ '',
31
+ '- **Check token flow:**',
32
+ ' - Is the JWT being sent in the Authorization header?',
33
+ ' - Is the token expired? Decode at jwt.io and check `exp`',
34
+ ' - Does `auth.verifyToken` return a valid payload?',
35
+ '',
36
+ '- **Check publicRoutes:**',
37
+ ' - Is the route supposed to be public? Check `auth.publicRoutes` in handler config',
38
+ ' - Is the RPC in `auth.publicRpc`?',
39
+ '',
40
+ '- **Check pgSettings:**',
41
+ ' - Is `pgSettings` configured in the handler?',
42
+ ' - Does it set `role` and `request.jwt.claims`?',
43
+ ' - Test with: `SELECT current_setting(\'request.jwt.claims\', true);`',
44
+ '',
45
+ '### 2. RLS Issues (empty results, permission denied)',
46
+ '',
47
+ 'Read everystack://security for RLS debugging.',
48
+ '',
49
+ '- **Check RLS is enabled:**',
50
+ ' ```sql',
51
+ ' SELECT tablename, rowsecurity FROM pg_tables WHERE schemaname = \'public\';',
52
+ ' ```',
53
+ '',
54
+ '- **Check policies exist:**',
55
+ ' ```sql',
56
+ ' SELECT * FROM pg_policies WHERE schemaname = \'public\';',
57
+ ' ```',
58
+ '',
59
+ '- **Test as specific role:**',
60
+ ' ```sql',
61
+ ' SET LOCAL ROLE authenticated;',
62
+ ' SELECT set_config(\'request.jwt.claims\', \'{"sub":"user-id","role":"authenticated"}\', true);',
63
+ ' SELECT * FROM your_table;',
64
+ ' ```',
65
+ '',
66
+ '- **Common RLS mistakes:**',
67
+ ' - Policy references wrong claim path (sub vs user_id)',
68
+ ' - USING clause doesn\'t match the data (e.g., UUID vs text comparison)',
69
+ ' - Missing policy for the operation (SELECT exists but not INSERT)',
70
+ ' - Forgot `WITH CHECK` on INSERT/UPDATE policies',
71
+ '',
72
+ '### 3. Query Issues (wrong data, missing relations)',
73
+ '',
74
+ 'Read everystack://query-protocol for filter syntax.',
75
+ '',
76
+ '- **Check relations config:**',
77
+ ' - Does the handler `relations` config match the Drizzle schema relations?',
78
+ ' - Is the relation direction correct (from/to)?',
79
+ '',
80
+ '- **Check column names:**',
81
+ ' - Handler uses camelCase by default. Database uses snake_case.',
82
+ ' - Check `naming` option in handler config.',
83
+ '',
84
+ '### 4. Deployment Issues',
85
+ '',
86
+ 'Read everystack://deployment and everystack://cli.',
87
+ '',
88
+ '- **Lambda errors:**',
89
+ ' ```bash',
90
+ ' everystack logs:errors --stage dev',
91
+ ' everystack logs:tail --stage dev',
92
+ ' ```',
93
+ '',
94
+ '- **Database connection:**',
95
+ ' ```bash',
96
+ ' everystack db:psql --stage dev',
97
+ ' everystack diag --stage dev',
98
+ ' ```',
99
+ '',
100
+ '- **Common deployment issues:**',
101
+ ' - Missing secrets: `pnpm sst secret list --stage dev`',
102
+ ' - VPC configuration: Lambda can\'t reach RDS without proper VPC setup',
103
+ ' - Bundle size: Check if unnecessary packages are bundled',
104
+ '',
105
+ '### 5. Performance Issues',
106
+ '',
107
+ '- **Slow queries:**',
108
+ ' - Check for missing indexes on filtered/joined columns',
109
+ ' - Check `maxLimit` and `maxEmbedDepth` in handler config',
110
+ ' - Use `EXPLAIN ANALYZE` on slow queries',
111
+ '',
112
+ '- **Cold starts:**',
113
+ ' - Minimize Lambda bundle size',
114
+ ' - Use provisioned concurrency for production',
115
+ '',
116
+ '## Resolution',
117
+ '',
118
+ 'After diagnosing:',
119
+ '1. Identify the root cause',
120
+ '2. Propose a fix with the specific code change',
121
+ '3. Verify the fix resolves the issue',
122
+ '4. Run project_validate to ensure no new issues were introduced',
123
+ ].filter(Boolean).join('\n'),
124
+ },
125
+ },
126
+ ],
127
+ };
128
+ });
129
+ }
@@ -0,0 +1,3 @@
1
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ export declare function registerDeployPrompt(server: McpServer): void;
3
+ //# sourceMappingURL=deploy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../src/prompts/deploy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAGzE,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CA0H5D"}
@@ -0,0 +1,118 @@
1
+ import { z } from 'zod';
2
+ export function registerDeployPrompt(server) {
3
+ server.prompt('deploy', 'Step-by-step deployment walkthrough for a specific stage. Covers AWS credentials, SST deploy, migrations, and verification.', {
4
+ stage: z.enum(['dev', 'staging', 'production']).describe('Deployment stage'),
5
+ projectPath: z.string().optional().describe('Absolute path to project root'),
6
+ }, async ({ stage, projectPath }) => {
7
+ const isProduction = stage === 'production';
8
+ return {
9
+ messages: [
10
+ {
11
+ role: 'user',
12
+ content: {
13
+ type: 'text',
14
+ text: [
15
+ `Deploy to ${stage}.`,
16
+ '',
17
+ '## Instructions',
18
+ '',
19
+ '1. Read everystack://deployment for infrastructure setup.',
20
+ '2. Read everystack://security for AWS credential setup and deployment checklist.',
21
+ projectPath ? `3. Run project_validate with projectPath="${projectPath}" to check for issues before deploying.` : '',
22
+ projectPath ? `4. Run project_status with projectPath="${projectPath}" to see current deployment state.` : '',
23
+ '',
24
+ '## Pre-Deploy Checklist',
25
+ '',
26
+ '### AWS Credentials',
27
+ '',
28
+ '1. Verify the correct AWS profile is configured:',
29
+ ` - ${stage === 'dev' ? '`everystack-manage` — for development deploys and CLI operations' : ''}`,
30
+ ` - ${isProduction ? '`everystack-deploy` — for CI/CD production deploys (limited permissions)' : ''}`,
31
+ '2. Run `aws sts get-caller-identity` to verify the active profile',
32
+ '3. Ensure `everystack-create` profile is DISABLED unless first deploy',
33
+ '',
34
+ '### Secrets',
35
+ '',
36
+ 'Set required secrets for this stage:',
37
+ '```bash',
38
+ `pnpm sst secret set JwtSecret "$(openssl rand -base64 32)" --stage ${stage}`,
39
+ '```',
40
+ '',
41
+ isProduction ? [
42
+ '### Production Safety',
43
+ '',
44
+ '- [ ] All tests pass: `pnpm test`',
45
+ '- [ ] No security warnings: run project_validate',
46
+ '- [ ] RLS policies are in place for all tables',
47
+ '- [ ] pgSettings is configured in handler',
48
+ '- [ ] No hardcoded secrets in source',
49
+ '- [ ] .env files are not committed',
50
+ '',
51
+ ].join('\n') : '',
52
+ '## Deploy Steps',
53
+ '',
54
+ '### 1. Deploy Infrastructure',
55
+ '```bash',
56
+ `pnpm sst deploy --stage ${stage}`,
57
+ '```',
58
+ '',
59
+ 'This creates/updates:',
60
+ '- S3 bucket for static assets',
61
+ '- CloudFront distribution',
62
+ '- Lambda functions',
63
+ '- RDS Aurora Serverless (V2+)',
64
+ '- SQS queues (V3)',
65
+ '- IAM roles and policies',
66
+ '',
67
+ '### 3. Database Setup (V2+)',
68
+ '```bash',
69
+ `everystack db:migrate --stage ${stage}`,
70
+ stage === 'dev' ? `everystack db:seed --stage ${stage} # dev only` : '',
71
+ '```',
72
+ '',
73
+ '### 4. Verify',
74
+ '```bash',
75
+ '# Check Lambda logs',
76
+ `everystack logs:tail --stage ${stage}`,
77
+ '',
78
+ '# Test the API',
79
+ `curl https://your-domain/api/health`,
80
+ '',
81
+ `# Connect to database (${stage})`,
82
+ `everystack db:psql --stage ${stage}`,
83
+ '```',
84
+ '',
85
+ '## Post-Deploy',
86
+ '',
87
+ '### OTA Updates (no redeploy needed)',
88
+ '```bash',
89
+ `everystack update --channel ${stage === 'production' ? 'production' : stage} --message "Description"`,
90
+ '```',
91
+ '',
92
+ isProduction ? [
93
+ '### Production Monitoring',
94
+ '',
95
+ '- Check CloudWatch for Lambda errors',
96
+ '- Monitor RDS connection count',
97
+ '- Verify CDN cache hit rates',
98
+ '- Set up CloudWatch alarms for error rates',
99
+ ].join('\n') : '',
100
+ '',
101
+ '## Rollback',
102
+ '',
103
+ 'If something goes wrong:',
104
+ '```bash',
105
+ '# Revert to previous OTA update',
106
+ `everystack update --channel ${stage === 'production' ? 'production' : stage} --rollback`,
107
+ '',
108
+ '# For infrastructure changes, redeploy from a known good commit',
109
+ 'git checkout <good-commit>',
110
+ `pnpm sst deploy --stage ${stage}`,
111
+ '```',
112
+ ].filter(Boolean).join('\n'),
113
+ },
114
+ },
115
+ ],
116
+ };
117
+ });
118
+ }
@@ -0,0 +1,3 @@
1
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ export declare function registerDesignSchemaPrompt(server: McpServer): void;
3
+ //# sourceMappingURL=design-schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"design-schema.d.ts","sourceRoot":"","sources":["../../src/prompts/design-schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAGzE,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAoGlE"}