agentleFS
PradnyeshpPradnyeshp/Claude-Skills/.claude/skills/audit-log/SKILL.md

audit-log

Skill2 starsChanged 4 months agoMITView on GitHub

Add an audit trail that records who did what, when, and to what — for security-sensitive and compliance-relevant actions (logins, permission changes, data mutations, admin operations) — in an append-only, tamper-evident, PII-conscious way. Use when the user says "add an audit log", "track who changed what", "add an audit trail", "record admin actions", "who did this and when", "add compliance logging", or "log security-sensitive events".

7 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

5 rules. 0 are common, 4 are distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 5 edited versions we read keep these.

  • 4

    Distinctive

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Protect sensitive data: Never write secrets, passwords, tokens, or full card/PII into the audit record — store identifiers and redacted …

    line 23
  2. Very specific:

    Verify: Add tests asserting that a sensitive action writes exactly one audit entry with the right actor/action/target/outcome, that a …

    line 25
  3. Distinctive:

    Every entry must identify actor, action, target, timestamp (UTC), and outcome using a stable, queryable schema — not free-text prose.

    line 30
  4. Distinctive:

    Write the audit entry atomically with the state change (same transaction) so records can't silently go missing or lie about rolled-back …

    line 31
  5. Distinctive:

    Never store secrets or unnecessary PII in the trail.

    line 32

“Common” is measured: kept by at least 6 in 10 of the 5 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Logger, ORM & auth signals

!grep -rilE "audit|logger|winston|pino|bunyan|structlog|logging|prisma|sequelize|typeorm|sqlalchemy|django|auth|currentUser|req\\.user" --include='*.*' package.json pyproject.toml go.mod Gemfile 2>/dev/null | grep -vE 'node_modules|\.git|dist|build' | head -8

Instructions

Add an audit trail for the actions in $ARGUMENTS. An audit log is a security/compliance record, distinct from debug logging: it must reliably capture who did what to what, when for sensitive operations, and be trustworthy after the fact. Reuse the project's datastore and request/auth context.

Method

  1. Identify the auditable events. Focus on security- and compliance-relevant actions, not everything: authentication (login success/failure, logout, MFA), authorization changes (role/permission grants, ownership transfers), sensitive data mutations (create/update/delete of protected records), and privileged/admin operations. Reads usually aren't audited unless the data is regulated.
  2. Capture a complete, structured record per event: the actor (user id + a stable identifier, not just a display name), the action (a stable verb like user.role.granted), the target (entity type + id), a timestamp (UTC), the outcome (success/failure), and useful context (source IP, request id, before/after for changes). Use a consistent schema so the log is queryable.
  3. Write to an append-only, separate store. Persist audit entries to a dedicated table/stream that the application only ever inserts into — no updates or deletes from app code. Keep it separate from ordinary application logs so retention, access, and integrity can be controlled independently. For stronger tamper-evidence, consider hash-chaining entries or shipping to write-once/external storage.
  4. Record reliably and in context. Write the audit entry as close to the action as possible — ideally in the same transaction as the state change so a committed change is never missing its audit record (and a rolled-back one leaves no false entry). Emit on failed attempts too (e.g. denied permission changes), since those matter most for security.
  5. Protect sensitive data. Never write secrets, passwords, tokens, or full card/PII into the audit record — store identifiers and redacted diffs. Balance "enough to reconstruct what happened" against not turning the audit log into a new data-leak surface (see the secrets-scan and logging skills).
  6. Set retention and access. Define how long entries are kept (compliance often dictates this) and restrict who can read them. Note the chosen retention window.
  7. Verify. Add tests asserting that a sensitive action writes exactly one audit entry with the right actor/action/target/outcome, that a failed/denied attempt is also recorded, and that a rolled-back transaction leaves no entry.

Rules

  1. Audit records are append-only — application code inserts, never updates or deletes; enforce this at the store level where possible.
  2. Every entry must identify actor, action, target, timestamp (UTC), and outcome using a stable, queryable schema — not free-text prose.
  3. Write the audit entry atomically with the state change (same transaction) so records can't silently go missing or lie about rolled-back work; record failed/denied attempts too.
  4. Never store secrets or unnecessary PII in the trail; redact sensitive values and keep the audit log separate from debug logging with its own retention and access controls.
  5. End by summarizing which events are audited, the record schema, the store and its append-only guarantee, the retention window, and that failure cases are captured.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.