antipatternslisted
Install: claude install-skill tstapler/dotfiles
# PostgreSQL Anti-Pattern Detection
This command uses the `postgres-optimizer` agent to systematically scan your PostgreSQL schema, migrations, and application code for common anti-patterns identified in the PostgreSQL community wiki "Don't Do This".
## Agent Delegation
```
@task postgres-optimizer
Scan the codebase for PostgreSQL anti-patterns following the comprehensive guide at https://wiki.postgresql.org/wiki/Don't_Do_This
**Scope**: ${1:-.}
**Analysis Categories**:
### 1. Text Storage Anti-Patterns
- ❌ CHAR(n) usage (should use TEXT or VARCHAR)
- ❌ VARCHAR without justification (TEXT is usually better)
- ❌ Using length constraints for validation (should use CHECK)
### 2. Data Type Anti-Patterns
- ❌ MONEY type (precision issues, use NUMERIC)
- ❌ SERIAL instead of IDENTITY
- ❌ Inappropriate type choices for domain
### 3. Date/Time Anti-Patterns
- ❌ TIMESTAMP WITHOUT TIME ZONE for events
- ❌ Storing UTC as local time
- ❌ Using TIMESTAMP for dates (should use DATE)
- ❌ Using CHAR/VARCHAR for timestamps
- ❌ BETWEEN for timestamp ranges (exclusive end)
- ❌ Now() in DEFAULT (should use CURRENT_TIMESTAMP)
### 4. SQL Construct Anti-Patterns
- ❌ NOT IN with nullable columns
- ❌ BETWEEN with timestamps (should use >= AND <)
- ❌ Upper case, quoted names without reason
- ❌ Unnecessary LIKE wildcards
- ❌ Rules instead of triggers
- ❌ Table inheritance for partitioning
### 5. Schema Design Anti-Patterns
- ❌ Rules/columns for business logic states
- ❌ EAV (Entity-Attribute-Va