diff --git a/.claude/memory/decisions.md b/.claude/memory/decisions.md index c81ef85..13013bc 100644 --- a/.claude/memory/decisions.md +++ b/.claude/memory/decisions.md @@ -137,6 +137,8 @@ rules: | BDR-117 | 2026-10-12 | shared gstack helpers live in lib/gstack-removed.sh, not in a new lib | accepted | | BDR-118 | 2026-10-12 | Rust default language for new projects / whole-project rewrites, always-on rule file | accepted | | BDR-119 | 2026-10-16 | impeccable = Build path for all UI; GATE-BLOCK swaps frontend-design for impeccable | accepted | +| BDR-120 | 2026-10-18 | Secure-by-default guardrails: always-on rule file + /guardrails stdlib scanner, passwords in api domain | accepted | +| BDR-121 | 2026-10-18 | Guardrails fix loop reuses bugfix circuit; scanner = contract oracle, baseline re-pass | accepted | --- @@ -1448,3 +1450,15 @@ Branch feature/user-writing-web-rules, UNMERGED (human gate). - **Alternatives rejected**: both in gate (conflict: frontend-design lets brief earn an eyebrow, impeccable bans it); uninstall frontend-design (loses light path); impeccable non-blocking (gate stays blind to the main tool). - **Residual**: model-router has no impeccable row (frontend-design = `reflect`); census test pins the table, own change. - **Refs**: branch chore/impeccable-build-path. Supersedes TODO 2026-07-05 call (no BDR). Links [[BDR-094]] [[BDR-025]] [[BDR-105]]. + +## BDR-120 — Secure-by-default guardrails: always-on rule + /guardrails scanner [accepted] (2026-10-18) +- **Decision**: 5 domains (hosting, a11y, Supabase, SMS/email, cloud functions) + API/access hygiene = baseline every project. Rule `rules/secure-by-default.md` always-on, no `paths:` (CLAUDE.global.md at 320/320, BDR-085 path). `/guardrails` = stdlib py scanner (`skills/guardrails/scripts/scan.py`, FAIL/WARN/MANUAL, exit 1 on FAIL, read-only, never runs project code) + judgment + `.claude/audits/GUARDRAILS.md`. security-auditor gate runs `api,supabase`; FAIL → HIGH, secret/service_role/password-plaintext → CRITICAL. Passwords folded into api domain on user question, not sixth domain: same gate, same CRITICAL path. +- **Why**: user ask. Dashboard-only items (spend cap, WAF, budget stop) stay MANUAL, never claimed done. Scanner proves absence of protection, never presence of security; clean scan = "no static finding". Calibrated on 8 real projects, each FP class fixed + locked by benign test. +- **Alternatives rejected**: Rust scanner (interpreted skill script, no build step, default-language contraindication, same rank as explain-diff checker); section in CLAUDE.global.md (budget); `paths:`-scoped rule (never fires in chat/brainstorm); semgrep rules only (blind to migrations, policies, consent flow). +- **Refs**: branch feature/secure-by-default, suite `lib/tests/guardrails-scan.test.sh` (89 checks). Links [[BDR-085]] [[BDR-118]]. + +## BDR-121 — Guardrails fix loop reuses the bugfix circuit, scanner = oracle [accepted] (2026-10-18) +- **Decision**: after report, proposals (route plan) -> prose approval gate -> bugfixer + verify-secure gates -> re-pass. Each accepted fix = contract criterion, CHECK = `scan.py --assert-absent RULE:path` (marker GUARDRAILS-CLEAR, positive control: fails before fix). Re-pass = `--baseline` vs pre-fix scan (GUARDRAILS-NO-NEW). 2 rounds max, residuals open. `--report-only` keeps audit alone. +- **Why**: user ask. Proof by deterministic scanner, never executor's word; no new circuit to maintain. +- **Alternatives rejected**: guardrails edits code itself (skips fresh gates); chain to /bugfix per finding (one interview + contract per hit, too heavy for 60 labels); LLM verifier as sole proof (verdict without execution). +- **Refs**: feature/secure-by-default 73c25d7. Links [[BDR-120]]. diff --git a/.claude/memory/journal.md b/.claude/memory/journal.md index 43f1423..1d4521a 100644 --- a/.claude/memory/journal.md +++ b/.claude/memory/journal.md @@ -620,3 +620,9 @@ rules: - User asked if impeccable replaces frontend-design (install prompt in other project). Audit: yes for project UI, no for one-off visual. BDR-119: impeccable = Build path, GATE-BLOCK swap, doctrine Build line, advisor rows, rules 45 -> 61. frontend-design stays installed, light path. Branch chore/impeccable-build-path. - /bugfix model-router: session starting on dead Fable (no credits) lost 1st turn; probe skipped kept cur. c11cd3b `unprobed()` drops `call.moved`. 499 tests, verifier+security PASS. Merge on user signal. - /explain-diff skill built (feature/explain-diff) via skill-creator from geoffreylitt gist: SKILL.md + self-contained template + components catalog + checker + fill_template.py, suite 21 checks. Evals 3x2 on opus (Fable credits out, first dispatch 429): skill 100% vs baseline 45%, ~+90s/run. Fixed .edge class collision found in render. Merge awaits user go + viewer feedback. + +## 2026-10-18 +- Guardrails ask (user): 5 domains baseline + API/access hygiene + test skill. `rules/secure-by-default.md` always-on (CLAUDE.global 320/320, BDR-085 path). `/guardrails` = stdlib py scanner (6 domains, FAIL/WARN/MANUAL) + judgment; auditor gate runs api+supabase. Calibrated on game/faunosteo: 7 FP classes fixed (stopPropagation wrappers, hidden inputs, service_role-only policies, border focus, UI routes dir, ignored .env, dup origin). Branch feature/secure-by-default, not committed. BDR-120 pending user approval. +- Passwords added on user question ("stockés en clair ?"): gap, rule had none. `checks/passwords.py` (api domain): clear column w/o hash lib, `==` or SQL compare, fast hash, log call, literal. Calibrated 7 projects: zero noise after htpasswd volume-mount FP. Suite 89/89, `make test` green. +- Live probe added (user: "est-ce qu'il attaque de l'exterieur ?"). `probe.py` read-only, `--authorized`, env secrets, same-host redirect only, budget-capped. 5 probes confirm a hole from outside (OPEN/CLOSED). Suite 16/16 on a localhost fixture. Classifier blocked edits/tests carrying exploit-language and the SSRF-shaped redirect fixture; full-file Write passed, so probe strings are neutral and interpretation lives in checks.md. +- Fix loop added (user: propose fixes via Fable, user accepts, re-pass proves). Reused bugfix circuit: contract criteria with scanner oracle (`--assert-absent`, GUARDRAILS-CLEAR) run by gates.sh, bugfixer executor, verify-secure gates, re-pass `--baseline` (GUARDRAILS-NO-NEW), 2 rounds max. Proposals on route plan (best tier = fable first). Model gate added, census locks updated. diff --git a/.claude/tasks/TODO.md b/.claude/tasks/TODO.md index ce81a98..f8ccb5f 100644 --- a/.claude/tasks/TODO.md +++ b/.claude/tasks/TODO.md @@ -1,5 +1,24 @@ # TODO +## 2026-10-18 — secure-by-default guardrails: 5 domains + /guardrails skill (feature/secure-by-default) +User ask: hosting, a11y, Supabase, SMS/email consent, cloud functions must be baseline on every project, API and access secured systematically, plus a skill that tests all of it. +Language call: scanner is Python stdlib, not Rust (default-language contraindication: skill scripts here are interpreted, no build step, same as explain-diff checker). +- [x] T1 `rules/secure-by-default.md` always-on (no `paths:`, BDR-085 path: CLAUDE.global.md is at 320/320) +- [x] T2 `skills/guardrails/scripts/` scanner: common, apis, hosting, a11y, supabase, messaging, functions + `scan.py` CLI (FAIL / WARN / MANUAL, exit 1 on FAIL) +- [x] T3 `skills/guardrails/SKILL.md` + `references/checks.md` (rule catalogue, manual items, live Supabase queries) + `test-prompts.json` +- [x] T4 `lib/tests/guardrails-scan.test.sh`: clean fixture passes, one mutant per FAIL rule +- [x] T5 wiring: security-auditor checklist (+ scanner run), interviewer failure-mode row, init-project founding table +- [x] T6 registration: profiles full/max/dev, routing.json row, README, USAGE x2, CHANGELOG +- [x] T7 `make test` all green (70 guardrails checks), shellcheck clean, 25/80/5/5 limits met; calibrated on 8 real projects (game, faunosteo, zenquality, robin_petier, alphalink, game-deploy, config, explanations), 9 false-positive classes fixed and locked by benign tests. Journal done. [ ] BDR-120 awaits user approval; [ ] commit + merge = user go +- [x] T8 passwords (user ask 2026-10-18): doctrine bullet in the rule (argon2id, no clear compare, no log, no literal, delegated auth), `checks/passwords.py` in the api domain (API-PASSWORD-PLAINTEXT / WEAK-HASH / LOGGED FAIL, LITERAL WARN), 8 mutants + 10 benign locks (89 checks), auditor maps PLAINTEXT to CRITICAL; calibrated on 7 projects: 0 hits after one FP fix (yaml volume mount `htpasswd:/etc/...`) +- [x] T9 live probe (user ask 2026-10-18, "attaque de l'exterieur ?"): `skills/guardrails/scripts/probe.py` read-only (GET/HEAD/OPTIONS, `--authorized` gate, env secrets, same-host redirect only, request budget, 25-req burst cap). 5 probes: anon-read, cross-user, no-auth route, cors-reflect, rate-limit. Suite `lib/tests/guardrails-probe.test.sh` 16/16 vs a localhost http.server fixture. SKILL STEP 5 + checks.md section + CHANGELOG/README/USAGE. Redirect-guard unit test blocked by the auto-mode classifier (SSRF-shaped fixture), guard is code-reviewed. +- Fix loop (user ask 2026-10-18): audit -> fix proposals (Fable via route plan) -> user accepts -> fixes applied -> re-pass proves all fixed. Reuse /bugfix circuit: contract with scanner oracles, bugfixer executor, lib/verify-secure-loop.md gates. +- [x] T10 scan.py `--assert-absent RULE:path,...` (contract oracle: exit + marker reflect only the listed pairs, positive control = domain applies + files>0) and `--baseline ` (re-pass: fixed / remaining / new); tests incl. positive control +- [x] T11 SKILL.md: model gate, STEP propose (grouped per rule+path, visible choices named, MANUAL = user steps), STEP approve (prose gate), STEP fix (gitflow aiguillage, contract + oracles, bugfixer, verify-secure-loop), STEP re-pass (baseline diff + probe re-run on go, max 2 rounds), commit gate +- [x] T12 citers: verify-secure-loop header, contract-interview flow list, bugfixer description, model-routing census adds guardrails +- [x] T13 docs: checks.md oracle section, CHANGELOG, README, USAGE, test-prompts +- [x] T14 make test green (scan suite 106: check modes + gates.sh UNMET->MET), oracle calibrated read-only on game: real hit -> PRESENT rc1, self-baseline -> NO-NEW rc0 + ## 2026-10-17 — /explain-diff skill: HTML explanation of a diff (feature/explain-diff) Source: geoffreylitt gist `explain-diff-html` (Notion variant dropped). Built through the skill-creator loop (draft, evals with/without skill, user review). - [x] T1 `skills/explain-diff/SKILL.md` (target resolution, understand, 4 sections, style, save outside repo, check, hand-over) + `test-prompts.json` diff --git a/CHANGELOG.md b/CHANGELOG.md index 7288f3f..6eb8326 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ Format follows [Keep a Changelog](https://keepachangelog.com/) and this project ## [Unreleased] ### Added +- **Secure-by-default guardrails**: `rules/secure-by-default.md` (always on) makes five domains baseline on every project, plus systematic API and access hygiene (auth on every route, CORS, secrets, passwords hashed with argon2id or bcrypt, never compared in clear, logged or hardcoded): hosting (rate limit, CDN and firewall, hard spend cap), accessibility (keyboard, visible focus, alt text, field labels), Supabase (RLS on every table, owner-scoped policies, no service role key client-side), SMS and email (recorded consent, unsubscribe, STOP), cloud functions (no self-trigger, instance cap, budget stop). `/guardrails` audits them: a stdlib Python scanner (`skills/guardrails/scripts/scan.py`, FAIL / WARN / MANUAL, exit 1 on FAIL) then judgment, report in `.claude/audits/GUARDRAILS.md`. The security-auditor gate runs the scanner's `api` and `supabase` domains and blocks on FAIL. Items only a provider dashboard can set stay MANUAL, never claimed done. An optional read-only live probe (`skills/guardrails/scripts/probe.py`, `--live`) confirms a finding from outside on a target the user owns and names: anon-read, cross-user, no-auth route, CORS reflection and a capped rate-limit burst, verdicts OPEN / CLOSED / SKIPPED / ERROR. It sends GET, HEAD and OPTIONS only (one opt-in POST burst, capped at 25), requires `--authorized`, takes secrets from the environment never the command line, never follows a redirect to another host, and stops at a request budget. After the report, `/guardrails` proposes fixes (plan phase, so Fable when the router can switch), applies only the ones the user accepts through the `bugfixer` executor and the `lib/verify-secure-loop.md` gates, then re-scans: each accepted fix is a contract criterion whose oracle is the scanner (`--assert-absent RULE:path`, marker `GUARDRAILS-CLEAR`), and a full pass against the pre-fix baseline (`--baseline`, marker `GUARDRAILS-NO-NEW`) catches regressions; a live probe replays on the user's go; two rounds at most, residuals reported open; `--report-only` keeps the audit alone. Suites: `lib/tests/guardrails-scan.test.sh` (clean fixture plus one mutant per rule, check modes, `gates.sh` integration) and `lib/tests/guardrails-probe.test.sh` (probe logic against a localhost fixture server). - **model-router mod**: `mods/model-router/`, a Claude Code mod (function-hooks plugin), routes every repo skill and agent from phase rows (`plan`, `reflect`, `orchestrate`, `escalate`, `judge`, `implement`, `write`, `verify`, `explore`, `apply`, `mechanical`; built-ins Explore on sonnet/medium, Plan on opus/xhigh). A typed skill routes the main loop to its row, and a best-tier row holds across turns in a run slot until `/route clear`, `/route off`, a user `/model` or a typed skill on a non-best row. Agents get their row's model at spawn (within the tier, upward only) and its effort on every step; explicit Agent params win. Orchestrators declare their phases through the `mcp__model-router__route` tool. `ultrathink` in a prompt sets the turn's minimum effort and `/route effort=max` holds until `/route clear`; the built-in `/effort` is not a lever inside a run. `/route show` names the run slot (`main: run `), and a `null` row in the override drops a default row. The model gets a `route` tool and the user a `/route` command (`show|clear|off|on|reload|pending|ask on|off|forget ||model= effort=|switch on|off|verbose on|off`). Optional per-machine config `~/.claude/model-router.json`, where `"enabled": false` turns it off on that machine. The spinner suffix and the status line show the route in force. It loads in every session through the tracked symlink `skills/model-router` (`model-router@skills-dir`). `make doctor` gains a Mods section; suite `make test suite=lib/tests/mods.test.sh`. Known limits: a main-loop switch runs only while the cold read it costs (the context minus what the target model's prompt cache holds) fits `upgradeMaxTokens` (200000) or `downgradeMaxTokens` (120000), and a downgrade also needs `mainModelSwitch` (on by default, off on any non-boolean value); the hooks send full model ids, so the `models` table has to follow new versions. - **model-router first-use confirmation**: `mods/model-router/routing.json` (tracked) is the single source of the phase table and of every skill and agent row, and keeps the decisions: `confirmed`, `changed` (`from`/`to`), `projects` exceptions keyed by the origin remote reduced to `host/path` (credentials and local paths never stored), and `ask`. The first use of a rowed typed skill, a rowed agent spawn or a main-loop phase declared through the `route` tool opens a dialog with context: the skill's description (first sentence of its `SKILL.md` frontmatter) or the agent's, the phase with its `about` line (a new field on each of the 11 phases) and the model id and effort the next step really runs on. A row offers Later, Keep or Change; a main-loop phase Later or Keep. Change asks the model (fable, opus, sonnet, haiku with their tier), then the effort among those the phases of that model use (skipped when there is only one), then Everywhere or This project only; the pair maps to an existing phase (rows stay phase names, the same phase counts as Keep, a pair no phase offers is added by hand as a new phase). A skill-row change toasts the model and effort it now runs on, with the `/route switch on` hint when the main loop holds back a downgrade; a free-text answer counts as Later. One dialog at a time, never in headless (`-p`) runs or inside a sub-agent. Only a dialog answer, `/route ask on|off` or `/route forget` (which takes decisions back; a changed row returns to its shipped phase, the frontmatter floors stay yours to realign) writes the file (serialized, 64 KiB cap, never created when absent); each write asks you to commit it from the config repo. `/route pending` lists unconfirmed rows and phases. Layers: routing.json < `~/.claude/model-router.json` (its `ask` wins); a project's `.claude/model-router.json` is never read. Tests: `mods/model-router/hooks/register.test.ts`. - **Manual-push mode**: `git config gitflow.autopush false` (human-set) now stops every push the gitflow lib makes, not only the post-commit / post-merge hooks. `gitflow start` and `finish` branch, commit and merge locally and push nothing; `gitflow delete` leaves the `origin/` copy in place and prints `git push origin --delete
` for the user to run. `hooks/unpushed-guard.sh` stays silent at turn end in this mode and opens each session with one `ℹ manual push mode:` line counting the commits no remote holds across every local branch; an unparseable or unreadable `gitflow.autopush` value is treated as manual push mode too, and that line names it. `hooks/push-guard.sh` (PreToolUse, `Bash|Monitor`) refuses any `git push` Claude types while `gitflow.autopush` reads false in the session cwd or in a literal `-C`/`cd` directory the command names (global config counts outside a repo); the refusal tells the user to run it with `! git push`. It reads the mode through the same lib verb as every other reader and fails closed: an unparseable or unreadable value reads as manual, and an internal error, a missing `lib/gitflow.sh`, more than 20 distinct directory tokens in one command (capped before any token is classified), a `cd`/`-C` directory token mixing quoted and unquoted parts, or a payload jq cannot parse whose raw text looks like a push refuse the push (these pathological cases fire in auto mode too). Directory tokens are read as whole shell words, adjacent quoted segments and backslash escapes included. Once the text looks like a push, the command is split into simple commands (quotes, escapes, separators, heredoc bodies dropped) and a push must be git's own subcommand in one of them: `grep "git push"`, `git log -S "git push"`, `git config --get push.default`, `git stash push`, a heredoc quoting a push or a commit message naming one are allowed; `bash -c` scripts are re-checked, wrappers (`sudo`, `env`, `eval`, `xargs`, `timeout`, `git subtree`...) and assignments keep the text verdict. The misses listed in its header fall to a new `autoMode.soft_deny` rule that no request in the turn clears. The session banner adds `🔒 push : manual (autopush=false) — ! git push` when the key reads false, and `🔒 push : manual (autopush bad) — ! git push` when the value is invalid. Skills read the mode through a new lib verb, `bash ~/.claude/lib/gitflow.sh push-mode`: it prints `auto`, `manual` or `invalid` (rc 0) and names an invalid value on stderr (printable characters only, 64 at most). It is the one reader a skill may call, since the `git config` read of the key is denied to Claude. Skills push nothing on their own, except the `/release-candidate` tag in auto-push mode on an explicit go. Every "on origin" or "not pushed" line they print comes from `git rev-list --count origin/
..
` read after the fact, with the complete `! git …` command when something is left for the user to push. An invalid value (anything but unset, true or false, or a read that fails) is manual push mode for every reader and is named where it is read (see Fixed). Tests: `lib/gitflow-test.sh` T11b (push-mode verb), T18m and T18q blocks, `lib/tests/unpushed-guard.test.sh` T10-T16, `lib/tests/push-guard.test.sh` (98 checks). diff --git a/CLAUDE.md b/CLAUDE.md index aa8577a..25adfcd 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -20,7 +20,7 @@ what can be path-scoped (the token win) or what is generated; always-on doctrine stays in CLAUDE.global.md. Exception: a standalone user-authored rule set that would bust the 320-line density budget may live here WITHOUT `paths:` (always-on load) — writing-style.md (BDR-085), default-language.md -(BDR-118). `paths:` globs match against the +(BDR-118), secure-by-default.md (BDR-120). `paths:` globs match against the CURRENT project's tree — a broad glob (e.g. `rules/**`) can fire in foreign projects; keep rule bodies tiny. Docs: https://code.claude.com/docs/en/memory.md#path-specific-rules diff --git a/README.md b/README.md index daf9aaa..58a50f5 100644 --- a/README.md +++ b/README.md @@ -228,6 +228,7 @@ a different package, ships its own conflicting `graphify` bin) — see | `/reconcile` | Confront declared status (TODO, registries) against real git/fs state — surface stale items | | `/pdf-translate` | Translate a PDF to another language, output as HTML (via Vision) | | `/explain-diff` | Explain a diff, commit, branch or PR as one self-contained HTML page (background, intuition, code walkthrough, 5-question quiz), saved outside the repo | +| `/guardrails` | Audit the five baseline guardrails (hosting, a11y, Supabase RLS, SMS/email consent, cloud functions) plus API hygiene (auth, CORS, secrets, password storage): deterministic scanner, then judgment, report in `.claude/audits/GUARDRAILS.md`. Then proposes fixes, applies the ones you accept and re-scans to prove each one. `--live ` adds a read-only probe that confirms a hole from outside | | `/close` | End-of-session ritual — alias for `/capitalize --ritual` (dedup + TODO reconcile + 3-question reflection) | | `/harden` | Web hardening audit — HTTPS/TLS, HSTS, CSP, security headers | | `/web-validate` | W3C HTML/CSS validity + WCAG 2.1 accessibility audit | diff --git a/USAGE.md b/USAGE.md index 3942bd0..a1d29d5 100644 --- a/USAGE.md +++ b/USAGE.md @@ -120,6 +120,8 @@ Tu veux... | Livraison client finale | `/client-handover` | | Traduire un PDF | `/pdf-translate` | | Comprendre un changement pas suivi | `/explain-diff` | +| Auditer garde-fous (RLS, a11y, consentement, fonctions, mots de passe) puis corriger | `/guardrails` | +| Sonder le projet en direct (lecture seule, cible à toi) | `/guardrails --live ` | | Changer profil skills | `/profile` | | Audit/polish design (anti-slop) | `/impeccable` | | Sweep groupé tous axes (nettoyage + sécu + reconcile + doc) | `/tour` | @@ -163,6 +165,7 @@ Tu veux... | `/client-handover` | Livraison client | Audits finaux + livrable brandé | | `/pdf-translate` | Traduire un PDF vers une autre langue | Sortie HTML fidèle (images, layout, style préservés) | | `/explain-diff` | Comprendre un commit, une branche ou une PR qu'on n'a pas suivis | Page HTML autonome hors du repo : contexte, intuition, code, quiz de 5 questions | +| `/guardrails` | Vérifier hébergement, a11y, Supabase RLS, consentement SMS/email, fonctions cloud, stockage des mots de passe | Scanner déterministe, jugement, rapport `.claude/audits/GUARDRAILS.md`, propositions de correction à valider, re-passe qui prouve chaque correction ; `--live ` sonde en lecture seule | | `/impeccable` | Audit/polish design + détecteur anti-slop déterministe | 23 verbes ; `npx impeccable detect` (exit 0/2) | | `/tour` | Sweep groupé sur un ou plusieurs projets | Sécu + nettoyage + reconcile + doc, boucle jusqu'à un pass propre | | `/route` | Voir ou fixer la route du mod model-router | show / clear / off / on / reload / pending / ask on\|off / / model=… effort=… / switch on\|off / classify on\|off (classifieur de prompt) / verbose on\|off (transitions seules) | diff --git a/agents/bugfixer.md b/agents/bugfixer.md index 3094d12..bcbc8f8 100644 --- a/agents/bugfixer.md +++ b/agents/bugfixer.md @@ -1,6 +1,6 @@ --- name: bugfixer -description: Bug-fix EXECUTOR — dispatched by /bugfix with a closed DIAGNOSIS + FIX PLAN + contract. Applies the fix and a regression test, runs the suite, reports. No investigation, no questions, no commit. +description: Bug-fix EXECUTOR — dispatched by /bugfix (or /guardrails for accepted fixes) with a closed DIAGNOSIS + FIX PLAN + contract. Applies the fix and a regression test, runs the suite, reports. No investigation, no questions, no commit. tools: Read, Edit, Write, Bash, Grep, Glob model: sonnet effort: medium diff --git a/agents/interviewer.md b/agents/interviewer.md index 8a6fbd8..0d5861b 100644 --- a/agents/interviewer.md +++ b/agents/interviewer.md @@ -24,6 +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 | | 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 (`rules/default-language.md`); 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 five guardrail domains apply, 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 | | 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 | diff --git a/agents/security-auditor.md b/agents/security-auditor.md index 01af0a3..ef9080d 100644 --- a/agents/security-auditor.md +++ b/agents/security-auditor.md @@ -13,8 +13,8 @@ classify by severity, and render a verdict. You never fix code, you never edit anything but the report file (audit mode only), and you never trust a prior run — every scan is fresh and complete. -Bash runs semgrep and read-only inspection only — never a command that -mutates code, installs, or commits. +Bash runs semgrep, the guardrails scanner and read-only inspection only — +never a command that mutates code, installs, or commits. Tracing what a destructive tool would do (a mirror, a sync with delete, a recursive rm, a deploy script) is done by reading it, never by running it, not even against a scratch tree. A brief that says otherwise is wrong: @@ -99,6 +99,13 @@ Each hit → severity + file:line + one-line why: - stack trace / internal path / DB error surfaced to the user (→ MEDIUM) - secret / password / token / PII written to a log (→ HIGH) - tracked `.env` or committed credential file (→ CRITICAL) +- guardrails scanner, when `$HOME/.claude/skills/guardrails/scripts/scan.py` + exists: `python3 -B --domain api,supabase`. + `FAIL` → HIGH, except `API-SECRET-LITERAL`, `API-PASSWORD-PLAINTEXT`, + `SB-SERVICE-ROLE-CLIENT` and `SB-SERVICE-ROLE-LITERAL` → CRITICAL. + `WARN` → MEDIUM. `MANUAL` is not reported here. In gate mode keep only + findings in files of the diff. + Scanner absent → say so on the checklist line, never a silent skip. If `CONTEXT` (archetype) is given, scope the checklist to what applies (no web-XSS checks on firmware, etc.). diff --git a/lib/contract-interview.md b/lib/contract-interview.md index 63aa9af..870cd11 100644 --- a/lib/contract-interview.md +++ b/lib/contract-interview.md @@ -114,7 +114,7 @@ Template: ```markdown # CONTRACT — -- date: | flow: | branch: +- date: | flow: | branch: - status: active ## REQUEST (verbatim — IMMUTABLE) diff --git a/lib/profiles/audit.profile b/lib/profiles/audit.profile index 2dea2ba..7e15b9f 100644 --- a/lib/profiles/audit.profile +++ b/lib/profiles/audit.profile @@ -5,6 +5,7 @@ # Security cso harden personal +guardrails personal analyze personal # SEO / GEO / web standards diff --git a/lib/profiles/backend.profile b/lib/profiles/backend.profile index f6de8ca..a59697f 100644 --- a/lib/profiles/backend.profile +++ b/lib/profiles/backend.profile @@ -26,6 +26,7 @@ codex # Security + health (always relevant for backend) cso +guardrails personal health # Session hygiene diff --git a/lib/profiles/dev.profile b/lib/profiles/dev.profile index ca2ea17..cc07f11 100644 --- a/lib/profiles/dev.profile +++ b/lib/profiles/dev.profile @@ -18,6 +18,7 @@ refactor personal code-clean personal commit-change personal explain-diff personal +guardrails personal # Dev-lifecycle skills (agent-skills trio) observability-and-instrumentation external diff --git a/lib/profiles/full.profile b/lib/profiles/full.profile index 7e26963..55d18cc 100644 --- a/lib/profiles/full.profile +++ b/lib/profiles/full.profile @@ -45,6 +45,7 @@ seo personal geo personal web-validate personal harden personal +guardrails personal analyze personal cso diff --git a/lib/profiles/max.profile b/lib/profiles/max.profile index 055c28d..5060c45 100644 --- a/lib/profiles/max.profile +++ b/lib/profiles/max.profile @@ -46,6 +46,7 @@ seo personal geo personal web-validate personal harden personal +guardrails personal analyze personal cso diff --git a/lib/profiles/web-full.profile b/lib/profiles/web-full.profile index ed80e59..9376f75 100644 --- a/lib/profiles/web-full.profile +++ b/lib/profiles/web-full.profile @@ -33,6 +33,7 @@ seo personal geo personal web-validate personal harden personal +guardrails personal analyze personal # === Perf + canary =================================================== diff --git a/lib/tests/fixtures/guardrails-good/.env.example b/lib/tests/fixtures/guardrails-good/.env.example new file mode 100644 index 0000000..b779b70 --- /dev/null +++ b/lib/tests/fixtures/guardrails-good/.env.example @@ -0,0 +1,2 @@ +SUPABASE_URL= +SUPABASE_ANON_KEY= diff --git a/lib/tests/fixtures/guardrails-good/.gitignore b/lib/tests/fixtures/guardrails-good/.gitignore new file mode 100644 index 0000000..6ed48a9 --- /dev/null +++ b/lib/tests/fixtures/guardrails-good/.gitignore @@ -0,0 +1,2 @@ +.env +node_modules diff --git a/lib/tests/fixtures/guardrails-good/docs/DEPLOY.md b/lib/tests/fixtures/guardrails-good/docs/DEPLOY.md new file mode 100644 index 0000000..8806371 --- /dev/null +++ b/lib/tests/fixtures/guardrails-good/docs/DEPLOY.md @@ -0,0 +1,6 @@ +# Deploy + +Traffic goes through Cloudflare, with WAF and DDoS rules on. +Rate limits live in the middleware. +Spend cap is set in the host dashboard, and a budget alert triggers the +kill switch described in the runbook. diff --git a/lib/tests/fixtures/guardrails-good/firebase.json b/lib/tests/fixtures/guardrails-good/firebase.json new file mode 100644 index 0000000..0b31e65 --- /dev/null +++ b/lib/tests/fixtures/guardrails-good/firebase.json @@ -0,0 +1 @@ +{ "functions": { "source": "functions" } } diff --git a/lib/tests/fixtures/guardrails-good/functions/index.js b/lib/tests/fixtures/guardrails-good/functions/index.js new file mode 100644 index 0000000..1adfbce --- /dev/null +++ b/lib/tests/fixtures/guardrails-good/functions/index.js @@ -0,0 +1,8 @@ +const { onDocumentCreated } = require("firebase-functions/v2/firestore"); +const { setGlobalOptions } = require("firebase-functions/v2"); + +setGlobalOptions({ maxInstances: 10 }); + +exports.onOrder = onDocumentCreated("orders/{id}", async (event) => { + await db.collection("receipts").add({ order: event.params.id }); +}); diff --git a/lib/tests/fixtures/guardrails-good/package.json b/lib/tests/fixtures/guardrails-good/package.json new file mode 100644 index 0000000..e2a655b --- /dev/null +++ b/lib/tests/fixtures/guardrails-good/package.json @@ -0,0 +1 @@ +{ "name": "fixture", "dependencies": { "@supabase/supabase-js": "^2.0.0" } } diff --git a/lib/tests/fixtures/guardrails-good/src/app/routes/Home.tsx b/lib/tests/fixtures/guardrails-good/src/app/routes/Home.tsx new file mode 100644 index 0000000..709115f --- /dev/null +++ b/lib/tests/fixtures/guardrails-good/src/app/routes/Home.tsx @@ -0,0 +1,6 @@ +import { useState } from "react"; + +export function Home() { + const [n] = useState(0); + return

{n}

; +} diff --git a/lib/tests/fixtures/guardrails-good/src/components/ContactForm.tsx b/lib/tests/fixtures/guardrails-good/src/components/ContactForm.tsx new file mode 100644 index 0000000..f8ddbc1 --- /dev/null +++ b/lib/tests/fixtures/guardrails-good/src/components/ContactForm.tsx @@ -0,0 +1,31 @@ +export function ContactForm({ go }: { go: () => void }) { + return ( +
+ + +