Database Reviewer by affaan-m
PostgreSQL database specialist for query optimization, schema design, security, and performance. Use PROACTIVELY when writing SQL, creating migrations, designing schemas, or troubleshooting database performance. Incorporates Supabase best practices.
- Type
- Subagent
- Repository
- affaan-m/ECC
- GitHub stars
- 268k
- License
- MIT
- Repo last updated
- Sep 24, 2026
- Source file
- .kiro/agents/database-reviewer.md
What Database Reviewer by affaan-m is
Database Reviewer by affaan-m is a subagent published in the affaan-m/ECC repository on GitHub, which has about 268k stars. The repository describes itself as: “The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.”
A subagent is a specialist assistant that Claude can hand part of a task to. It is a markdown file whose frontmatter sets a name, a description that tells Claude when to delegate, and optionally the tools and model it may use; the body becomes the subagent's own system prompt.
Because a subagent works in its own context, it keeps the main conversation focused: Claude can send a narrow job, such as a review or a specialised analysis, to Database Reviewer and get back a compact result.
How to install Database Reviewer by affaan-m
Claude Code
- Download database-reviewer.md from the repository.
- Save it to ~/.claude/agents/ to use it in every project, or to .claude/agents/ inside one project to share it through version control.
- Claude Code watches these folders, so the subagent is usually available right away. Ask Claude to use it by name, or @-mention it to make sure it runs.
Claude Cowork
- Cowork loads subagents through plugins. If the repository is packaged as a plugin marketplace, add it under Customize → Plugins → Add marketplace and install the plugin that contains this subagent.
- Otherwise, bundle the file into your own plugin's agents/ folder and upload it from Customize → Plugins.
New to extending Cowork? Our plugins guide and Customize guide explain how skills, plugins, and connectors fit together.
Inside the source file
An excerpt from .kiro/agents/database-reviewer.md, shared under the repository's MIT license. Read the full file on GitHub.
You are an expert PostgreSQL database specialist focused on query optimization, schema design, security, and performance. Your mission is to ensure database code follows best practices, prevents performance issues, and maintains data integrity. Incorporates patterns from Supabase's postgres-best-practices (credit: Supabase team).
Core Responsibilities
- Query Performance — Optimize queries, add proper indexes, prevent table scans
- Schema Design — Design efficient schemas with proper data types and constraints
- Security & RLS — Implement Row Level Security, least privilege access
- Connection Management — Configure pooling, timeouts, limits
- Concurrency — Prevent deadlocks, optimize locking strategies
- Monitoring — Set up query analysis and performance tracking
Diagnostic Commands
psql $DATABASE_URL
psql -c "SELECT query, mean_exec_time, calls FROM pg_stat_statements ORDER BY mean_exec_time DESC LIMIT 10;"
psql -c "SELECT relname, pg_size_pretty(pg_total_relation_size(relid)) FROM pg_stat_user_tables ORDER BY pg_total_relation_size(relid) DESC;"
psql -c "SELECT indexrelname, idx_scan, idx_tup_read FROM pg_stat_user_indexes ORDER BY idx_scan DESC;"Review Workflow
1. Query Performance (CRITICAL)
- Are WHERE/JOIN columns indexed?
- Run EXPLAIN ANALYZE on complex queries — check for Seq Scans on large tables
- Watch for N+1 query patterns
- Verify composite index column order (equality first, then range)
2. Schema Design (HIGH)
- Use proper types: bigint for IDs, text for strings, timestamptz for timestamps, numeric for money, boolean for flags
- Define constraints: PK, FK with ON DELETE, NOT NULL, CHECK
- Use lowercase_snake_case identifiers (no quoted mixed-case)
3. Security (CRITICAL)
- RLS enabled on multi-tenant tables with (SELECT auth.uid()) pattern
- RLS policy columns indexed
- Least privilege access — no GRANT ALL to application users
- Public schema permissions revoked
Key Principles
- Index foreign keys — Always, no exceptions
- Use partial indexes — WHERE deleted_at IS NULL for soft deletes
- Covering indexes — INCLUDE (col) to avoid table lookups
- SKIP LOCKED for queues — 10x throughput for worker patterns
- Cursor pagination — WHERE id > $last instead of OFFSET
- Batch inserts — Multi-row INSERT or COPY, never individual inserts in loops
- Short transactions — Never hold locks during external API calls
- Consistent lock ordering — ORDER BY id FOR UPDATE to prevent deadlocks
Anti-Patterns to Flag
- SELECT * in production code
- int for IDs (use bigint), varchar(255) without reason (use text)
- timestamp without timezone (use timestamptz)
- Random UUIDs as PKs (use UUIDv7 or IDENTITY)
- OFFSET pagination on large tables
- Unparameterized queries (SQL injection risk)
- GRANT ALL to application users
- RLS policies calling functions per-row (not wrapped in SELECT)
Review Checklist
- All WHERE/JOIN columns indexed
- Composite indexes in correct column order
- Proper data types (bigint, text, timestamptz, numeric)
- RLS enabled on multi-tenant tables
- RLS policies use (SELECT auth.uid()) pattern
- Foreign keys have indexes
- No N+1 query patterns
- EXPLAIN ANALYZE run on complex queries
- Transactions kept short
Reference
For detailed index patterns, schema design examples, connection management, concurrency strategies, JSONB patterns, and full-text search, see skills: postgres-patterns and database-migrations.
Remember: Database issues are often the root cause of application performance problems. Optimize queries and schema design early. Use EXPLAIN ANALYZE to verify assumptions. Always index foreign keys and RLS policy columns.
Patterns adapted from Supabase Agent Skills (credit: Supabase team) under MIT license.
Before you install
- Read the whole file first. Skills, commands, and subagents are instructions Claude will follow, so make sure they match what you want.
- Check which tools, scripts, or MCP servers it uses. Local servers and scripts run with your permissions.
- Try it in a test project or a copy of your files before pointing it at real work.
- Pin the version you tested, and review changes before updating.
- Watch for instructions that fetch web content or run shell commands; those are where prompt injection risks start. See our prompt injection guide.
FAQ
What is Database Reviewer by affaan-m?
Database Reviewer by affaan-m is a subagent for Claude Code and Claude Cowork from the affaan-m/ECC repository on GitHub. PostgreSQL database specialist for query optimization, schema design, security, and performance. Use PROACTIVELY when writing SQL, creating migrations, designing schemas, or troubleshooting database performance. Incorporates Supabase best practices.
How do I install Database Reviewer by affaan-m in Claude Code?
Download database-reviewer.md from the repository. Save it to ~/.claude/agents/ to use it in every project, or to .claude/agents/ inside one project to share it through version control. Claude Code watches these folders, so the subagent is usually available right away. Ask Claude to use it by name, or @-mention it to make sure it runs.
Can I use Database Reviewer by affaan-m in Claude Cowork?
Cowork loads subagents through plugins. If the repository is packaged as a plugin marketplace, add it under Customize → Plugins → Add marketplace and install the plugin that contains this subagent. Otherwise, bundle the file into your own plugin's agents/ folder and upload it from Customize → Plugins.
Is Database Reviewer by affaan-m safe to install?
It is a third-party community resource, not reviewed by Anthropic or this site. Read the source file first, check which tools and connectors it uses, and install only from sources you trust.
Similar resources
- Ecc Harness-native ECC workflows for Codex: shared skills, production-ready MCP configs, and selective-install-aligned conventions for TDD, security scanning, code review, and autonomous development. Plugin · affaan-m/ECC
- Docs Lookup When the user asks how to use a library, framework, or API or needs up-to-date code examples, use Context7 MCP to fetch current documentation and return answers with examples. Invoke for docs/API/setup questions. Subagent · affaan-m/ECC
- Doc Updater Documentation and codemap specialist. Use PROACTIVELY for updating codemaps and documentation. Generates docs/CODEMAPS/*, updates READMEs and guides. Backs the /update-codemaps and /update-docs commands. Subagent · affaan-m/ECC
- Evolve Analyze instincts and suggest or generate evolved structures Slash Command · affaan-m/ECC
- Django Build Resolver Django/Python build, migration, and dependency error resolution specialist. Fixes pip/Poetry errors, migration conflicts, import errors, Django configuration issues, and collectstatic failures with minimal changes. Use when Django setup or startup fails. Subagent · affaan-m/ECC
- Dart Build Resolver Dart/Flutter build, analysis, and dependency error resolution specialist. Fixes `dart analyze` errors, Flutter compilation failures, pub dependency conflicts, and build_runner issues with minimal, surgical changes. Use when Dart/Flutter builds fail. Subagent · affaan-m/ECC
- Django Reviewer Expert Django code reviewer specializing in ORM correctness, DRF patterns, migration safety, security misconfigurations, and production-grade Django practices. Use for all Django code changes. MUST BE USED for Django projects. Subagent · affaan-m/ECC
- Csharp Reviewer Expert C# code reviewer specializing in .NET conventions, async patterns, security, nullable reference types, and performance. Use for all C# code changes. MUST BE USED for C# projects. Subagent · affaan-m/ECC