Checks
Each rule below is a module in packages/gate/src/checks/. The examples come from the tests in packages/gate/test/, or were checked against the rule’s code.
Where each rule runs
Section titled “Where each rule runs”The columns use these meanings:
- pre: the hook that runs before a
Write,EditorMultiEdit. It blocks (exit code2) only the violations the edit introduces. - end of turn: the
stophook. It analyzes every file the turn touched again and blocks what the turn introduced, compared with the file’s first-touch baseline or git HEAD. It shows at most 20 lines per file. - check CLI:
smugan check. It lists every violation in the files it reads and exits1.
“Listed once” means the finding is part of one end-of-turn hold and is recorded, so it never holds the turn again. The detectors marked that way are covered in End-of-turn detectors. With "mode": "warn" in the config, every blocking column only reports.
| Rule id | Area | pre | end of turn | check CLI |
|---|---|---|---|---|
db-naming |
SQL naming | blocks | blocks | lists |
rls |
Supabase RLS | blocks | blocks | lists |
rls-tests |
Supabase RLS | blocks | blocks | lists |
security-notes |
Supabase RLS | blocks | blocks | lists |
rls-policy |
Supabase RLS | blocks | blocks | lists |
view-invoker |
Supabase RLS | blocks | blocks | lists |
search-path |
Supabase functions | blocks | blocks | lists |
anon-grants |
Supabase grants | blocks | blocks | lists |
money-float |
SQL types | blocks | blocks | lists |
ui-strings |
UI copy (pt-BR) | blocks | blocks | lists |
no-any |
TypeScript | blocks | blocks | lists |
secrets |
Secrets | blocks | blocks | lists |
console-log |
Debug residue | blocks | blocks | lists |
dead-imports |
Dead code | blocks on Write only |
blocks | lists |
stale-mutation |
Next.js server actions | blocks | blocks | lists |
empty-catch |
Error handling | blocks | blocks | lists |
rust-panic |
Panics (Rust) | blocks | blocks | lists |
swallowed-error |
Error handling (Rust) | blocks | blocks | lists |
fetch-timeout |
Outgoing calls | blocks | blocks | lists |
test-weakening |
Tests | blocks | blocks | lists |
await-in-loop |
N+1 queries | blocks, critical turn only | — | — |
assertion-weakening |
Tests | — | lost assertions block; removed tests listed once | — |
contract-drift |
Error/input contract | — | listed once | — |
clone |
Duplication | — | listed once | — |
exploration-residue |
Leftover files | — | listed once | — |
smugan-ignore |
Suppressions | blocks | blocks | lists |
The first 18 rules are the CHECKS list in checks/index.mjs. The hook skips dead-imports on Edit and MultiEdit because a change made in several steps passes through an unused import. The end of turn checks the final state instead (hook.mjs, preHook).
Turning rules on and off
Section titled “Turning rules on and off”The logic is checkEnabled in config.mjs.
-
Any rule.
"checks": { "<rule>": false }turns it off. An object passes options to it and keeps it on. -
Supabase rules.
rls,rls-tests,security-notes,anon-grants,view-invoker,search-pathandrls-policydefault to on only for a migration Supabase owns:- one under
supabase/migrations/, or - one where some folder from the file up to the project root has
supabase/config.tomlor asupabase/@supabase/*dependency in itspackage.json(stack.mjs).
A plain Postgres project turns one on with
true. - one under
-
ui-strings. Defaults to on only when the environment variableSMUGAN_UI_LANGis apttag (pt,pt-BR, …). Setting the rule inchecksoverrides that.
Suppressing a finding
Section titled “Suppressing a finding”// smugan-ignore <rule>: <reason of 6+ characters>// smugan-ignore-file <rule>: <reason of 6+ characters>This is how parseSuppressions in engine.mjs reads them:
- Scope.
smugan-ignorecovers its own line and the next line. A blank line in between breaks the link.smugan-ignore-filecovers the whole file. - Rules. Several rules go comma-separated with no spaces (
console-log,empty-catch).*matches every rule. - Colon. Required. A comment without it is not read as a suppression.
- Reason. Cut at a trailing
*/or-->, then trimmed. Fewer than 6 characters suppresses nothing and is reported as asmugan-ignoreviolation. - Comment style. The parser reads raw text, so the same syntax works in
//,--,/* */and<!-- -->comments. - Old name.
smaug-ignoreis accepted as well.
db-naming
Section titled “db-naming”Source: checks/db-naming.mjs
Flags an identifier declared in DDL that:
- has a non-ASCII character,
- has a word from a fixed list of unambiguous Portuguese words (
nome,usuario,pedidos,valor, …), or - has an uppercase letter (not snake_case).
It reads the names in create table (temporary and unlogged too) and that table’s column list, add column, rename … to, rename to, create index, function, procedure, type, view, materialized view, schema, sequence, trigger and policy. Policy names skip the case check, because they are often sentences.
Scope: every .sql file, migration or not. Comments and string contents are blanked first.
Options: allow, a list of identifiers accepted as they are.
-- flagged: "nome" is Portuguesecreate table patients ( id uuid primary key, nome_completo text);-- flagged: not snake_casecreate table events (createdAt timestamptz);-- passescreate table patients ( id uuid primary key default gen_random_uuid(), full_name text not null);Known false negatives:
- Portuguese words outside the list. Words that are also English (
data,total,status,local,agenda) are left out on purpose. - Identifiers written in DDL forms the patterns do not cover.
- Identifiers declared outside
.sqlfiles (ORM schemas).
Source: checks/rls.mjs
Flags:
- A
create tablewithoutalter table … enable row level securityfor that table in the same file. - An
alter table … disable row level security, unless one of these holds:- the same file enables it again later (outside a down section),
- the file drops the table,
- the table is in a platform schema,
- it sits in a down migration. That is a
*.down.sqlfile, Diesel’sdown.sql, or the down section after a goose (-- +goose Down), dbmate (-- migrate:down) or sql-migrate (-- +migrate Down) marker.
Scope: migration .sql files (migration/ or migrations/ folder), Supabase projects by default. Temporary tables and the auth, storage, extensions, realtime, vault and pg_catalog schemas are skipped.
Options: exempt, a list of table names.
-- flaggedcreate table notes (id uuid primary key);-- passescreate table notes (id uuid primary key);alter table notes enable row level security;create policy "own rows" on notes for select using (auth.uid() = user_id);Known false negatives:
- The enable statement is matched by table name only, without its schema:
alter table public.notes enable …also clearscreate table private.notes. - DDL built inside a string (
execute 'create table …') is blanked and not read. - Only the same file is read: RLS enabled in a later migration does not clear the finding.
rls-tests
Section titled “rls-tests”Source: checks/rls-tests.mjs
Flags a table created in a migration whose name does not appear, as a whole word, in any .sql file under the pgTAP test folder. The check only proves that a test exists. supabase test db proves it passes.
Scope: migration .sql files, Supabase projects by default. Same table filter as rls.
Options: exempt; dir, the test folder (default supabase/tests).
-- flagged when no .sql file under supabase/tests/ mentions notescreate table notes (id uuid);This passes once a file such as supabase/tests/100-notes.test.sql mentions the table:
select results_eq($$ select count(*) from notes $$, $$ values (0::bigint) $$, 1);Known false negatives: the test files are read raw, so any whole-word mention of the table, a comment included, counts as a test. notes_archive does not count for notes.
security-notes
Section titled “security-notes”Source: checks/security-notes.mjs
Flags:
- A table created in a migration whose name does not appear, as a whole word, in the project’s notes file.
- Every such table when the notes file does not exist.
Scope: migration .sql files, Supabase projects by default.
Options: exempt; file (default SECURITY_NOTES.md, relative to the project root).
-- flagged when SECURITY_NOTES.md does not mention notescreate table notes (id uuid);This passes once SECURITY_NOTES.md has a line about the table:
- Tabela `notes`: visitante não lê nada; usuário logado lê/edita só o que é dele.Known false negatives: any whole-word mention of the name counts as a description. The check does not judge what the line says.
rls-policy
Section titled “rls-policy”Source: checks/rls-policy.mjs
Flags a create policy that:
- Opens writes to every row. The policy is permissive, for
update,deleteorall(the default), and itsusingis(true)or(1=1)once spaces and wrapping parentheses are removed. It is skipped when every role in itstolist is a server role (service_role,postgres,supabase_admin,supabase_auth_admin,supabase_storage_admin,dashboard_user). - Reads
user_metadataorraw_user_meta_datain itsusingorwith checkexpression, whatever the command. The user can edit that metadata throughauth.updateUser().
Scope: migration .sql files, Supabase projects by default.
-- flagged: every role can update and delete every rowcreate policy "allow all" on notes for all using (true) with check (true);-- flagged: access decided by metadata the user editscreate policy notes_admin on notes for select to authenticated using (((select auth.jwt()) -> 'user_metadata' ->> 'is_admin')::bool);-- passescreate policy notes_delete on notes for delete using (auth.uid() = user_id);create policy notes_admin on notes for select using (((select auth.jwt()) -> 'app_metadata' ->> 'role') = 'admin');Known false negatives, by design:
- A
selectorinsertpolicy open to everyone. A public catalog or a contact form is left to the table’s pgTAP test. - A policy with no
using, which PostgreSQL treats as showing no row. - An
as restrictivepolicy. - A
usingthat is always true in any form other thantrueor1=1(for exampleauth.role() = 'authenticated').
view-invoker
Section titled “view-invoker”Source: checks/view-invoker.mjs
Flags a view created in the public schema (an unqualified name counts as public) without security_invoker. Without it, the view reads its tables with its owner’s rights, so their RLS does not apply to the caller. Either of these clears it:
security_invokerin the view’s own options. A baresecurity_invokercounts as true;false,off,0ornodoes not.- A later
alter view … set (security_invoker = …)in the same file. Analterthat comes before acreate or replacedoes not count, because thecreate or replaceredefines the view.
Scope: migration .sql files, Supabase projects by default. Temporary views are skipped. Materialized views are not matched by the pattern.
-- flaggedcreate view public.profile_names as select id, full_name from profiles;-- passescreate view profile_names with (security_invoker = true) as select id from profiles;Known false negatives: views in schemas other than public are not judged, even when the API exposes that schema.
search-path
Section titled “search-path”Source: checks/search-path.mjs
Flags a create function or create procedure whose header (the statement without its dollar-quoted body) says security definer and has no set search_path. A later alter function … set search_path in the same file clears it. One placed before a create or replace does not.
Scope: migration .sql files, Supabase projects by default. Routines in platform schemas are skipped.
-- flaggedcreate or replace function public.handle_new_user() returns trigger language plpgsql security definer as $$ begin return new; end; $$;-- passescreate function public.handle_new_user() returns trigger language plpgsql security definer set search_path = '' as $$ begin return new; end; $$;Known false negatives: a pinned search_path that still includes a schema callers can write to is accepted. The check only looks for the clause.
anon-grants
Section titled “anon-grants”Source: checks/anon-grants.mjs
Flags a top-level GRANT, or ALTER DEFAULT PRIVILEGES … GRANT, to anon or authenticated on a schema other than public, graphql_public or a platform schema. The schemas are read from:
on schema …/in schema …lists, and- qualified object names (
app_private.accounts).
Arguments inside parentheses (function signatures) are ignored. An unqualified object counts as public.
Scope: migration .sql files, Supabase projects by default.
-- flaggedGRANT SELECT ON ALL TABLES IN SCHEMA app_private TO anon;-- passesGRANT USAGE ON SCHEMA public TO anon, authenticated;GRANT ALL ON ALL TABLES IN SCHEMA app_private TO service_role;REVOKE ALL ON ALL TABLES IN SCHEMA app_private FROM anon, authenticated;Known false negatives:
- Grants to other roles that the API uses are not judged.
- A grant inside a string (
execute '…') is blanked.
A non-public schema that is meant to be a public catalog takes a smugan-ignore with the reason.
money-float
Section titled “money-float”Source: checks/money-float.mjs
Flags a column with a money-like name declared as real, float, float(n), float4, float8, double precision or money. The column can be declared in a create table, an add column, or an alter column … type conversion.
How the name is judged:
- It is split into words (camelCase too).
- A word that ends in
price,amount,total,cost,balance,paymentorrevenue(plural or not), or insalary/salaries, counts. Sounit_price,subtotalandunitpricecount. feeandfeescount only as a whole word:feedback_scoreandcoffee_countpass.
Scope: migration .sql files. This is not a Supabase rule: it runs on any project.
-- flaggedcreate table orders (id uuid primary key, price real not null);alter table orders add column if not exists shipping_cost real;-- passescreate table t (price numeric(12,2), amount_cents integer, balance bigint);Known false negatives:
- Money words outside the list (
discount,tax). - Columns of
create temp tableorcreate unlogged table, which this rule’s pattern does not match.
ui-strings
Section titled “ui-strings”Source: checks/ui-strings.mjs
Flags two things. Both checks are tuned to report few false positives at the cost of missing some cases.
- English in the UI. A word from a fixed English vocabulary (
Save,Cancel,Submit,Loading,password, …) in JSX text or in aplaceholder,title,alt,aria-label,aria-descriptionorlabelattribute. Words common in Brazilian UIs (download,login,email,dashboard, …) are left out of the vocabulary. - Missing accents. A pt-BR word written without its accent or cedilla (
nao→não,configuracao→configuração, …). It is looked for in the same places, plus string literals that contain whitespace.
Scope:
- Only
.tsxand.jsxfiles. - Off by default unless
SMUGAN_UI_LANGis apttag or the project sets the rule inchecks. - Not scanned: code attributes (
className,id,href,type,name,value, …), text with URLs,@, braces or other code characters, and single-word literals (often enum values).
Options: english: false and accents: false turn off either half.
// flaggedexport default function P() { return <button>Save</button>; }// flagged twice: "Configuracao" and "invalida"<p>Configuracao invalida</p>// passesexport default function P() { return <button>Salvar</button>; }Known false negatives:
- English words outside the vocabulary.
- English in plain string literals: only JSX text and the attributes above are read for English.
- Copy in
.ts/.jsfiles.
no-any
Section titled “no-any”Source: checks/no-any.mjs
Flags, without a justification:
anyin a type position. That covers annotations,as any, generic and tuple slots (Record<string, any>,[any, string]),any[], union and intersection members, a function type’s return, and type aliases or defaults (type X = any,<T = any>).- The double cast
as unknown as.
keyof any, T extends any, and a value named any followed by . or ( pass.
What counts as a justification:
- A comment matching
any: <reason>, with at least 6 characters after the colon. It can be on the same line or anywhere in the contiguous block of comment lines directly above (blank lines allowed). Because of how this match works, asmugan-ignore no-any: …comment above the line also satisfies it. - An
eslint-disable…forno-explicit-anywith a-- <reason>.-linecovers its own line and-next-linethe line below.
Also flags @ts-nocheck and @ts-ignore at the start of a comment, unless the directive is followed by a reason of at least 6 characters. @ts-expect-error passes without one, because it fails by itself once the error is gone.
Scope: .ts, .tsx, .mts, .cts, excluding declaration files (.d.ts, .d.mts, .d.cts).
// flaggedconst x: any = load();const user = payload as unknown as User;// passes// any: third-party SDK returns untyped payloadsconst x: any = sdk.load();Known false negatives:
- Implicit
any: noanyis written, so there is nothing to match. anyin.jsfiles.- Type-system escapes other than the listed directives and the double cast.
secrets
Section titled “secrets”Source: checks/secrets.mjs
Flags, line by line on the raw text (comments included):
- Key shapes:
- private key blocks;
- AWS access key ids;
- Google API keys;
sk-…secret keys;- GitHub classic and fine-grained tokens;
- Slack tokens with real-length ids;
- Stripe
sk_/rk_keys; whsec_webhook secrets, unless the base64 decodes to readable text;- hardcoded JWTs;
sb_secret_….
- Secret-looking literals. A literal of 16+ characters assigned to a name containing
secret,password,passwd,token,api_key/apikey,private_keyorservice_role. It must look like a key (digits, or 24+ characters) and not match a placeholder pattern (process.env,example,your-,xxx,changeme,<…>,${, …). - Database URLs carrying a password for a remote host. Placeholders, variables, expressions and interpolations pass, and so do local hosts (no dot, loopback, private ranges,
.local,.internal,.test,example.*). The README’s Checks section has the full parsing rules. - Admin keys in client code.
service_roleorsb_secret_behindNEXT_PUBLIC_*, or in a"use client"module. - Example env files. In
.env.example,.env.sample,.env.templateand.env.dist, a value that looks like a real secret, or a database URL with a real password on any line, a commented-out one included.
Scope:
- JS/TS, JSON, YAML, TOML, SQL, Python, Go, Rust, Ruby, PHP, Java, Kotlin, C#, Swift, Dart, shell, PowerShell, Astro, Vue, Svelte, Terraform, Prisma, Dockerfiles/Containerfiles, and the example env files.
- Prose files are not read.
.env,.env.localand.env.*.localare in the default ignore list.
// flaggedconst apiKey = "a1b2c3d4e5f6g7h8i9j0";// passesconst apiKey = process.env.API_KEY;Known false negatives:
- A secret split across literals (
"AKIA" + "…"), which no single line holds whole. - A secret assigned to a name outside the list.
- A password given as a URL property or query parameter (
;password=…,?password=…).
console-log
Section titled “console-log”Source: checks/console-log.mjs
Flags console.log, console.debug, console.info, console.table, console.dir and console.trace calls. console.warn and console.error pass.
Scope: JS/TS code files (.ts, .tsx, .js, .jsx, .mjs, .cjs, .mts, .cts), excluding:
script/,scripts/,test/,tests/,__tests__/,e2e/,bin/,tool/andtools/folders,.test.and.spec.files,.config.files.
console.log(user); // flaggedFix: delete the call, or route the output through the project’s logger. The message deliberately does not suggest renaming it to warn or error.
Known false negatives: a call through an alias (const { log } = console; log(x)) or bracket access is not matched.
dead-imports
Section titled “dead-imports”Source: checks/dead-imports.mjs
Flags an imported binding (default, named, renamed or namespace, import type included) whose name never appears again in the file outside comments and strings. Side-effect imports (import './x.css') are never flagged.
Scope: .ts, .tsx, .js, .jsx, .mjs, .mts, .cts, excluding declaration files. In the pre hook it applies only to Write.
// flagged: useEffect is never usedimport { useState, useEffect } from 'react';export const n = useState(0);// passesimport { join as joinPath } from 'node:path';export const p = joinPath('a', 'b');Known false negatives:
- The analysis covers one file and matches by name, so any occurrence counts as a use. That includes a property of the same name (
obj.helperkeepsimport { helper }alive). import x = require(…)is not read.
stale-mutation
Section titled “stale-mutation”Source: checks/stale-mutation.mjs
Flags a file with a 'use server' directive line that writes to the database but has no cache revalidation anywhere in it.
- Writes:
.from(…).insert/update/upsert/delete(…), or.rpc('name')with a literal name not starting withget_,list_,search_,count_orfetch_. - Revalidation:
revalidatePath,revalidateTag,expirePathorexpireTag, orupdateTag()/refresh()when imported fromnext/cache.
It reports the first write only.
Scope: .ts and .tsx, excluding script, test, e2e, bin and config paths.
// flagged'use server';export async function addClient(name: string) { await supabase.from('clients').insert({ name });}// passes'use server';import { revalidatePath } from 'next/cache';export async function addClient(name: string) { await supabase.from('clients').insert({ name }); revalidatePath('/clients');}Known false negatives:
- Any revalidation call anywhere in the file clears every write in it.
- Writes through other clients (an ORM’s
create) are not matched. - An
.rpcwith a dynamic name is never flagged.
A read-only RPC whose name does not show it takes smugan-ignore stale-mutation: <reason>.
empty-catch
Section titled “empty-catch”Source: checks/empty-catch.mjs
Flags:
- A
catchblock that is empty or holds only comments. - An empty
.catch(() => {})handler, in arrow orfunctionform.
Scope: JS/TS code files, excluding script, test, e2e, bin and config paths.
try { save(); } catch (e) {} // flaggedfetch(url).catch(() => {}); // flaggedtry { save(); } catch (e) { throw e; } // passesfetch(url).catch((e) => report(e)); // passesKnown false negatives, by design:
- A
catchwhose body has statements that ignore the error. That needs judgment and is left to the reviewer. - A handler with an expression body (
.catch(() => null)).
The end-of-turn contract-drift detector covers some of these cases inside functions that already existed.
rust-panic
Section titled “rust-panic”Source: checks/rust-panic.mjs
Flags in Rust a .unwrap() and the stub macros todo!() and unimplemented!(). The first panics with no reason when the value is an error; the stubs compile and panic only when the path runs. Cloudflare’s outage of 18 November 2025 was a Result::unwrap() in a new proxy.
Scope: .rs files, excluding tests/, benches/, examples/, test module files (tests.rs, *_tests.rs, test_*.rs), build.rs and inline #[cfg(test)] modules. A lock’s .lock(), .read() or .write() followed by .unwrap() passes: it panics only on a poisoned lock. Like every rule, only what a write adds blocks; across three popular repositories with Rust, 42 existing unwraps in production code.
let text = fs::read_to_string(path).unwrap(); // flaggedlet re = Regex::new("^a+$").expect("literal is valid"); // passeslet n = read().unwrap_or(0); // passesswallowed-error
Section titled “swallowed-error”Source: checks/swallowed-error.mjs
Flags a Rust match arm that discards the error (Err(_)) and answers with nothing or an empty value: {}, (), "", vec![], Vec::new(), String::new(), Default::default() or another Type::new()/Type::default(), with or without return. The caller cannot tell the failure from real empty data.
Scope: .rs files, excluding tests/, benches/, examples/, test module files (tests.rs, *_tests.rs, test_*.rs), build.rs and inline #[cfg(test)] modules.
Err(_) => Vec::new(), // flaggedErr(e) => { tracing::warn!("read failed: {e}"); Vec::new() } // passesKnown false negatives, by design: None, false, numbers, continue and a bare return pass. In tokio, serde_json and reqwest those were deliberate control flow (a parser returning None, a predicate answering false). A named binding left unused (Err(e) => Vec::new()) needs judgment and is left to the reviewer. Across 400 crates in a local registry the rule fired fewer than 20 times; an intentional case takes // smugan-ignore swallowed-error: <reason>.
fetch-timeout
Section titled “fetch-timeout”Source: checks/fetch-timeout.mjs
Flags a fetch(…) or globalThis.fetch(…) call with no deadline. A call has a deadline when it mentions AbortSignal/AbortController, or when its inline options object has a signal key. A timeout: key counts only in two cases:
fetchis imported or required from a library other thanundici(for example node-fetch 2), or- the call is
$fetch.
Anywhere else the message says the timeout: option is ignored. A declaration named fetch (function fetch(, a Worker’s fetch(request) { … } method, a typed member signature) is not a call.
Scope: JS/TS code files without a "use client" directive (leading comments skipped), excluding script, test, e2e, bin and config paths. Code that only runs in a browser is also skipped: a file with React state hooks (useState, useEffect, useSWR, useQuery…), a module that exports a React hook (export function useAuth()) and a Pages Router .jsx/.tsx page without getServerSideProps, getStaticProps, getStaticPaths or getInitialProps. A local fetch(new URL(…, import.meta.url)) passes, and so does a call whose options are a parameter of the enclosing function (fetch(url, init), { ...init }); a local const opts = {…} is still checked.
await fetch("https://example.com"); // flaggedawait fetch(url, { timeout: 5_000 }); // flagged: the platform fetch ignores timeout:await fetch(url, { signal: AbortSignal.timeout(3_000) }); // passesKnown false negatives:
- Wrappers (
api.get(),client.fetch()). window.fetchandself.fetch.- Any call preceded by a
..
Known false positive: options passed as a variable (fetch(url, init)) are not read, so the call is flagged even when init carries a signal.
test-weakening
Section titled “test-weakening”Source: checks/test-weakening.mjs
Flags, in test files:
- Disabled or focused tests:
- modifiers on
describe/it/test, also behind another modifier (it.concurrent.fails):.skip,.only,.todoand.fixme; - the aliases
xit,xdescribe,xtest,fitandfdescribe, unless the file declares or imports that name, or it is a method (camera.fit()); - a
skip,only,todoorfailsoption set totrueor to a string (test('x', { skip: true }, fn)); testInfo.skip/fixme/fail()andtest.info().skip/fixme/fail().
- modifiers on
- Tests marked as expected to fail:
.fail,.failsand.failing. - An
it/testblock with no assertion. The block runs to where the next test or describe starts. These count as assertions:expect,assert,expectTypeOf,assertType,.shouldandcy.. - An assertion between equal constants (
expect(true).toBe(true),assert.equal(1, 1),expect(true).toBeTruthy()). Skipped in a file that counts its assertions (t.plan,plan: n,expect.assertions,expect.hasAssertions). process.exit()orprocess.exit(0).
Scope: JS/TS code files whose path has .test. or .spec., or sits under test/, tests/, __tests__/ or e2e/.
it.only('adds', () => { expect(add(1, 2)).toBe(3); }); // flagged: focusedit('adds', () => { expect(1).toBe(1); }); // flagged: constant compared with itselfit('adds', () => { expect(add(1, 2)).toBe(3); }); // passesKnown false negatives:
- A test that asserts only on a mock.
- An assertion removed from an existing test. That needs the turn-start version, so the end-of-turn
assertion-weakeningdetector covers it.
Known false positive, accepted: a test whose assertions all live in an imported helper is flagged. Suppress it with a reason.
await-in-loop
Section titled “await-in-loop”Source: checks/await-in-loop.mjs
Flags:
- An
awaiton a database client inside a walk over a collection. The walk is afor…of, afor…in, an index loop bounded by.length, or aforEach/map/flatMapasync callback. The clients aresupabase,db,prisma,knex,sql,tx,trx,drizzle,pg,database,repoandrepository.client,pool,connandconnectioncount only with.query(/.execute(. - An
await fetch(inside aforEachcallback.
When it runs: only in the pre hook, and only in a critical turn. A critical turn means:
- the risk level is forced to
critical, - the edited file is critical, or
- another critical file was already touched in the turn (
hook.mjs,turnIsCritical).
Only loops the edit adds block. smugan check and the end of turn do not run this rule.
Scope: JS/TS code files, excluding script, test, e2e, bin, seed, migration and config paths.
// flaggedfor (const inv of invoices) { inv.items = await db.items.findMany({ where: { invoiceId: inv.id } });}// passes: one queryconst rows = await db.items.findMany({ where: { invoiceId: { in: ids } } });Known false negatives, by design:
whileloops,for (;;)loops and retry loops.for awaitloops..storagetransfers.await fetchin aforloop.- SDK clients (
client.messages.create).
assertion-weakening
Section titled “assertion-weakening”End of turn only, when the same turn changed production code. It has two parts:
- A pre-existing test that lost strong assertions blocks, like a gate violation.
- A removed test, or a deleted test file, is listed once.
Details and limits: End-of-turn detectors.
How to suppress:
- Lost assertions.
smugan-ignore assertion-weakening: <reason>on or above the test’s line. - Removed tests. A suppression on line 1 or a
smugan-ignore-file. A deleted file has no line left to carry one.
contract-drift
Section titled “contract-drift”End of turn, listed once. It flags a quiet default added to a function that existed at the turn’s first touch. Suppress it with smugan-ignore contract-drift: <reason> on or above the reported line. See End-of-turn detectors.
End of turn, listed once. It flags a new function identical to another one in the repository, up to names and literals. Suppress it with smugan-ignore clone: <reason> on or above the new function’s line. Option: minTokens (default 60). See End-of-turn detectors.
exploration-residue
Section titled “exploration-residue”End of turn, listed once. It flags a new script that nothing references, and a config or lockfile change that the request does not mention. A smugan-ignore comment does not cover it. The project’s ignore globs and checks["exploration-residue"]: false do. See End-of-turn detectors.
smugan-ignore
Section titled “smugan-ignore”Source: engine.mjs, parseSuppressions
Flags a smugan-ignore or smugan-ignore-file comment whose reason has fewer than 6 characters. This violation cannot itself be suppressed.
// smugan-ignore console-log: short ← flagged, and the next line is still flaggedconsole.log(1);// smugan-ignore console-log: startup banner for operators ← passesconsole.log(1);