CtrlK
BlogDocsLog inGet started
Tessl Logo

alonso-skills/postgres-writing-guidelines

Use when writing or reviewing PostgreSQL/PL-pgSQL, designing table schemas, writing functions and procedures, building migrations, defining domains, or architecting a Postgres application database. Also use when writing RAISE EXCEPTION patterns, BEFORE/AFTER triggers for cross-table constraints, base/subtype hierarchies, composite key designs, row-level security policies, or idempotent DDL scripts. If you are touching Postgres for an application database, use this skill. PostgreSQL-specific — examples will not run on other engines.

84

1.72x
Quality

89%

Does it follow best practices?

Impact

100%

1.72x

Average score across 2 eval scenarios

SecuritybySnyk

Passed

No known issues

Overview
Quality
Evals
Security
Files

task.mdevals/scenario-1/

E-Commerce Database Schema

Problem Description

A new e-commerce platform needs a PostgreSQL database schema to power its core ordering system. The platform sells physical goods and needs to track customers, their orders, individual order lines, and shipments. Customers may have both a standard account and the ability to store saved payment methods, but the schema must enforce that payment method records can only exist for verified customers.

The team has adopted a strict PostgreSQL-first approach: they want the database itself — not the application layer — to enforce business rules wherever possible. All naming must be consistent and self-documenting so that any developer looking at the schema immediately understands the relationships and constraints at a glance, including from error messages in production logs.

The schema should also support multiple account tiers (standard and premium), where each tier has a different set of attributes tracked, but all share common customer attributes. The ordering hierarchy must preserve the full ancestry of each item so that joins across the hierarchy never require traversing intermediate tables unnecessarily.

Output Specification

Produce a single SQL file named schema.sql containing all DDL needed to build the schema from scratch, including:

  • All type and column definitions required for the schema
  • All table definitions with constraints, including the customer hierarchy and order line hierarchy
  • Any trigger functions and triggers required to enforce cross-table rules
  • At least one stored procedure for inserting a new order (with its first line)
  • At least one stored function for looking up a customer by email
  • A view appropriate for customer-facing order history

The file should be runnable as a fresh database setup. Also produce a types.yaml file cataloging all custom types used in the schema, their underlying base types, and what category of data they represent.

evals

scenario-1

criteria.json

task.md

SKILL.md

tile.json