General
PromptBeginner5 minmarkdown
Untitled Skill
193
Argumento: nome da tabela em snake_case (ex: `coding_sessions`)
Loading actions...
Main instructions and any bundled files for this skill.
TypeScript and ESLint rules that MUST be followed when creating, modifying, or reviewing any file under apps/frontend/, including .ts, .tsx, .js, and .jsx files. Also apply when discussing frontend li...
risks
Argumento: nome da tabela em snake_case (ex: coding_sessions)
Migration — crie em supabase/migrations/<timestamp>_<nome>.sql
SQL mínimo obrigatório:
-- Habilitar RLS (NUNCA esquecer)
ALTER TABLE <tabela> ENABLE ROW LEVEL SECURITY;
-- Política de leitura (usuário vê só os próprios dados)
CREATE POLICY "<tabela>_select" ON <tabela>
FOR SELECT USING (auth.uid() = user_id);
-- Política de inserção
CREATE POLICY "<tabela>_insert" ON <tabela>
FOR INSERT WITH CHECK (auth.uid() = user_id);
-- Política de update
CREATE POLICY "<tabela>_update" ON <tabela>
FOR UPDATE USING (auth.uid() = user_id) WITH CHECK (auth.uid() = user_id);
-- Política de delete
CREATE POLICY "<tabela>_delete" ON <tabela>
FOR DELETE USING (auth.uid() = user_id);
-- Índices nas FKs e colunas mais consultadas
CREATE INDEX <tabela>_user_id_idx ON <tabela>(user_id);
lib/supabase/types.ts:export type NomeTabela = {
id: string
user_id: string
// ... demais campos
created_at: string
}
Armadilha conhecida — NUNCA usar .upsert() com índice único parcial. Usar check-then-insert/update manual.
Verificação — rode /check antes do commit.