Agent skill · security · jeremylongshore
implementing-database-audit-logging
Process use when you need to track database changes for compliance and
Why this skill is useful
Adds executable SQL scripts for implementing comprehensive database audit logging with compliance considerations that aren't commonly found in public documentation.
What it needs
Requires mysql, psql installed locally. About 5k tokens when loaded. Last updated 2026-08-07. 2,604 stars on the source repository.
What this skill does
Database Audit Logger Overview Implement database audit logging to track all data modifications (INSERT, UPDATE, DELETE) with full before/after values, user identity, timestamps, and application context. This skill supports trigger-based auditing for PostgreSQL and MySQL, change data capture (CDC) patterns, and application-level audit logging. Prerequisites Database credentials with CREATE TABLE, CREATE FUNCTION, and CREATE TRIGGER permissions psql or mysql CLI for executing audit setup DDL Understanding of applicable compliance requirements (which tables, which operations, retention period) Estimated storage for audit logs: plan for 10-30% of the audited table's data volume per year Separate tablespace or storage volume for audit data to prevent audit growth from affecting application performance Instructions 1. Identify tables requiring audit logging based on compliance and business needs: Tables containing PII (users, contacts, addresses) -- GDPR/HIPAA requirement Tables containing financial data (transactions, payments, invoices) -- SOX/PCI-DSS requirement Tables containing access control data (roles, permissions, API keys) -- security requirement Determine which operations to audit per table: INSERT, UPDATE, DELETE, or all three 2. Create the audit log table with comprehensive metadata: 3. Add indexes for common audit queries: CREATE INDEX idxaudittablerecord ON auditlog (tablename, recordid) CREATE INDEX idxauditchangedat ON auditlog (changedat) CREATE INDEX idxauditchangedby ON auditlog (changedby) CREATE INDEX idxauditaction ON auditlog (tablename, action) 4. Create the PostgreSQL audit trigger function: 5. Attach triggers to each audited table: CREATE TRIGGER auditusers AFTER INSERT OR UPDATE OR DELETE ON users FOR EACH ROW EXECUTE FUNCTION audittriggerfunc() Repeat for each table requiring audit logging 6. …
How to use it
Reference it in AdaL, Claude Code, Cursor or any coding agent — nothing to install:
@skills jeremylongshore/implementing-database-audit-logging--3b7b3f