@agilno-tech/rivet 0.1.0-alpha.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.
- package/LICENSE +202 -0
- package/NOTICE +6 -0
- package/README.md +59 -0
- package/bin/cli.js +42 -0
- package/dist/agents/backend-django-agent/SKILL.md +35 -0
- package/dist/agents/backend-nestjs-agent/SKILL.md +36 -0
- package/dist/agents/boss-agent/SKILL.md +28 -0
- package/dist/agents/bounded-worker/SKILL.md +28 -0
- package/dist/agents/data-performance-agent/SKILL.md +32 -0
- package/dist/agents/delivery-ticketing-agent/SKILL.md +36 -0
- package/dist/agents/devops-agent/SKILL.md +34 -0
- package/dist/agents/engineering-manager/SKILL.md +28 -0
- package/dist/agents/frontend-nextjs-agent/SKILL.md +34 -0
- package/dist/agents/frontend-web-agent/SKILL.md +31 -0
- package/dist/agents/incident-response-agent/SKILL.md +42 -0
- package/dist/agents/jest-agent/SKILL.md +77 -0
- package/dist/agents/mobile-agent/SKILL.md +32 -0
- package/dist/agents/playwright-agent/SKILL.md +54 -0
- package/dist/agents/product-design-manager/SKILL.md +27 -0
- package/dist/agents/qa-agent/SKILL.md +29 -0
- package/dist/agents/quality-manager/SKILL.md +28 -0
- package/dist/agents/vitest-agent/SKILL.md +77 -0
- package/dist/governance/pre-push-rules.md +75 -0
- package/dist/governance/prompt-hygiene.md +22 -0
- package/dist/governance/review-checklist.md +24 -0
- package/dist/governance/safety-and-data.md +27 -0
- package/dist/governance/usage-rules.md +21 -0
- package/dist/mandatory/address-pr-feedback/SKILL.md +196 -0
- package/dist/mandatory/agentic-goal/SKILL.md +42 -0
- package/dist/mandatory/agentic-status/SKILL.md +74 -0
- package/dist/mandatory/apply-design/SKILL.md +228 -0
- package/dist/mandatory/check-ac/SKILL.md +124 -0
- package/dist/mandatory/create-pr-and-commit/SKILL.md +304 -0
- package/dist/mandatory/design/SKILL.md +312 -0
- package/dist/mandatory/feature-workflow/SKILL.md +87 -0
- package/dist/mandatory/hotfix/SKILL.md +195 -0
- package/dist/mandatory/pre-push/SKILL.md +272 -0
- package/dist/mandatory/project-context/SKILL.md +180 -0
- package/dist/mandatory/release-docs/SKILL.md +191 -0
- package/dist/mandatory/review-pr/SKILL.md +323 -0
- package/dist/mandatory/security-review/SKILL.md +157 -0
- package/dist/skills/api-contract/SKILL.md +77 -0
- package/dist/skills/backend-django/SKILL.md +27 -0
- package/dist/skills/backend-nestjs/SKILL.md +65 -0
- package/dist/skills/bug-ticket-creation/SKILL.md +43 -0
- package/dist/skills/cloudwatch-troubleshooting/SKILL.md +73 -0
- package/dist/skills/database-migration/SKILL.md +97 -0
- package/dist/skills/debugging/SKILL.md +32 -0
- package/dist/skills/devops-infra/SKILL.md +26 -0
- package/dist/skills/documentation/SKILL.md +24 -0
- package/dist/skills/frontend-nextjs/SKILL.md +27 -0
- package/dist/skills/incident-postmortem/SKILL.md +38 -0
- package/dist/skills/kubernetes-troubleshooting/SKILL.md +71 -0
- package/dist/skills/mobile-react-native/SKILL.md +37 -0
- package/dist/skills/postgres-analytics/SKILL.md +29 -0
- package/dist/skills/product-jira-ticketing/SKILL.md +28 -0
- package/dist/skills/qa-bug-analysis/SKILL.md +27 -0
- package/dist/skills/refactoring/SKILL.md +32 -0
- package/dist/skills/sprint-planning/SKILL.md +32 -0
- package/dist/skills/testing-quality/SKILL.md +62 -0
- package/dist/v2/protocols/agent-orchestration.md +49 -0
- package/dist/v2/protocols/delivery.md +45 -0
- package/dist/v2/protocols/design-authority.md +29 -0
- package/dist/v2/protocols/goal-graph.md +44 -0
- package/dist/v2/protocols/pattern-first-development.md +29 -0
- package/dist/v2/protocols/qa-evidence.md +29 -0
- package/dist/v2/protocols/security.md +29 -0
- package/dist/v2/schemas/event.schema.json +86 -0
- package/dist/v2/schemas/evidence.schema.json +94 -0
- package/dist/v2/schemas/feature-decomposition.schema.json +48 -0
- package/dist/v2/schemas/feature-plan.schema.json +95 -0
- package/dist/v2/schemas/goal-graph.schema.json +61 -0
- package/dist/v2/schemas/integration.schema.json +119 -0
- package/dist/v2/schemas/orchestration.schema.json +69 -0
- package/dist/v2/schemas/project.schema.json +209 -0
- package/dist/v2/schemas/providers.schema.json +142 -0
- package/dist/v2/schemas/quality.schema.json +50 -0
- package/dist/v2/schemas/work-action.schema.json +44 -0
- package/dist/v2/schemas/work-request.schema.json +253 -0
- package/dist/v2/templates/evidence/qa-bundle.json +194 -0
- package/dist/v2/templates/github-actions/rivet-deploy.yml +98 -0
- package/dist/v2/templates/harness/SKILL.md +90 -0
- package/dist/v2/templates/project/.rivet/orchestration.yaml +42 -0
- package/dist/v2/templates/project/.rivet/project.yaml +14 -0
- package/dist/v2/templates/project/.rivet/providers.yaml +8 -0
- package/dist/v2/templates/project/.rivet/quality.yaml +16 -0
- package/package.json +58 -0
- package/protocols/agent-orchestration.md +49 -0
- package/protocols/delivery.md +45 -0
- package/protocols/design-authority.md +29 -0
- package/protocols/goal-graph.md +44 -0
- package/protocols/pattern-first-development.md +29 -0
- package/protocols/qa-evidence.md +29 -0
- package/protocols/security.md +29 -0
- package/schemas/event.schema.json +86 -0
- package/schemas/evidence.schema.json +94 -0
- package/schemas/feature-decomposition.schema.json +48 -0
- package/schemas/feature-plan.schema.json +95 -0
- package/schemas/goal-graph.schema.json +61 -0
- package/schemas/integration.schema.json +119 -0
- package/schemas/orchestration.schema.json +69 -0
- package/schemas/project.schema.json +209 -0
- package/schemas/providers.schema.json +142 -0
- package/schemas/quality.schema.json +50 -0
- package/schemas/work-action.schema.json +44 -0
- package/schemas/work-request.schema.json +253 -0
- package/src/adapters/confluence.js +138 -0
- package/src/adapters/contract.js +657 -0
- package/src/adapters/factory.js +122 -0
- package/src/adapters/figma.js +178 -0
- package/src/adapters/fixtures.js +183 -0
- package/src/adapters/github.js +314 -0
- package/src/adapters/http.js +704 -0
- package/src/adapters/jira.js +195 -0
- package/src/adapters/linear.js +171 -0
- package/src/adapters/node-transport.js +59 -0
- package/src/cli/integration-setup-prompt.js +32 -0
- package/src/cli/interrupt.js +25 -0
- package/src/cli/main.js +596 -0
- package/src/cli/output.js +174 -0
- package/src/cli/parse-args.js +246 -0
- package/src/cli/project-discovery.js +70 -0
- package/src/cli/task-confirmation.js +38 -0
- package/src/cli/task-presentation.js +22 -0
- package/src/clients/claude.js +214 -0
- package/src/clients/codex.js +180 -0
- package/src/clients/compatibility.js +23 -0
- package/src/clients/contract.js +224 -0
- package/src/clients/fake.js +170 -0
- package/src/clients/process-runner.js +657 -0
- package/src/clients/result-contract.js +78 -0
- package/src/commands/delivery-publish.js +80 -0
- package/src/commands/delivery-remote.js +230 -0
- package/src/commands/delivery-review-update.js +39 -0
- package/src/commands/delivery-tracker.js +94 -0
- package/src/commands/delivery-transition.js +79 -0
- package/src/commands/delivery.js +223 -0
- package/src/commands/dependency-approval.js +21 -0
- package/src/commands/doctor.js +191 -0
- package/src/commands/evidence.js +44 -0
- package/src/commands/feature.js +212 -0
- package/src/commands/goals.js +231 -0
- package/src/commands/human-run.js +208 -0
- package/src/commands/human-task.js +278 -0
- package/src/commands/init.js +848 -0
- package/src/commands/install.js +814 -0
- package/src/commands/integration-setup.js +65 -0
- package/src/commands/integrations.js +54 -0
- package/src/commands/models.js +158 -0
- package/src/commands/orchestrate.js +61 -0
- package/src/commands/preflight.js +125 -0
- package/src/commands/protocols.js +228 -0
- package/src/commands/repositories.js +77 -0
- package/src/commands/setup-remote.js +41 -0
- package/src/commands/setup.js +214 -0
- package/src/commands/status.js +224 -0
- package/src/commands/support.js +44 -0
- package/src/commands/task-completion.js +104 -0
- package/src/commands/uninstall.js +234 -0
- package/src/commands/verify.js +171 -0
- package/src/commands/work.js +220 -0
- package/src/commands/worktrees.js +52 -0
- package/src/config/command-readiness.js +218 -0
- package/src/config/commands.js +206 -0
- package/src/config/defaults.js +55 -0
- package/src/config/load.js +230 -0
- package/src/config/validate.js +560 -0
- package/src/delivery/bitbucket-review.js +123 -0
- package/src/delivery/branch-publication.js +23 -0
- package/src/delivery/contract.js +379 -0
- package/src/delivery/github-deployment.js +132 -0
- package/src/delivery/github-review.js +5 -0
- package/src/delivery/github.js +382 -0
- package/src/delivery/gitlab-review.js +5 -0
- package/src/delivery/gitlab.js +395 -0
- package/src/delivery/prepare.js +90 -0
- package/src/delivery/publication-process.js +33 -0
- package/src/delivery/publication-transport.js +112 -0
- package/src/delivery/review-request.js +184 -0
- package/src/delivery/review-update.js +74 -0
- package/src/delivery/service.js +400 -0
- package/src/delivery/store.js +76 -0
- package/src/delivery/tracker-target.js +51 -0
- package/src/delivery/tracker-transition.js +158 -0
- package/src/delivery/tracker.js +164 -0
- package/src/discovery/git.js +85 -0
- package/src/discovery/portable.js +108 -0
- package/src/discovery/project.js +345 -0
- package/src/discovery/tools.js +145 -0
- package/src/evaluations/approval.js +20 -0
- package/src/evaluations/cost-policy.js +20 -0
- package/src/evaluations/harness-attempt.js +113 -0
- package/src/evaluations/live-runner.js +55 -0
- package/src/evaluations/profile.js +28 -0
- package/src/evaluations/report.js +11 -0
- package/src/evaluations/text-attempt.js +18 -0
- package/src/evidence/checksum.js +87 -0
- package/src/evidence/collect.js +727 -0
- package/src/evidence/validate.js +354 -0
- package/src/feature/accepted-integration.js +46 -0
- package/src/feature/actions.js +37 -0
- package/src/feature/client-profile.js +56 -0
- package/src/feature/decomposition-contract.js +58 -0
- package/src/feature/host-execution.js +633 -0
- package/src/feature/host-lock-recovery.js +96 -0
- package/src/feature/host-run-lock.js +32 -0
- package/src/feature/local-approval.js +183 -0
- package/src/feature/plan-contract.js +215 -0
- package/src/feature/planner.js +253 -0
- package/src/feature/run-store.js +241 -0
- package/src/feature/runtime-bridge.js +840 -0
- package/src/feature/verification-report.js +168 -0
- package/src/feature/workflow.js +375 -0
- package/src/git/client.js +509 -0
- package/src/git/integration-worktree.js +153 -0
- package/src/git/reconcile.js +222 -0
- package/src/git/reservations.js +450 -0
- package/src/git/worktrees.js +478 -0
- package/src/graph/completion.js +189 -0
- package/src/graph/fixtures.js +116 -0
- package/src/graph/reducer.js +124 -0
- package/src/graph/scheduler.js +252 -0
- package/src/graph/validate.js +106 -0
- package/src/install/managed.js +579 -0
- package/src/install/project-reference.js +33 -0
- package/src/install/project-runtime.js +142 -0
- package/src/install/runtime-integrity.cjs +141 -0
- package/src/integrations/capabilities.js +69 -0
- package/src/integrations/host-observation.js +26 -0
- package/src/integrations/registry.js +56 -0
- package/src/models/delegate.js +102 -0
- package/src/models/profiles.js +53 -0
- package/src/models/protocols.js +208 -0
- package/src/models/registry.js +83 -0
- package/src/models/transport.js +59 -0
- package/src/policy/approvals.js +251 -0
- package/src/policy/authority.js +282 -0
- package/src/policy/budget.js +149 -0
- package/src/policy/command-bootstrap.js +219 -0
- package/src/policy/commands.js +803 -0
- package/src/prompts/launch-contract.js +43 -0
- package/src/prompts/planning-contract.js +92 -0
- package/src/protocols/presentation.js +53 -0
- package/src/protocols/project.js +289 -0
- package/src/quality/runner.js +497 -0
- package/src/quality/traceability.js +215 -0
- package/src/repositories/identity.js +59 -0
- package/src/repositories/index.js +2 -0
- package/src/repositories/provider.js +210 -0
- package/src/runtime/application.js +353 -0
- package/src/runtime/dependency-directory.js +33 -0
- package/src/runtime/harness-discovery.js +121 -0
- package/src/runtime/heartbeat.js +47 -0
- package/src/runtime/instance-store.js +112 -0
- package/src/runtime/orchestrator.js +1133 -0
- package/src/runtime/portable-dependencies.js +94 -0
- package/src/runtime/recovery.js +190 -0
- package/src/runtime/retry.js +54 -0
- package/src/runtime/supervisor.js +166 -0
- package/src/runtime/worktree-bootstrap.js +169 -0
- package/src/state/event-store.js +333 -0
- package/src/state/lock.js +266 -0
- package/src/state/paths.js +274 -0
- package/src/state/redact.js +106 -0
- package/src/state/snapshot-store.js +310 -0
- package/src/status/public/app.js +96 -0
- package/src/status/public/index.html +37 -0
- package/src/status/public/styles.css +50 -0
- package/src/status/server.js +323 -0
- package/src/status/view-model.js +356 -0
- package/src/support/bundle.js +195 -0
- package/src/support/failure-report.js +96 -0
- package/src/work-request/contract.js +250 -0
- package/src/work-request/host.js +78 -0
- package/src/work-request/local.js +163 -0
- package/src/work-request/tracker.js +105 -0
- package/templates/evidence/qa-bundle.json +194 -0
- package/templates/github-actions/rivet-deploy.yml +98 -0
- package/templates/harness/SKILL.md +90 -0
- package/templates/project/.rivet/orchestration.yaml +42 -0
- package/templates/project/.rivet/project.yaml +14 -0
- package/templates/project/.rivet/providers.yaml +8 -0
- package/templates/project/.rivet/quality.yaml +16 -0
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: rivet-security-review
|
|
3
|
+
description: "Audit code, APIs, or infrastructure for security vulnerabilities — authentication flaws,"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Security Review
|
|
7
|
+
|
|
8
|
+
Audit code, APIs, or infrastructure for security vulnerabilities — authentication flaws,
|
|
9
|
+
injection risks, data exposure, and OWASP Top 10 issues. Runs standalone on demand, and is
|
|
10
|
+
also auto-invoked by `/pre-push` and `/review-pr` whenever a diff touches an auth, payment,
|
|
11
|
+
or user-data path.
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
/security-review
|
|
17
|
+
/security-review <path, file glob, or diff range>
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
With no argument, review the current diff against the default branch. `/pre-push` and
|
|
21
|
+
`/review-pr` invoke this skill's checklist inline against their own diff — they do not shell
|
|
22
|
+
out to a separate `/security-review` call, but the checklist below is the shared source of
|
|
23
|
+
truth both use.
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## Instructions
|
|
28
|
+
|
|
29
|
+
1. Determine scope:
|
|
30
|
+
- Explicit path/glob argument → review those files.
|
|
31
|
+
- Diff range argument → review the diff.
|
|
32
|
+
- No argument → `git diff origin/<default-branch>...HEAD`.
|
|
33
|
+
- Invoked internally by `/pre-push` or `/review-pr` → scope is whatever files/diff the
|
|
34
|
+
caller already flagged as touching a sensitive path.
|
|
35
|
+
|
|
36
|
+
2. Identify context needed to apply the checklist accurately:
|
|
37
|
+
- Application type (web API / mobile backend / internal tool / public-facing)
|
|
38
|
+
- Auth mechanism (JWT / session / OAuth / API key) — infer from the codebase or `CLAUDE.md`
|
|
39
|
+
- Data sensitivity (PII / financial / healthcare / low) — check `CLAUDE.md`'s Sensitive
|
|
40
|
+
Areas section
|
|
41
|
+
- Framework — NestJS / Django / Next.js / other, for the framework-specific checklist notes
|
|
42
|
+
|
|
43
|
+
3. Apply every relevant item in the Security Checklist below. Skip items that don't apply to
|
|
44
|
+
the stack or the code in scope — do not report N/A items as findings.
|
|
45
|
+
|
|
46
|
+
4. Output format (matches `/pre-push` and `/review-pr` severity conventions):
|
|
47
|
+
|
|
48
|
+
```
|
|
49
|
+
## Security Review
|
|
50
|
+
|
|
51
|
+
### 🔴 Critical
|
|
52
|
+
(must fix before shipping — injection, auth bypass, data exposure)
|
|
53
|
+
- <file:line> — <OWASP category> — <what's wrong> — <fix>
|
|
54
|
+
|
|
55
|
+
### 🟡 Warnings
|
|
56
|
+
(should fix soon — weak validation, missing rate limiting)
|
|
57
|
+
- <file:line> — <OWASP category> — <what's wrong> — <fix>
|
|
58
|
+
|
|
59
|
+
### 🟢 Recommendations
|
|
60
|
+
(hardening — CSP headers, input sanitization, logging)
|
|
61
|
+
- <file:line> — <suggestion>
|
|
62
|
+
|
|
63
|
+
### Verification
|
|
64
|
+
How to confirm each Critical/Warning fix works (test cases, tools/commands to run).
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
5. If called from `/pre-push` or `/review-pr`, return only the 🔴/🟡 findings for merging into
|
|
68
|
+
the caller's own Findings section — the caller keeps its own report format and severity
|
|
69
|
+
levels; don't emit a second, separate report block.
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
## Security Checklist
|
|
74
|
+
|
|
75
|
+
Each item is tagged with the relevant [OWASP Top 10 2021](https://owasp.org/Top10/) category:
|
|
76
|
+
**A01** Broken Access Control · **A02** Cryptographic Failures · **A04** Insecure Design · **A05** Security Misconfiguration · **A07** Identification & Authentication Failures · **A09** Security Logging & Monitoring Failures
|
|
77
|
+
|
|
78
|
+
Items marked **[NestJS]**, **[Django]**, or **[Next.js]** have framework-specific notes. Everything else applies to any stack.
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
### Auth & Tokens — A07
|
|
83
|
+
|
|
84
|
+
- [ ] **Refresh tokens in httpOnly cookies, not localStorage** — any XSS script can read `localStorage`. Cookie must have `httpOnly: true`, `Secure: true` (HTTPS), `SameSite: Strict`, and `Path` scoped to the auth route (e.g., `/v1/auth`).
|
|
85
|
+
- **[NestJS]** Use `cookie-parser` middleware + `res.cookie(name, value, options)` in the auth controller. Frontend must pass `credentials: "include"` on all fetch calls.
|
|
86
|
+
- **[Django]** Set `SESSION_COOKIE_HTTPONLY = True`, `SESSION_COOKIE_SECURE = True`, `SESSION_COOKIE_SAMESITE = "Strict"` in `settings.py`. For JWT, write the token in a view using `response.set_cookie(...)` with same flags.
|
|
87
|
+
|
|
88
|
+
- [ ] **Rate limiting on all auth endpoints** — minimum: register ≤3/min, login ≤5/min, forgot-password ≤3/min, reset-password ≤5/min.
|
|
89
|
+
- **[NestJS]** `ThrottlerGuard` must be registered as `APP_GUARD` in `AppModule` (configuring it without registering the guard has no effect). Add `@Throttle({ default: { ttl: 60000, limit: 5 } })` per endpoint.
|
|
90
|
+
- **[Django]** Use `django-ratelimit` (`@ratelimit` decorator) or DRF's `DEFAULT_THROTTLE_CLASSES` with `AnonRateThrottle`/`UserRateThrottle`. For brute-force lockout use `django-axes`.
|
|
91
|
+
|
|
92
|
+
- [ ] **Password complexity beyond min length** — `@MinLength(8)` or `min_length=8` alone allows "12345678". Require at least 1 uppercase, 1 lowercase, 1 digit.
|
|
93
|
+
- **[NestJS]** `@Matches(/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)/)` on register and reset-password DTOs.
|
|
94
|
+
- **[Django]** Add `MinimumLengthValidator` + custom `validate()` function in `AUTH_PASSWORD_VALIDATORS`.
|
|
95
|
+
|
|
96
|
+
- [ ] **Password reset tokens hashed in DB** — store `SHA-256(token)`, send the raw token by email. A DB breach must not allow password reset for any account.
|
|
97
|
+
|
|
98
|
+
- [ ] **Refresh token reuse detection** — when a used token is re-presented, invalidate the entire token family (all sessions for that login chain) and log a warning. Deleting only the latest token on refresh is insufficient.
|
|
99
|
+
|
|
100
|
+
- [ ] **Session/presence cookies HMAC-signed** — a cookie whose value is only checked for presence (`if (!cookie?.value)`) can be forged with `document.cookie = "session=1"`. The value must include a timestamp + HMAC-SHA256 signature verified server-side.
|
|
101
|
+
- **[Next.js]** Verify in `middleware.ts` (or `proxy.ts` for Next.js 16+) using `crypto.subtle`.
|
|
102
|
+
|
|
103
|
+
- [ ] **2FA partial tokens not in sessionStorage** — `sessionStorage` is accessible to XSS. Pass via URL query param (`/verify-2fa?t=<token>`) or keep in React state only.
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
### Input Validation & Mass Assignment — A04
|
|
108
|
+
|
|
109
|
+
- [ ] **Validated schema objects on all request bodies** — TypeScript type annotations (`body: { name?: string }`) are erased at runtime. Inline interfaces provide no runtime validation.
|
|
110
|
+
- **[NestJS]** Always use class-validator DTOs with `@Body() dto: MyDto`. Without this, `ValidationPipe({ whitelist: true })` cannot strip/reject extra fields, enabling mass assignment.
|
|
111
|
+
- **[Django/DRF]** Always use a serializer class — never pass `request.data` directly to `Model.objects.create(**data)`. Set `read_only_fields` to prevent privilege escalation via writable fields.
|
|
112
|
+
|
|
113
|
+
- [ ] **UUID validation on all ID params** — reject malformed IDs at the routing layer before they reach the DB.
|
|
114
|
+
- **[NestJS]** `@Param('id', ParseUUIDPipe)` on every `:id` route param. `@IsUUID()` on UUID fields in DTOs (not just `@IsString()`).
|
|
115
|
+
- **[Django]** Use `<uuid:pk>` URL converter. DRF `UUIDField` on serializer fields.
|
|
116
|
+
|
|
117
|
+
- [ ] **No raw SQL with string interpolation** — use parameterized queries.
|
|
118
|
+
- **[NestJS/Prisma]** Use `` $queryRaw`SELECT * FROM t WHERE id = ${id}` `` (tagged template), not `$queryRawUnsafe`.
|
|
119
|
+
- **[Django]** Use `Model.objects.filter(id=id)` or `cursor.execute(sql, [param])`, never `f"... WHERE id = {id}"`.
|
|
120
|
+
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
### Secrets & Cryptography — A02
|
|
124
|
+
|
|
125
|
+
- [ ] **Sensitive third-party config encrypted at rest** — fields like `apiKey`, `botToken`, `password`, `secret` in an integration/connector config table must be encrypted before DB persistence (AES-256-GCM or equivalent), not stored as plain JSON. A DB dump or SQL injection must not expose all third-party credentials.
|
|
126
|
+
|
|
127
|
+
- [ ] **No PII in log messages** — log generic messages for missing/invalid account scenarios. Write `"password reset for non-existent account"`, not `"password reset for ${email}"`.
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
### Authorization & Tenant Isolation — A01
|
|
132
|
+
|
|
133
|
+
- [ ] **Tenant ID from JWT, not request** — extract `tenantId` from the verified JWT payload, never from request body, query params, or headers. Trusting client-supplied tenant context allows cross-tenant data access.
|
|
134
|
+
- **[NestJS]** `@CurrentUser('tenantId')` decorator.
|
|
135
|
+
- **[Django]** Read from `request.user.tenant_id` set by the authentication backend; reject any `tenant_id` in the request body for scoped queries.
|
|
136
|
+
|
|
137
|
+
- [ ] **All execution paths go through the same authorization layer** — if there is an AI assistant flow and a direct API endpoint performing the same action, both must evaluate the same rules/permissions. Direct API shortcuts that bypass the rules engine are a full authorization bypass.
|
|
138
|
+
|
|
139
|
+
- [ ] **CORS blocks localhost in production** — `http://localhost:*` in the CORS allowlist in production allows local malware or browser extensions to send authenticated cross-origin requests. Allow localhost only when `NODE_ENV !== "production"`.
|
|
140
|
+
|
|
141
|
+
---
|
|
142
|
+
|
|
143
|
+
### Security Logging — A09
|
|
144
|
+
|
|
145
|
+
- [ ] **Audit log user ID field matches JWT payload field names** — if the JWT strategy returns `{ id, tenantId }`, the audit interceptor must read `user.id`, not `user.userId`. A field name mismatch silently writes `null` to every audit record, making forensic investigation impossible.
|
|
146
|
+
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
### Headers & Configuration — A05
|
|
150
|
+
|
|
151
|
+
- [ ] **HTTP security headers active on the backend**
|
|
152
|
+
- **[NestJS]** `app.use(helmet())` in `main.ts` — covers CSP, HSTS, `X-Content-Type-Options`, `X-Frame-Options`, `Referrer-Policy`.
|
|
153
|
+
- **[Django]** `django.middleware.security.SecurityMiddleware` + `SECURE_HSTS_SECONDS`, `SECURE_CONTENT_TYPE_NOSNIFF`, `X_FRAME_OPTIONS = "DENY"`, `django-csp` for Content-Security-Policy.
|
|
154
|
+
|
|
155
|
+
- [ ] **Next.js security headers in `next.config.ts`** — add a `headers()` export with at minimum: `X-Frame-Options: DENY`, `X-Content-Type-Options: nosniff`, `Strict-Transport-Security`, `Content-Security-Policy`, `Referrer-Policy`, `Permissions-Policy`.
|
|
156
|
+
|
|
157
|
+
- [ ] **Auth state directories restricted** — directories storing session keys or auth state files on disk (e.g., OAuth tokens, bot session data) must be `chmod 700` and owned by the service user, not world-readable.
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: rivet-api-contract
|
|
3
|
+
description: "Designing or reviewing API endpoints and schemas; ensuring backward compatibility; writing OpenAPI/Swagger summaries."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Skill: API & Contract
|
|
7
|
+
|
|
8
|
+
## When to use
|
|
9
|
+
Designing or reviewing API endpoints and schemas; ensuring backward compatibility; writing OpenAPI/Swagger summaries.
|
|
10
|
+
|
|
11
|
+
## Prompt template
|
|
12
|
+
You are acting as an API designer.
|
|
13
|
+
|
|
14
|
+
Context:
|
|
15
|
+
- Consumers include web and mobile clients
|
|
16
|
+
- Stability matters: avoid breaking changes
|
|
17
|
+
- Align naming and error formats with existing APIs
|
|
18
|
+
|
|
19
|
+
Task:
|
|
20
|
+
[DESCRIBE ENDPOINT OR CONTRACT CHANGE]
|
|
21
|
+
|
|
22
|
+
Output:
|
|
23
|
+
- Method + path (or GraphQL operation)
|
|
24
|
+
- Request schema (query/body)
|
|
25
|
+
- Response schema (success + error)
|
|
26
|
+
- Versioning/backward compatibility notes
|
|
27
|
+
- Examples (1 request/response)
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## API Contract Standards (enforce on all endpoints)
|
|
32
|
+
|
|
33
|
+
### Response Envelope
|
|
34
|
+
|
|
35
|
+
All endpoints must return a consistent envelope:
|
|
36
|
+
|
|
37
|
+
```json
|
|
38
|
+
{ "success": true, "data": { ... } }
|
|
39
|
+
{ "success": false, "error": { "code": "VALIDATION_ERROR", "message": "..." } }
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Exception: auth token endpoints (login/register/refresh) may return flat `{ accessToken, expiresIn }` if changing would break existing clients.
|
|
43
|
+
|
|
44
|
+
### Tenant Isolation
|
|
45
|
+
|
|
46
|
+
- Extract `tenantId` from the JWT (`@CurrentUser('tenantId')`), never from request body or query params.
|
|
47
|
+
- Every list/get/mutation endpoint must scope DB queries by `tenantId`.
|
|
48
|
+
- Shared infrastructure endpoints (health, servers, system bots) must still require authentication even if data is not per-tenant.
|
|
49
|
+
|
|
50
|
+
### Pagination on List Endpoints
|
|
51
|
+
|
|
52
|
+
Every endpoint returning a collection must support pagination:
|
|
53
|
+
|
|
54
|
+
```text
|
|
55
|
+
GET /resource?limit=50&offset=0
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
- Default limit: 50
|
|
59
|
+
- Max limit: 100 (server-side clamp: `Math.min(Math.max(limit, 1), 100)`)
|
|
60
|
+
- Response: `{ entries: [...], total: N, limit: 50, offset: 0 }`
|
|
61
|
+
- Exception: endpoints where the result set is provably bounded (e.g., per-tenant connectors, likely ≤20 items)
|
|
62
|
+
|
|
63
|
+
### HTTP Status Codes
|
|
64
|
+
|
|
65
|
+
| Operation | Status |
|
|
66
|
+
| --------- | ------ |
|
|
67
|
+
| POST (create) | 201 Created |
|
|
68
|
+
| GET, PATCH, PUT | 200 OK |
|
|
69
|
+
| DELETE | 200 OK (with body) or 204 No Content |
|
|
70
|
+
| Rate limit exceeded | 429 Too Many Requests |
|
|
71
|
+
| Rules engine deny | 403 Forbidden |
|
|
72
|
+
| Validation failure | 400 Bad Request |
|
|
73
|
+
|
|
74
|
+
### Param Validation
|
|
75
|
+
|
|
76
|
+
- All `:id` path params: `@Param('id', ParseUUIDPipe)` — rejects non-UUID strings before DB layer
|
|
77
|
+
- Query params with type expectations: use `@Query('limit', new DefaultValuePipe(50), ParseIntPipe)`
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: rivet-backend-django
|
|
3
|
+
description: "For implementing or extending Django + Django REST Framework backend features including models, serializers, views, perm"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Skill: Backend (Django / DRF)
|
|
7
|
+
|
|
8
|
+
## When to use
|
|
9
|
+
For implementing or extending Django + Django REST Framework backend features including models, serializers, views, permissions, and migrations.
|
|
10
|
+
|
|
11
|
+
## Prompt template
|
|
12
|
+
You are acting as a senior Django backend engineer.
|
|
13
|
+
|
|
14
|
+
Context:
|
|
15
|
+
- Framework: Django + Django REST Framework
|
|
16
|
+
- Follow existing project structure and naming conventions
|
|
17
|
+
- Prefer serializers for validation and API contracts
|
|
18
|
+
- Maintain backward compatibility unless explicitly requested
|
|
19
|
+
|
|
20
|
+
Task:
|
|
21
|
+
[DESCRIBE BACKEND TASK]
|
|
22
|
+
|
|
23
|
+
Output:
|
|
24
|
+
- Proposed approach
|
|
25
|
+
- Django code (models, serializers, views, urls)
|
|
26
|
+
- Migration notes if required
|
|
27
|
+
- Edge cases and validation considerations
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: rivet-backend-nestjs
|
|
3
|
+
description: "For implementing or extending NestJS services (REST or GraphQL), controllers/resolvers, DTO validation, modules, and int"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Skill: Backend (NestJS)
|
|
7
|
+
|
|
8
|
+
## When to use
|
|
9
|
+
For implementing or extending NestJS services (REST or GraphQL), controllers/resolvers, DTO validation, modules, and integration patterns.
|
|
10
|
+
|
|
11
|
+
## What to provide
|
|
12
|
+
- Framework version (if relevant)
|
|
13
|
+
- Transport (REST / GraphQL)
|
|
14
|
+
- Auth strategy (JWT, sessions, etc.)
|
|
15
|
+
- DB access layer (Prisma/TypeORM/knex) and conventions
|
|
16
|
+
- Error handling conventions
|
|
17
|
+
- Any existing module structure
|
|
18
|
+
|
|
19
|
+
## Prompt template
|
|
20
|
+
You are acting as a senior NestJS backend engineer.
|
|
21
|
+
|
|
22
|
+
Context:
|
|
23
|
+
- Codebase uses NestJS with TypeScript
|
|
24
|
+
- Follow existing module boundaries and naming conventions
|
|
25
|
+
- Prefer DTO validation (class-validator / zod / existing standard)
|
|
26
|
+
- Keep APIs backward compatible unless explicitly instructed
|
|
27
|
+
- Include structured error responses
|
|
28
|
+
|
|
29
|
+
Task:
|
|
30
|
+
[DESCRIBE THE BACKEND TASK]
|
|
31
|
+
|
|
32
|
+
Constraints:
|
|
33
|
+
- [LIST CONSTRAINTS: perf, security, no breaking changes, etc.]
|
|
34
|
+
|
|
35
|
+
Output:
|
|
36
|
+
- Proposed approach (short)
|
|
37
|
+
- Code: modules/controllers/services/DTOs
|
|
38
|
+
- Edge cases and error handling
|
|
39
|
+
- Notes on config/env and migrations if relevant
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## NestJS Common Pitfalls (enforce these in every task)
|
|
44
|
+
|
|
45
|
+
### DTOs & Validation
|
|
46
|
+
- **Never use inline TypeScript types on `@Body()`** — `@Body() body: { name?: string }` is erased at runtime. `ValidationPipe({ whitelist: true })` cannot strip/reject fields without class-validator decorators. Always create a DTO class.
|
|
47
|
+
- **`ParseUUIDPipe` on all `:id` params** — `@Param('id', ParseUUIDPipe)` rejects malformed UUIDs as 400 before they reach the DB layer.
|
|
48
|
+
- **`@IsUUID()` on UUID fields in DTOs** — `@IsString()` alone accepts any string; use `@IsUUID()` for FK/reference fields.
|
|
49
|
+
- **`@HttpCode` on every mutating endpoint** — POST → `201`, DELETE/action endpoints → `200`. NestJS defaults POST to 200, which is wrong.
|
|
50
|
+
|
|
51
|
+
### Module Architecture
|
|
52
|
+
- **Explicit module imports, not `@Global()`** — only infrastructure modules (Prisma, Config) should be `@Global()`. Business modules must declare their dependencies in `imports[]`. Invisible global dependencies break at runtime if `@Global()` is ever removed.
|
|
53
|
+
- **No duplicate class names across modules** — two `CreateTenantDto` with different fields cause silent bugs when imported from the wrong path. Prefix admin variants: `AdminCreateTenantDto`.
|
|
54
|
+
- **No dead code modules** — modules that are never imported in `AppModule` or any other module should be deleted, not left as dead `@Global()` exports.
|
|
55
|
+
|
|
56
|
+
### State Management
|
|
57
|
+
- **No mutable singleton state in services** — methods like `setApiKey(key)` that mutate `this.apiKey` race under concurrent requests. Pass secrets as parameters instead.
|
|
58
|
+
- **Controller-level Maps need lifecycle cleanup** — if a controller holds Maps (rate limiting, connection tracking), implement `OnModuleDestroy` and clean up entries to prevent memory leaks.
|
|
59
|
+
|
|
60
|
+
### Response Format
|
|
61
|
+
- **All endpoints return `{ success: true, data }` envelope** — auth token endpoints (login/register) may return flat structure for client compatibility, but all other endpoints must wrap responses.
|
|
62
|
+
|
|
63
|
+
### Logging
|
|
64
|
+
- **Audit log field names must match JWT payload** — if `JwtStrategy` returns `{ id, tenantId, email }`, use `user?.id` not `user?.userId`. A field name mismatch silently produces `null` in all audit entries.
|
|
65
|
+
- **No PII in log messages** — use generic messages for missing-account scenarios. Log `"password reset for non-existent account"`, not `"password reset for ${email}"`.
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: rivet-bug-ticket-creation
|
|
3
|
+
description: "Creating Jira-ready bug tickets from any source — postmortem action items, debugging findings, monitoring alerts, or ad-"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Skill: Bug Ticket Creation (Jira)
|
|
7
|
+
|
|
8
|
+
## When to use
|
|
9
|
+
Creating Jira-ready bug tickets from any source — postmortem action items, debugging findings, monitoring alerts, or ad-hoc discoveries during development.
|
|
10
|
+
|
|
11
|
+
## Prompt template
|
|
12
|
+
You are acting as an engineer creating a Jira bug ticket.
|
|
13
|
+
|
|
14
|
+
Input:
|
|
15
|
+
[PASTE POSTMORTEM ACTION ITEMS / DEBUGGING FINDINGS / ALERT DETAILS / BUG DESCRIPTION]
|
|
16
|
+
|
|
17
|
+
Context:
|
|
18
|
+
- Jira is the system of record
|
|
19
|
+
- Tickets should be actionable and self-contained — another engineer should be able to pick it up without extra context
|
|
20
|
+
- Reference the source (postmortem doc, incident ID, alert name) if available
|
|
21
|
+
|
|
22
|
+
Task:
|
|
23
|
+
Create one or more Jira-ready bug tickets.
|
|
24
|
+
|
|
25
|
+
Output per ticket:
|
|
26
|
+
- **Title**: short, specific (e.g., "Fix race condition in token refresh causing 401s under load")
|
|
27
|
+
- **Type**: Bug
|
|
28
|
+
- **Priority**: Critical / High / Medium / Low
|
|
29
|
+
- **Labels**: [postmortem, incident-followup, monitoring, tech-debt, etc.]
|
|
30
|
+
- **Description**:
|
|
31
|
+
- What happened / what's broken
|
|
32
|
+
- Root cause (if known)
|
|
33
|
+
- How it was discovered (postmortem, alert, user report, code review)
|
|
34
|
+
- **Steps to reproduce** (if applicable)
|
|
35
|
+
- **Expected vs actual behavior**
|
|
36
|
+
- **Affected services / components**
|
|
37
|
+
- **Environment**: dev / staging / production
|
|
38
|
+
- **Acceptance criteria**:
|
|
39
|
+
- [ ] Bug is resolved
|
|
40
|
+
- [ ] Regression test added
|
|
41
|
+
- [ ] Monitoring/alert covers this scenario
|
|
42
|
+
- **Linked tickets**: related incident, parent epic, or postmortem doc
|
|
43
|
+
- **Assignee suggestion**: team or area owner based on affected component
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: rivet-cloudwatch-troubleshooting
|
|
3
|
+
description: "Investigating issues on EC2-hosted services where logs are shipped to CloudWatch — pulling logs, checking instance healt"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Skill: CloudWatch & EC2 Troubleshooting
|
|
7
|
+
|
|
8
|
+
## When to use
|
|
9
|
+
Investigating issues on EC2-hosted services where logs are shipped to CloudWatch — pulling logs, checking instance health, and diagnosing application or infrastructure failures.
|
|
10
|
+
|
|
11
|
+
## Prerequisites
|
|
12
|
+
- AWS CLI installed locally
|
|
13
|
+
- AWS profile configured with access to CloudWatch Logs, EC2, and relevant services
|
|
14
|
+
- Know the log group name(s) for the target service
|
|
15
|
+
|
|
16
|
+
## Prompt template
|
|
17
|
+
You are acting as an SRE investigating an issue on EC2-hosted services using CloudWatch.
|
|
18
|
+
|
|
19
|
+
Input:
|
|
20
|
+
[DESCRIBE THE ISSUE: service errors, high latency, instance unreachable, deployment failure, etc.]
|
|
21
|
+
|
|
22
|
+
Context:
|
|
23
|
+
- AWS profile: [profile name]
|
|
24
|
+
- Region: [e.g., eu-west-1]
|
|
25
|
+
- Log group: [e.g., /app/api-service or /var/log/syslog]
|
|
26
|
+
- EC2 instance ID(s): [if known]
|
|
27
|
+
- Environment: [dev / staging / production]
|
|
28
|
+
|
|
29
|
+
Task:
|
|
30
|
+
Investigate the issue using AWS CLI.
|
|
31
|
+
|
|
32
|
+
### Investigation steps
|
|
33
|
+
|
|
34
|
+
1. **Find the log group and streams**
|
|
35
|
+
- `aws logs describe-log-groups --profile <profile> --region <region> --log-group-name-prefix <prefix>`
|
|
36
|
+
- `aws logs describe-log-streams --log-group-name <group> --profile <profile> --region <region> --order-by LastEventTime --descending --limit 10`
|
|
37
|
+
|
|
38
|
+
2. **Pull recent logs**
|
|
39
|
+
- `aws logs tail <log-group> --profile <profile> --region <region> --since 30m`
|
|
40
|
+
- `aws logs tail <log-group> --profile <profile> --region <region> --since 30m --follow` — live tail
|
|
41
|
+
- `aws logs filter-log-events --log-group-name <group> --filter-pattern "ERROR" --profile <profile> --region <region> --start-time <epoch-ms>` — filter for errors
|
|
42
|
+
|
|
43
|
+
3. **Check EC2 instance health**
|
|
44
|
+
- `aws ec2 describe-instance-status --instance-ids <id> --profile <profile> --region <region>`
|
|
45
|
+
- `aws ec2 describe-instances --instance-ids <id> --profile <profile> --region <region> --query 'Reservations[].Instances[].{State:State.Name,Type:InstanceType,LaunchTime:LaunchTime}'`
|
|
46
|
+
|
|
47
|
+
4. **Check CloudWatch metrics**
|
|
48
|
+
- `aws cloudwatch get-metric-statistics --namespace AWS/EC2 --metric-name CPUUtilization --dimensions Name=InstanceId,Value=<id> --start-time <ISO> --end-time <ISO> --period 300 --statistics Average --profile <profile> --region <region>`
|
|
49
|
+
- Key metrics: CPUUtilization, StatusCheckFailed, NetworkIn/Out, DiskReadOps
|
|
50
|
+
|
|
51
|
+
5. **Check CloudWatch alarms**
|
|
52
|
+
- `aws cloudwatch describe-alarms --state-value ALARM --profile <profile> --region <region>`
|
|
53
|
+
|
|
54
|
+
6. **Check system logs (if accessible)**
|
|
55
|
+
- `aws ec2 get-console-output --instance-id <id> --profile <profile> --region <region>` — boot/kernel logs
|
|
56
|
+
- Check `/var/log/` log groups if system logs are shipped to CloudWatch
|
|
57
|
+
|
|
58
|
+
### Common patterns
|
|
59
|
+
- **OOM**: look for "Out of memory" or "Killed process" in system logs, check memory metrics
|
|
60
|
+
- **Disk full**: check DiskSpaceUtilization custom metric or `/var/log/messages`
|
|
61
|
+
- **App crash loop**: filter for repeated startup/shutdown log patterns
|
|
62
|
+
- **Network issues**: check StatusCheckFailed_System, security groups, NACLs
|
|
63
|
+
|
|
64
|
+
### Output
|
|
65
|
+
- **Status summary**: instance and application health
|
|
66
|
+
- **Root cause**: what the logs and metrics indicate
|
|
67
|
+
- **Fix recommendation**: restart, resize, config change, or code fix
|
|
68
|
+
- **Commands run**: list of commands and key output for the postmortem record
|
|
69
|
+
|
|
70
|
+
### Related skills
|
|
71
|
+
- For analyzing the root cause after gathering data: see `debugging.md`
|
|
72
|
+
- For writing up the incident afterward: see `incident-postmortem.md`
|
|
73
|
+
- For Kubernetes-based services: see `kubernetes-troubleshooting.md`
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: rivet-database-migration
|
|
3
|
+
description: "Designing new tables/columns, writing safe migrations, or reviewing schema changes for correctness and backward compatib"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Skill: Database Migration & Schema Design
|
|
7
|
+
|
|
8
|
+
## When to use
|
|
9
|
+
|
|
10
|
+
Designing new tables/columns, writing safe migrations, or reviewing schema changes for correctness and backward compatibility.
|
|
11
|
+
|
|
12
|
+
## Prompt template
|
|
13
|
+
|
|
14
|
+
You are acting as a database engineer planning a schema change.
|
|
15
|
+
|
|
16
|
+
Input:
|
|
17
|
+
[DESCRIBE THE DATA REQUIREMENT OR PASTE EXISTING SCHEMA]
|
|
18
|
+
|
|
19
|
+
Context:
|
|
20
|
+
|
|
21
|
+
- Database: [PostgreSQL / MySQL / other]
|
|
22
|
+
- ORM: [Prisma / TypeORM / Django ORM / knex / raw SQL]
|
|
23
|
+
- Environment: changes must be deployable with zero downtime
|
|
24
|
+
- Existing data: [empty table / has production data / approximate row count]
|
|
25
|
+
|
|
26
|
+
Task:
|
|
27
|
+
Design the schema change and write a safe migration.
|
|
28
|
+
|
|
29
|
+
Output:
|
|
30
|
+
|
|
31
|
+
- **Schema design**: tables, columns, types, constraints, indexes
|
|
32
|
+
- **Migration SQL or ORM migration**: forward and rollback
|
|
33
|
+
- **Data migration**: if existing rows need transformation
|
|
34
|
+
- **Deployment strategy**: ordering (migrate before deploy vs after), backfill steps
|
|
35
|
+
- **Zero-downtime notes**: nullable columns first, backfill, then add constraints
|
|
36
|
+
- **Risks**: data loss scenarios, locking concerns on large tables
|
|
37
|
+
- **Validation**: queries to verify migration succeeded
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## Schema Design Checklist
|
|
42
|
+
|
|
43
|
+
### Enums vs Strings
|
|
44
|
+
|
|
45
|
+
Use a PostgreSQL enum (or ORM enum) whenever a column holds a finite, known set of values.
|
|
46
|
+
String columns silently accept typos and invalid values with no DB-level enforcement.
|
|
47
|
+
|
|
48
|
+
Common candidates to audit: `status`, `plan`, `type`, `decision`, `severity`, `channel`, `invoiceType`, `paymentType`.
|
|
49
|
+
|
|
50
|
+
Migration pattern (PostgreSQL):
|
|
51
|
+
|
|
52
|
+
```sql
|
|
53
|
+
CREATE TYPE offer_status AS ENUM ('DRAFT', 'SENT', 'PAID', 'CANCELLED');
|
|
54
|
+
ALTER TABLE offers ALTER COLUMN status TYPE offer_status USING status::text::offer_status;
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Foreign Key Constraints
|
|
58
|
+
|
|
59
|
+
Every column that references another table's `id` must have an explicit FK constraint with a cascade rule.
|
|
60
|
+
Missing FKs allow orphaned rows to accumulate silently.
|
|
61
|
+
|
|
62
|
+
- `ON DELETE CASCADE` — child rows deleted when parent is deleted (e.g., refresh tokens when device is deleted)
|
|
63
|
+
- `ON DELETE SET NULL` — nullable FK set to null (e.g., audit log `approvedBy` when user is deleted)
|
|
64
|
+
- `ON DELETE RESTRICT` — default; block deletion if children exist
|
|
65
|
+
|
|
66
|
+
Before adding a FK to an existing column, clean orphaned rows first:
|
|
67
|
+
|
|
68
|
+
```sql
|
|
69
|
+
DELETE FROM child_table WHERE parent_id NOT IN (SELECT id FROM parent_table);
|
|
70
|
+
ALTER TABLE child_table ADD CONSTRAINT fk_parent FOREIGN KEY (parent_id) REFERENCES parent_table(id) ON DELETE CASCADE;
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Composite Unique Constraints
|
|
74
|
+
|
|
75
|
+
For tenant-scoped uniqueness (e.g., same phone number allowed across tenants, but not within one):
|
|
76
|
+
|
|
77
|
+
```sql
|
|
78
|
+
ALTER TABLE contacts ADD CONSTRAINT uq_tenant_phone UNIQUE (tenant_id, phone);
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
PostgreSQL correctly allows multiple `NULL` values in unique constraints, so nullable fields are safe.
|
|
82
|
+
|
|
83
|
+
### Indexes Checklist
|
|
84
|
+
|
|
85
|
+
Add indexes for every common query pattern. Missing indexes cause sequential scans as tables grow.
|
|
86
|
+
|
|
87
|
+
| Query pattern | Index type |
|
|
88
|
+
| ------------- | ---------- |
|
|
89
|
+
| `WHERE tenant_id = ? AND is_enabled = true` | Composite `(tenant_id, is_enabled)` |
|
|
90
|
+
| `WHERE tenant_id = ? AND status = ?` | Composite `(tenant_id, status)` |
|
|
91
|
+
| `WHERE user_id = ?` | Single `(user_id)` |
|
|
92
|
+
| `WHERE expires_at < NOW()` (cleanup jobs) | Single `(expires_at)` |
|
|
93
|
+
| Unique lookup by token | Unique constraint (already creates index — don't add a redundant `@@index`) |
|
|
94
|
+
|
|
95
|
+
### Redundant Indexes
|
|
96
|
+
|
|
97
|
+
A `@unique` constraint already creates a B-tree index. Adding an explicit `@@index` on the same column is redundant overhead — remove the duplicate.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: rivet-debugging
|
|
3
|
+
description: "Investigating production errors, unexpected behavior, or failing tests by systematically narrowing down the root cause f"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Skill: Debugging & Root Cause Analysis
|
|
7
|
+
|
|
8
|
+
## When to use
|
|
9
|
+
Investigating production errors, unexpected behavior, or failing tests by systematically narrowing down the root cause from symptoms.
|
|
10
|
+
|
|
11
|
+
## Prompt template
|
|
12
|
+
You are acting as a senior engineer debugging an issue.
|
|
13
|
+
|
|
14
|
+
Input:
|
|
15
|
+
[PASTE ERROR LOGS / STACK TRACES / USER REPORT / FAILING TEST OUTPUT]
|
|
16
|
+
|
|
17
|
+
Context:
|
|
18
|
+
- Service/component affected: [name]
|
|
19
|
+
- Environment: [dev / staging / production]
|
|
20
|
+
- When it started: [timestamp / deployment / change that may have triggered it]
|
|
21
|
+
- What has been tried so far: [any prior investigation]
|
|
22
|
+
|
|
23
|
+
Task:
|
|
24
|
+
Perform structured root cause analysis.
|
|
25
|
+
|
|
26
|
+
Output:
|
|
27
|
+
- **Symptom summary**: what is observed
|
|
28
|
+
- **Hypotheses**: ranked list of likely causes (most probable first)
|
|
29
|
+
- **Investigation steps**: specific commands, queries, or checks to confirm each hypothesis
|
|
30
|
+
- **Root cause**: confirmed or best-guess cause with evidence
|
|
31
|
+
- **Fix recommendation**: proposed solution with code or config changes
|
|
32
|
+
- **Prevention**: how to avoid recurrence (tests, alerts, guards)
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: rivet-devops-infra
|
|
3
|
+
description: "For Docker, CI/CD, environment separation, monitoring/logging, and deployment procedures."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Skill: Infrastructure & DevOps
|
|
7
|
+
|
|
8
|
+
## When to use
|
|
9
|
+
For Docker, CI/CD, environment separation, monitoring/logging, and deployment procedures.
|
|
10
|
+
|
|
11
|
+
## Prompt template
|
|
12
|
+
You are acting as a DevOps engineer.
|
|
13
|
+
|
|
14
|
+
Context:
|
|
15
|
+
- Services include NestJS API and React Native build pipeline
|
|
16
|
+
- Environments: dev / stage / prod
|
|
17
|
+
- Follow security best practices (least privilege, secrets management)
|
|
18
|
+
|
|
19
|
+
Task:
|
|
20
|
+
[DESCRIBE INFRA / PIPELINE NEED]
|
|
21
|
+
|
|
22
|
+
Output:
|
|
23
|
+
- Proposed config (Docker/CI)
|
|
24
|
+
- Environment variables and secrets handling
|
|
25
|
+
- Rollback strategy
|
|
26
|
+
- Monitoring/logging notes
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: rivet-documentation
|
|
3
|
+
description: "Writing runbooks, architecture notes, onboarding docs, release notes, or decision records."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Skill: Documentation & Knowledge
|
|
7
|
+
|
|
8
|
+
## When to use
|
|
9
|
+
Writing runbooks, architecture notes, onboarding docs, release notes, or decision records.
|
|
10
|
+
|
|
11
|
+
## Prompt template
|
|
12
|
+
You are acting as a technical writer.
|
|
13
|
+
|
|
14
|
+
Context:
|
|
15
|
+
- Audience: engineers, QA, product, operations
|
|
16
|
+
- Documentation must reflect real behavior and be maintainable
|
|
17
|
+
|
|
18
|
+
Task:
|
|
19
|
+
[DESCRIBE DOC TO CREATE/UPDATE]
|
|
20
|
+
|
|
21
|
+
Output:
|
|
22
|
+
- Doc content with clear sections
|
|
23
|
+
- Examples/snippets where useful
|
|
24
|
+
- Links placeholders for related docs
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: rivet-frontend-nextjs
|
|
3
|
+
description: "For implementing Next.js frontend pages, components, API integrations, and performance‑optimized UI behavior."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Skill: Frontend (Next.js)
|
|
7
|
+
|
|
8
|
+
## When to use
|
|
9
|
+
For implementing Next.js frontend pages, components, API integrations, and performance‑optimized UI behavior.
|
|
10
|
+
|
|
11
|
+
## Prompt template
|
|
12
|
+
You are acting as a senior Next.js frontend engineer.
|
|
13
|
+
|
|
14
|
+
Context:
|
|
15
|
+
- Next.js + React + TypeScript
|
|
16
|
+
- Follow existing design system and component patterns
|
|
17
|
+
- Handle loading, error, and empty states properly
|
|
18
|
+
- Ensure API contract alignment with backend
|
|
19
|
+
|
|
20
|
+
Task:
|
|
21
|
+
[DESCRIBE FRONTEND TASK]
|
|
22
|
+
|
|
23
|
+
Output:
|
|
24
|
+
- Component or page implementation
|
|
25
|
+
- Types/interfaces
|
|
26
|
+
- Data fetching logic
|
|
27
|
+
- Integration notes
|