congiuluc/my-awesome-copilot/audit-backend-python

Claude Code and agent skill by congiuluc/my-awesome-copilot

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Implement audit logging and audit trails for Python FastAPI applications. Covers SQLAlchemy event listeners, middleware-based action logging, Pydantic audit models, and compliance patterns. Use when: adding audit trails to data changes, logging user actions, implementing compliance requirements (GDPR, SOC2, HIPAA), or reviewing audit coverage in Python.

Install

npx vskill@latest install congiuluc/my-awesome-copilot/audit-backend-python

SKILL.md

The same SKILL.md was published earlier as congiuluc/my-awesome-copilot/audit-backend-python.

Audit Logging (Python FastAPI)

When to Use

  • Adding audit trails for entity create/update/delete operations
  • Logging user actions (login, permission changes, data access)
  • Implementing compliance audit requirements (GDPR, SOC2, HIPAA)
  • Reviewing existing audit coverage for gaps
  • Adding tamper-proof audit storage

Official Documentation

Key Principles

  • Audit is separate from logging — audit events are business-critical records, not debug logs.
  • Immutable and append-only — audit records must never be updated or deleted.
  • Who, What, When, Where — every audit entry captures the actor, action, timestamp, and target.
  • Sensitive data handling — store what changed but redact PII where required.
  • Async and non-blocking — audit writes must not slow down the primary operation.

Procedure

  1. Define the AuditEntry Pydantic/SQLAlchemy model (see audit model sample)
  2. Implement SQLAlchemy after_insert, after_update, after_delete event listeners
  3. Add a FastAPI middleware for HTTP request-level action auditing
  4. Store audit records in a dedicated, append-only table
  5. Include the actor (user ID), action type, entity type, entity ID, timestamp, and changes
  6. Redact sensitive fields (passwords, tokens, PII) before persisting
  7. Add retention policies and archival for compliance

Audit Entry Structure

FieldTypeDescription
idstrUnique audit entry ID (UUID)
timestampdatetimeWhen the action occurred (UTC)
user_idstrWho performed the action
actionstrCREATE, UPDATE, DELETE, ACCESS, LOGIN, etc.
entity_typestrThe type of entity affected
entity_idstrThe ID of the entity affected
changes`str \None`JSON diff of old/new values (for updates)
ip_address`str \None`Client IP address
correlation_id`str \None`Request correlation ID

Constraints

  • NEVER update or delete audit records
  • ALWAYS capture the acting user from the request authentication context
  • ALWAYS use UTC timestamps (datetime.now(timezone.utc))
  • ALWAYS redact sensitive fields before persisting
  • NEVER let audit failures break the primary operation (use try/except)

Security

  • Security scanPassed, 95 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

7-day trend score
5

Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/congiuluc/my-awesome-copilot/audit-backend-python/badge)](https://verified-skill.com/skills/congiuluc/my-awesome-copilot/audit-backend-python)

Something wrong with this skill or its page? Tell us.