Automated summary
This skill guides the implementation of database audit logging (triggers, application-level logging, CDC, or native logs) for compliance and security monitoring.
Strengths
- Compares four audit strategies (triggers, application-level, CDC, native logs) with explicit pros and cons
- Provides a concrete audit table schema with JSON old/new values, indexes, and date partitioning
- Covers the full lifecycle: requirements, implementation, archival, alerting, and validation
- Includes a validation and documentation step aimed at compliance auditors
Limitations
- The file only partially details the generated SQL (the Output section is truncated)
- Command examples are limited to psql and mysql; other engines are not tooled
- CDC is covered at the strategy-selection level, not as a full streaming infrastructure setup
Use it when you need a reliable audit trail on sensitive tables to satisfy GDPR, HIPAA, SOX, or PCI-DSS requirements.
Avoid it when the need is plain infrastructure monitoring or application logs without tracking database changes.
Security analysis
CautionThis is a legitimate database audit-logging skill with no malicious, destructive, exfiltration, or obfuscated instructions. However, it uses powerful database tools to create triggers and audit tables and may capture sensitive data, so it warrants caution rather than a safe rating.
- •Executes SQL via psql/mysql and creates database triggers, which can alter schema and affect production performance or availability.
- •Audit design captures old/new row values, client IP, and application context, potentially storing sensitive or PII data in logs without explicit masking, redaction, or encryption guidance.
- •Recommends granting INSERT on the audit table to all database users, which may be overly broad for least-privilege environments.
- •No explicit transaction/rollback or environment guardrails for running DDL/DML against live databases.
Examples
Implement database audit logging on our Postgres `customers` and `orders` tables using AFTER INSERT/UPDATE/DELETE triggers that store old and new row values as JSON, with an audit table partitioned by month.We need audit trails for SOX compliance on our MySQL billing database. Compare trigger-based auditing, application-level logging, and CDC for our case, then recommend one and draft the audit table schema.Add audit logging to our users table, then write queries and alerts to flag bulk deletes and off-hours changes for the security team.name: implementing-database-audit-logging description: | Process use when you need to track database changes for compliance and security monitoring. This skill implements audit logging using triggers, application-level logging, CDC, or native logs. Trigger with phrases like "implement database audit logging", "add audit trails", "track database changes", or "monitor database activity for compliance".
allowed-tools: Read, Write, Edit, Grep, Glob, Bash(psql:), Bash(mysql:) version: 1.0.0 author: Jeremy Longshore jeremy@intentsolutions.io license: MIT
Database Audit Logger
This skill provides automated assistance for database audit logger tasks.
Prerequisites
Before using this skill, ensure:
- Database credentials with CREATE TABLE and CREATE TRIGGER permissions
- Understanding of compliance requirements (GDPR, HIPAA, SOX, PCI-DSS)
- Sufficient storage for audit logs (estimate 10-30% of data size)
- Decision on audit log retention period
- Access to database documentation for table schemas
- Monitoring tools configured for audit log analysis
Instructions
Step 1: Define Audit Requirements
- Identify tables requiring audit logging based on compliance needs
- Determine events to audit (INSERT, UPDATE, DELETE, SELECT for sensitive data)
- Define which columns contain sensitive data requiring audit
- Document retention requirements for audit logs
- Identify users/roles whose actions need auditing
Step 2: Choose Audit Strategy
- Trigger-Based Auditing: Best for comprehensive row-level tracking
- Pros: Automatic, no application changes, captures all changes
- Cons: Performance overhead, complex trigger maintenance
- Application-Level Auditing: Best for selective auditing
- Pros: Flexible, lower database overhead, easier debugging
- Cons: Requires application changes, can miss direct database changes
- Change Data Capture (CDC): Best for real-time streaming
- Pros: Minimal performance impact, real-time analysis, external processing
- Cons: Complex setup, requires CDC infrastructure
- Native Database Logs: Best for general monitoring
- Pros: No setup, captures everything, built-in
- Cons: High volume, limited retention, difficult to query
Step 3: Design Audit Table Schema
- Create audit log table with these core columns:
- audit_id (primary key), table_name, action (INSERT/UPDATE/DELETE)
- record_id (reference to audited record), old_values (JSON), new_values (JSON)
- changed_by (user), changed_at (timestamp), client_ip, application_context
- Add indexes on table_name, changed_at, changed_by for query performance
- Partition audit table by date for efficient archival
- Configure tablespace for audit logs separate from primary data
Step 4: Implement Audit Mechanism
- For trigger-based: Create AFTER INSERT/UPDATE/DELETE triggers on each table
- Capture old and new row values as JSON in trigger body
- Record user context (CURRENT_USER, application user, IP address)
- Handle trigger failures gracefully (log but don't block operations)
- Test triggers with sample data modifications
Step 5: Configure Audit Log Management
- Set up automated archival of old audit logs to cold storage
- Implement audit log analysis queries for common compliance reports
- Create alerts for suspicious activities (bulk deletes, off-hours changes)
- Document audit log query procedures for compliance auditors
- Schedule periodic audit log reviews with security team
Step 6: Validate Audit Implementation
- Perform test operations on audited tables
- Verify audit log entries are created with complete data
- Test audit log queries for performance
- Confirm audit logs cannot be modified by regular users
- Document audit implementation for compliance documentation
Output
This skill produces:
Audit Table Schema: SQL DDL for audit log table with proper indexes and partitioning
Audit Triggers: Database triggers for automatic audit log population on data changes
Audit Log Queries: Pre-built SQL queries for compliance reports and change tracking
Implementation Documentation: Configuration details, trigger logic, and maintenance procedures
Compliance Report Templates: SQL queries for GDPR access logs, SOX change reports, etc.
Error Handling
Trigger Performance Issues:
- Audit only critical tables, not all tables
- Use asynchronous audit logging with queue systems
- Batch audit log inserts instead of individual inserts
- Monitor trigger execution time and optimize trigger logic
Audit Table Growth:
- Implement automated archival of audit logs older than retention period
- Partition audit table by month or quarter
- Compress old audit log partitions
- Move historical audit logs to cheaper storage tiers
Missing Audit Context:
- Set application context in database session before operations
- Use database session variables to pass user identity
- Implement connection pooling with session initialization
- Log application user separately from database user
Permission Issues:
- Ensure audit log table is writable by trigger execution context
- Grant INSERT on audit table to all database users
- Protect audit table from modifications (no UPDATE/DELETE grants)
- Use separate schema for audit tables with restricted access
Resources
Audit Table Templates:
- PostgreSQL audit trigger:
{baseDir}/templates/postgresql-audit-trigger.sql - MySQL audit trigger:
{baseDir}/templates/mysql-audit-trigger.sql - Audit table schema:
{baseDir}/templates/audit-table-schema.sql
Compliance Report Queries: {baseDir}/queries/compliance-reports/
- GDPR data access report
- SOX change audit report
- User activity summary
- Suspicious activity detection
Audit Strategy Guide: {baseDir}/docs/audit-strategy-selection.md
Performance Tuning: {baseDir}/docs/audit-performance-optimization.md
Archival Procedures: {baseDir}/scripts/audit-archival.sh
Overview
This skill provides automated assistance for the described functionality.
Examples
Example usage patterns will be demonstrated in context.
From the file to a first result
The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.
View the source and supporting filesThis download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.
1. Download the file
Download SKILL.mdFrom the root of a test project, save the file as .skill-downloads/database-audit-logging-implementation-mma3jsj2/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.
Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.
mkdir -p '.skill-downloads/database-audit-logging-implementation-mma3jsj2' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/database-audit-logging-implementation-mma3jsj2/download' --output '.skill-downloads/database-audit-logging-implementation-mma3jsj2/SKILL.md.part' && mv '.skill-downloads/database-audit-logging-implementation-mma3jsj2/SKILL.md.part' '.skill-downloads/database-audit-logging-implementation-mma3jsj2/SKILL.md'2. Check prerequisites
Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.
Tools declared by the author (check availability in your agent): Read, Write, Edit, Grep, Glob, Bash(psql:*), Bash(mysql:*)
Original excerpt: Prerequisites
Before using this skill, ensure:
- Database credentials with CREATE TABLE and CREATE TRIGGER permissions
- Understanding of compliance requirements (GDPR, HIPAA, SOX, PCI-DSS)
- Sufficient storage for audit logs (estimate 10-30% of data size)
- Decision on audit log retention period
- Access to database documentation for table schemas
- Monitoring tools configured for audit log analysis
The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.
3. Load the skill
After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.
Claude Code
test -f '.skill-downloads/database-audit-logging-implementation-mma3jsj2/SKILL.md' && test -s '.skill-downloads/database-audit-logging-implementation-mma3jsj2/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/implementing-database-audit-logging' && cp -R '.skill-downloads/database-audit-logging-implementation-mma3jsj2' '.claude/skills/implementing-database-audit-logging'Cursor
test -f '.skill-downloads/database-audit-logging-implementation-mma3jsj2/SKILL.md' && test -s '.skill-downloads/database-audit-logging-implementation-mma3jsj2/SKILL.md' && mkdir -p '.cursor/skills' && test ! -e '.cursor/skills/implementing-database-audit-logging' && cp -R '.skill-downloads/database-audit-logging-implementation-mma3jsj2' '.cursor/skills/implementing-database-audit-logging'Codex
test -f '.skill-downloads/database-audit-logging-implementation-mma3jsj2/SKILL.md' && test -s '.skill-downloads/database-audit-logging-implementation-mma3jsj2/SKILL.md' && mkdir -p '.agents/skills' && test ! -e '.agents/skills/implementing-database-audit-logging' && cp -R '.skill-downloads/database-audit-logging-implementation-mma3jsj2' '.agents/skills/implementing-database-audit-logging'OpenSkills
OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.
Official OpenSkills installationopenskills install './.skill-downloads/database-audit-logging-implementation-mma3jsj2'openskills read 'database-audit-logging-implementation-mma3jsj2'Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.
For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.
openskills syncManual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.
4. Try a first task
Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:
Read .skill-downloads/database-audit-logging-implementation-mma3jsj2/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.
DeFi AMM Security
Security
Security checklist for Solidity AMM contracts, liquidity pools, and swap flows. Covers reentrancy, donation attacks, oracle manipulation, slippage, and integer math.
Semgrep Rule Creator
Security
Creates custom Semgrep rules for detecting security vulnerabilities, bug patterns, and code patterns. Includes test-first methodology, taint mode support, and validation steps. Helps when building targeted static analysis detections.
Dev Toolbar Review Guide
Security
Safety rules for the dev toolbar, PostHog client, and feature flags. Use when reviewing changes to dev-tools and related files, covering environment guards, override cookies, and SSE stream safety.