Skills DirectorySkills Directory
SkillsLearnSecurityCategoriesDocsCommunityBlog
Sign InSubmit Skill
Skills Directory

Security-tested agent skills for Claude, coding agents, and AI workflows.

Directory

  • Browse Skills
  • All Skills A–Z
  • Claude Skills
  • Claude Code Skills
  • Agent Skills
  • Categories
  • Submit a Skill

Learn

  • Learn Hub
  • Install Claude Skills
  • Write SKILL.md
  • Skills vs MCP
  • Directories Compared

Security

  • Security
  • Methodology
  • Secure Claude Skills
  • Security Badges

Company

  • About
  • Community
  • Blog
  • API Docs
  • Advertise

2026 Skills Directory. All rights reserved.

Back to skills

Antipatterns

ASecurity

Scan PostgreSQL codebase and schema for anti-patterns using postgres-optimizer agent

8 stars
0 votes
0 copies
0 views
Added 9/20/2026
databasesrustgobashsqldatabasesecurityperformance

Security Analysis

A100/100

Scanned 9/20/2026

Install to Claude Code

$npx -y skills add tstapler/dotfiles --skill antipatterns --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Antipatterns?

Add the live security badge to your README — it updates automatically with every re-scan.

Security grade badge for Antipatterns
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/tstapler-antipatterns/badge)](https://www.skillsdirectory.com/skills/tstapler-antipatterns)

More formats (shields.io, HTML) on the badges page.

Download Zip
Files
SKILL.md
---
description: Scan PostgreSQL codebase and schema for anti-patterns using postgres-optimizer agent
---

# 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-Value) patterns
- ❌ Splitting tables by time period manually
- ❌ Polymorphic associations without proper foreign keys

### 6. Index Anti-Patterns
- ❌ Missing indexes on foreign keys
- ❌ Redundant/overlapping indexes
- ❌ Indexes on small tables
- ❌ Wrong index type for query patterns
- ❌ Not using partial indexes appropriately

### 7. Query Anti-Patterns
- ❌ SELECT * in application queries
- ❌ N+1 query patterns
- ❌ Missing LIMIT on unbounded queries
- ❌ Cartesian products (missing JOIN conditions)
- ❌ Subqueries that should be JOINs

### 8. Security/Configuration Anti-Patterns
- ❌ SQL_ASCII encoding (should use UTF8)
- ❌ TRUST authentication over TCP/IP
- ❌ psql -W in scripts (password prompt)
- ❌ String concatenation for SQL (SQL injection risk)

**Search Locations**:
1. **Schema Definitions**: DDL files, migrations, schema.sql
2. **Application Code**: Query builders, ORM configurations, raw SQL
3. **Configuration**: postgresql.conf, pg_hba.conf, connection strings
4. **Database Inspection**: If connection details provided, inspect live schema

**Analysis Output**:

For each anti-pattern found:
1. **Location**: File:line or database object name
2. **Anti-Pattern**: Which specific pattern from the list
3. **Current Code**: The problematic code snippet
4. **Impact**: Performance/correctness/security risk (Critical/High/Medium/Low)
5. **Fix**: Specific recommended change
6. **Migration Path**: How to safely remediate (if schema change)

**Deliverables**:
- Summary count of anti-patterns by category and severity
- Detailed findings report with file locations
- Prioritized remediation plan (Critical → High → Medium → Low)
- Safe migration scripts for schema changes
- Estimated effort and risk for each fix

**Safety Notes**:
- Flag any findings that require production migration carefully
- Provide rollback plans for schema changes
- Consider backward compatibility for type changes
- Note any performance implications during migration
```

## Usage

```bash
# Scan current directory
/db:antipatterns

# Scan specific path
/db:antipatterns src/main/resources/db/migration

# Scan with database connection (add to command)
/db:antipatterns . --db-url postgresql://localhost:5432/mydb
```

## Reference

This command implements checks from the PostgreSQL community wiki:
https://wiki.postgresql.org/wiki/Don't_Do_This

## Integration with /db:review

This command complements `/db:review` by:
- `/db:review`: Comprehensive schema optimization analysis (cardinality, indexes, queries)
- `/db:antipatterns`: Focused anti-pattern detection in code and schema

Use both for complete database health assessment.

Attribution

tstaplertstapler
View sourceMore from tstapler →
SSkills DirectorySkills Directory

Your tool, in front of Claude Code builders.

3 founder slots · $299/mo · GSC-verified traffic · sponsors can never buy grades.

See placements

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments (0)

No comments yet. Be the first to comment!

SSkills DirectorySkills Directory

Your tool, in front of Claude Code builders.

3 founder slots · $299/mo · GSC-verified traffic · sponsors can never buy grades.

See placements

Related Skills

Mysql Best Practices

MySQL development best practices for schema design, query optimization, and database administration

2481 votes

Clickhouse Io

ClickHouse数据库模式、查询优化、分析和数据工程最佳实践,适用于高性能分析工作负载。

2456590 votes

Jpa Patterns

Spring Boot中的JPA/Hibernate实体设计、关系、查询优化、事务、审计、索引、分页和连接池模式。

2456590 votes

Postgres Patterns

基于Supabase最佳实践的PostgreSQL数据库模式,用于查询优化、架构设计、索引和安全。

2456590 votes

V3 Memory Unification

Unify 6+ memory systems into AgentDB with HNSW indexing for 150x-12,500x search improvements. Implements ADR-006 (Unified Memory Service) and ADR-009 (Hybrid Memory Backend).

701370 votes
View all in databases →