feat(rules): Supabase and cloud-functions bodies become path rules, one always-on line each

This commit is contained in:
bchanot committed 2026-10-29 13:03:31 +01:00
1 parent 2fe5291a13
commit 664d1ea839
5 files changed
+36 -13

No files matched your search

+1 -1
View File
@@ -24,7 +24,7 @@ Gather context. Produce complete PROJECT BRIEF as single source of truth.
| "I don't know / you decide" | Propose ONE concrete default + why, ask yes/no | Take the default, mark `(assumed)`, list in OPEN DECISIONS | | "I don't know / you decide" | Propose ONE concrete default + why, ask yes/no | Take the default, mark `(assumed)`, list in OPEN DECISIONS |
| Contradictory answers (e.g. embedded runtime + managed cloud DB) | Name the contradiction, ask which side wins | Put BOTH options in OPEN DECISIONS; do not silently pick one | | Contradictory answers (e.g. embedded runtime + managed cloud DB) | Name the contradiction, ask which side wins | Put BOTH options in OPEN DECISIONS; do not silently pick one |
| Language not stated (new project / from scratch / whole-project rewrite) | Propose Rust + why (`~/.claude/lib/architecture-defaults.md` § Default language); name the contraindication if another language fits better (browser frontend, mandated platform, missing ecosystem) | Rust, marked `(assumed)`, listed in OPEN DECISIONS | | Language not stated (new project / from scratch / whole-project rewrite) | Propose Rust + why (`~/.claude/lib/architecture-defaults.md` § Default language); name the contraindication if another language fits better (browser frontend, mandated platform, missing ecosystem) | Rust, marked `(assumed)`, listed in OPEN DECISIONS |
| Project has an API, a database, messaging, cloud functions or a UI | Apply `rules/secure-by-default.md`: note under QUALITY which of the six guardrail domains apply, and whether the accessibility baseline (`rules/a11y.md`) applies, and list each dashboard-only item (spend cap, WAF, budget alert) in OPEN DECISIONS as manual | A domain applies and nothing is planned: list it in OPEN DECISIONS, never drop it silently | | Project has an API, a database, messaging, cloud functions or a UI | Apply `rules/secure-by-default.md` (Supabase and cloud-function detail: `rules/supabase.md`, `rules/cloud-functions.md`): note under QUALITY which of the six guardrail domains apply, and whether the accessibility baseline (`rules/a11y.md`) applies, and list each dashboard-only item (spend cap, WAF, budget alert) in OPEN DECISIONS as manual | A domain applies and nothing is planned: list it in OPEN DECISIONS, never drop it silently |
| Partial answer to the block | Re-ask ONLY the missing items in the follow-up round | Missing fields → `none stated` + OPEN DECISIONS entry | | Partial answer to the block | Re-ask ONLY the missing items in the follow-up round | Missing fields → `none stated` + OPEN DECISIONS entry |
| Feature list balloons (>10) | Keep the 10 the user ranks first as V1 | Overflow goes to OUT OF SCOPE with a `(deferred by budget)` tag | | Feature list balloons (>10) | Keep the 10 the user ranks first as V1 | Overflow goes to OUT OF SCOPE with a `(deferred by budget)` tag |
+13
View File
@@ -0,0 +1,13 @@
---
paths: ["**/functions/**", "**/serverless.*", "**/firebase.json"]
---
# Cloud functions — secure by default, domain 6
Path-scoped body of `rules/secure-by-default.md` domain 6 (BDR-125 phase 1);
the always-on line there keeps the instance cap and the self-trigger ban.
- No function re-triggers itself: never write to the resource that fires it,
never invoke itself. If unavoidable, guard with an idempotency flag.
- Max instances (or reserved concurrency) and a timeout on every function.
- Budget alert wired to an automatic stop beyond the budget.
+4 -11
View File
@@ -39,13 +39,8 @@ never claimed done: write it as a manual step in the project's deploy notes.
comments carry no token, hash, key or secret. comments carry no token, hash, key or secret.
## 4. Supabase ## 4. Supabase
- RLS enabled on every table, in the migration that creates it. - RLS on every table, never a service_role or secret key client-side. Full
- Policies limited to the owner: `(select auth.uid())` per operation, role domain: rules/supabase.md (loads on Supabase files).
`authenticated`. No `using (true)` on writes, no anon write.
- No `service_role` or secret key client-side: not in a bundle, not in a
`NEXT_PUBLIC_`, `VITE_` or `PUBLIC_` variable.
- Views `security_invoker`. `security definer` functions pin `search_path`
and revoke execute from anon. Buckets private by default.
## 5. SMS and email ## 5. SMS and email
- Prior consent recorded per contact: who, when, channel, source, wording. - Prior consent recorded per contact: who, when, channel, source, wording.
@@ -54,7 +49,5 @@ never claimed done: write it as a manual step in the project's deploy notes.
SMS says STOP, and a STOP reply is processed and stored automatically. SMS says STOP, and a STOP reply is processed and stored automatically.
## 6. Cloud functions ## 6. Cloud functions
- No function re-triggers itself: never write to the resource that fires it, - Max instances and a timeout on every function, never a self-trigger. Full
never invoke itself. If unavoidable, guard with an idempotency flag. domain: rules/cloud-functions.md (loads on function files).
- Max instances (or reserved concurrency) and a timeout on every function.
- Budget alert wired to an automatic stop beyond the budget.
+16
View File
@@ -0,0 +1,16 @@
---
paths: ["**/supabase/**", "**/*supabase*.*"]
---
# Supabase — secure by default, domain 4
Path-scoped body of `rules/secure-by-default.md` domain 4 (BDR-125 phase 1);
the always-on line there keeps RLS and the client-side key ban.
- RLS enabled on every table, in the migration that creates it.
- Policies limited to the owner: `(select auth.uid())` per operation, role
`authenticated`. No `using (true)` on writes, no anon write.
- No `service_role` or secret key client-side: not in a bundle, not in a
`NEXT_PUBLIC_`, `VITE_` or `PUBLIC_` variable.
- Views `security_invoker`. `security definer` functions pin `search_path`
and revoke execute from anon. Buckets private by default.
+2 -1
View File
@@ -7,7 +7,8 @@ argument-hint: '[project path] [--domain api,hosting,supabase,messaging,function
# /guardrails # /guardrails
Checks a project against `rules/secure-by-default.md`, then fixes what the Checks a project against `rules/secure-by-default.md` (domains 4 and 6 in
full: `rules/supabase.md`, `rules/cloud-functions.md`), then fixes what the
user accepts and proves each fix. A scanner reads the tree as data and finds user accepts and proves each fix. A scanner reads the tree as data and finds
what text can prove. This skill judges the hits, covers what text cannot what text can prove. This skill judges the hits, covers what text cannot
prove, lists what only a dashboard can set and, on request, probes a running prove, lists what only a dashboard can set and, on request, probes a running