/mainframe-natural-adabas-classic:postgresql-code-reviewfrom mainframe-natural-adabas-classic
Reviews PostgreSQL SQL, schema, migrations, functions, triggers, indexes, JSONB, arrays, custom types, domains, extensions, privileges, and Row Level Security for anti-patterns. Use when asked to audit or critique PostgreSQL code, database migrations, PL/pgSQL, RLS policies, or schema design.
Ships in mainframe-natural-adabas-classic. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Review PostgreSQL-specific code for correctness, performance, type quality, security, and maintainability, then return a verdict, evidence-backed findings, and paste-ready corrected SQL.
| Area | Bad pattern | Better pattern |
|---|---|---|
| JSONB filters | data->>'status' = 'shipped' without index support. | Use containment: data @> '{"status": "shipped"}' and CREATE INDEX idx_orders_status ON orders USING gin((data->'status'));. |
| JSONB structure | Deep, unconstrained blobs such as `data | |
| Array filters | 'electronics' = ANY(categories) without a supporting index. | Use CREATE INDEX idx_products_categories ON products USING gin(categories); and categories @> ARRAY['electronics']. |
| Array mutation | Array concatenation in row-by-row loops. | Use bulk updates such as `categories = categories |
| Concern | Review rule |
|---|---|
| Primary keys | Prefer PostgreSQL-appropriate generated identifiers such as BIGSERIAL PRIMARY KEY or the project standard. |
| Email and text | Use CITEXT for case-insensitive email, TEXT instead of arbitrary VARCHAR when there is no true length rule, and CHECK constraints for real validation. |
| Time | Use TIMESTAMPTZ instead of TIMESTAMP for instants. |
| JSONB | Default structured JSONB with metadata JSONB DEFAULT '{}' when optional document data is intentional. |
| Constrained values | Use ENUM, custom domains, or lookup tables rather than free VARCHAR(20) values. |
| Money-like values | Use a domain such as positive_amount AS DECIMAL(10,2) CHECK (VALUE > 0) when the constraint is reused. |
Example type objects to preserve: CREATE TYPE currency_code AS ENUM ('USD', 'EUR', 'GBP', 'JPY');, CREATE TYPE transaction_status AS ENUM ('pending', 'completed', 'failed', 'cancelled');, and CREATE DOMAIN positive_amount AS DECIMAL(10,2) CHECK (VALUE > 0);.
| Area | Review rule |
|---|---|
| Trigger timestamps | Use CURRENT_TIMESTAMP and fire triggers only when needed with WHEN (OLD.* IS DISTINCT FROM NEW.*). |
| Trigger API | Check CREATE OR REPLACE FUNCTION update_modified_time() RETURNS TRIGGER, NEW.updated_at, RETURN NEW, LANGUAGE plpgsql, CREATE TRIGGER update_modified_time_trigger, and EXECUTE FUNCTION update_modified_time(). |
| Extensions | Use CREATE EXTENSION IF NOT EXISTS "uuid-ossp", "pgcrypto", and "pg_trgm" only when needed; know uuid_generate_v4(), crypt('password', gen_salt('bf')), and word_similarity('postgres', 'postgre'). |
| Row Level Security | Require ALTER TABLE sensitive_data ENABLE ROW LEVEL SECURITY; and policies such as CREATE POLICY user_data_policy ... USING (user_id = current_setting('app.current_user_id')::INTEGER); when tenant or user isolation is needed. |
| Privileges | Avoid GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO app_user; prefer GRANT SELECT, INSERT, UPDATE ON specific_table TO app_user and GRANT USAGE ON SEQUENCE specific_table_id_seq TO app_user. |
| Indexes | Check use of GIN for JSONB and arrays, GiST for ranges/geospatial, partial indexes for selective predicates, and evidence from plans where available. |
| SQL injection | No user input concatenated into SQL; require JPQL, derived queries, or bound native parameters when reviewing application access. |
GIN and GiST for appropriate data types.JSONB like a string field instead of using operators such as @> and ?.VARCHAR for limited value sets instead of ENUM, domain, lookup table, or CHECK.TIMESTAMP for real-world instants where time zone correctness matters.JSONB without validation for fields the application depends on.Use exact PostgreSQL examples when relevant: UNIQUE, NULL, created_at, idx_users_metadata, valid_email, table_name, application_role, UUID, BEGIN, BEFORE, EACH, GOOD, JSONB/arrays, GIN/GiST, function/procedure, and built-in security or extension capabilities.
Example schema facts include email CITEXT UNIQUE NOT NULL, created_at TIMESTAMPTZ DEFAULT NOW(), metadata JSONB DEFAULT '{}', CONSTRAINT valid_email CHECK (...), and CREATE INDEX idx_users_metadata ON users USING gin(metadata);.
## PostgreSQL review — <file or selection>
**Verdict:** Pass | Fix required | Reject
| # | Severity | Finding | Evidence | Fix |
| --- | --- | --- | --- | --- |
| 1 | High | User input concatenated into SQL | `<file:line or snippet>` | Bind through JPQL, a derived query, or a parameterized native query. |
| 2 | Medium | JSONB containment query has no GIN index | `Seq Scan on orders` | `CREATE INDEX idx_orders_data ON orders USING gin(data);` |
| 3 | Low | VARCHAR used for case-insensitive email | `email VARCHAR(255)` | Use `CITEXT` plus an appropriate `CHECK` constraint. |
### Corrected SQL
```sql
CREATE INDEX idx_orders_data ON orders USING gin(data);
-- Repository query stays parameterized: WHERE data @> :filter
## Quality gate
- [ ] A verdict is stated: Pass, Fix required, or Reject.
- [ ] Every finding carries severity and concrete evidence such as file/line, snippet, or plan output.
- [ ] No user input is concatenated into SQL; every parameter is bound.
- [ ] PostgreSQL-specific types including `CITEXT`, `JSONB`, arrays, `ENUM`, and domains were considered.
- [ ] Index types including `GIN`, `GiST`, and partial indexes were evaluated where relevant.
- [ ] `CHECK`, `ENUM`, and domain constraints were validated for constrained values.
- [ ] `RLS`, privileges, extension usage, functions, and triggers were checked when present.
- [ ] Corrected SQL is paste-ready and rollback-safe for schema changes.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
25 skills in this plugin
/adabas-postgresql-migrationModel Adabas files, DDM and FDT definitions, MU and PE structures, packed and unpacked numerics, descriptors, and ISN identity as a PostgreSQL schema, then prove equivalence with recorded reconciliation numbers. Use when designing or reviewing an Adabas to PostgreSQL data migration, mapping legacy field formats to column types, deciding child-table versus array storage, or verifying that migrated data matches the legacy source./code-modernizationUse this skill when the user asks to modernize legacy code with a disciplined GitHub Copilot workflow: brief, assess, map, extract business rules, reimagine architecture, transform modules, and harden with tests and security review. Trigger for COBOL, JCL, legacy Java, .NET, C++, classic ASP, monolith modernization, behavior-preserving rewrite, business-rule extraction, modernization assessment, or legacy-to-modern transformation./create-architectural-decision-recordCreate an Architectural Decision Record (ADR) as a structured Markdown document with front matter, coded consequences, alternatives, implementation notes, and references. Use when the user asks to document an architecture decision, create an ADR, capture alternatives and trade-offs, or save a decision under docs/adr./github-actions-hardeningReview, audit, author, and harden GitHub Actions workflows against Actions-specific threats: untrusted-input script injection, privileged trigger escalation, mutable action references, over-scoped GITHUB_TOKEN permissions, unsafe GITHUB_ENV/GITHUB_OUTPUT writes, secret exposure, OIDC misuse, and self-hosted runner risk. Use for .github/workflows/*.yml, secure my CI, pull_request_target danger, SHA pinning, or permissions lockdown./java-junitApply JUnit 5 best practices for Java tests, including Maven or Gradle setup, standard and parameterized tests, lifecycle hooks, assertions, Mockito isolation, tags, nested tests, and test commands. Use when asked for JUnit 5+ guidance or to write Java unit tests./java-springbootApply Spring Boot best practices for project structure, dependency injection, configuration, REST controllers, DTO validation, services, transactions, Spring Data JPA, logging, testing, and security. Use when asked for Spring Boot guidance or to implement Java backend code.npx claudepluginhub gbb-acelerators/awesome-harness-primitives --plugin mainframe-natural-adabas-classicOther plugins' skills for the same job