audit-logging

audit-logging is a cursor rule for Cursor from e-gov/cursor-prompts. It costs 1,298 tokens per session, scanned A, original, MIT.

A set of Java rules for recording important business operations with a dedicated audit logger. Audit logs are separate from ordinary application logs and support security or compliance reviews.

In plain words
What is it for?
Use it when service code performs significant operations that need a structured record of the action, actor, time, and related details.
Why use it?
It prevents audit records from being formatted inconsistently or mixed with debug and error messages.

Cursor rule for Cursor

Written for Cursor: a Cursor rule (.mdc).

Good fit Use it when service code performs significant operations that need a structured record of the action, actor, time, and related details.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/e-gov/cursor-prompts/audit-logging
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Clone the repo
git clone --depth 1 https://github.com/e-gov/cursor-prompts

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for audit-logging

README.md
[![agentmods](https://agentmods.dev/badge/rules/e-gov/cursor-prompts/audit-logging/github.svg)](https://agentmods.dev/rules/e-gov/cursor-prompts/audit-logging)
Your own site
<a href="https://agentmods.dev/rules/e-gov/cursor-prompts/audit-logging"><img src="https://agentmods.dev/badge/rules/e-gov/cursor-prompts/audit-logging/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for audit-logging

Your own site · 80×15
<a href="https://agentmods.dev/rules/e-gov/cursor-prompts/audit-logging"><img src="https://agentmods.dev/badge/rules/e-gov/cursor-prompts/audit-logging.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 1,298 This file is loaded in full into every session.
When invoked 1,298 The same file — it is already loaded in full.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.01298 $0.01298
Opus 5.5 $0.00519 $0.00519
Sonnet 5.5 $0.00260 $0.00260
Haiku 4.5 $0.00130 $0.00130

Measured 3mo ago against content hash fba726cc26c3, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

audit-logging scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

rules/java-common/audit-logging.mdc · 161 lines

How it starts

The opening of the file, as written. The whole thing — 161 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Audit Logging Conventions

Context

  • Apply when implementing significant business operations within service classes (src/main/java/**/service/**/*.java) that require an audit trail.
  • This application uses a dedicated AuditLogger utility to ensure consistent, structured logging of important events for security and compliance.
  • Audit logs are separate from regular application/debug logs.
  • For comprehensive security best practices, see [security.mdc](mdc:rules/common/security.mdc).

Standard Log Structure

Using the AuditLogger utility ensures logs are generated in the following standard JSON format. Developers do not construct this JSON manually.

{
  "correlationId": "550e8400-e29b-41d4-a716-446655440000",
  "time": "2023-04-04T12:34:56.123456Z",
  "application": {
    "name": "bookstore-service",
    "extraInfo": {
      "environment": "dev"
    }
  },
  "activity": {
    "action": "BOOK_UPDATED", // Example action
    "extraInfo": { // Action-specific details
      "id": "123e4567-e89b-12d3-a456-426614174000",
      "oldTitle": "The Old Title",
      "newTitle": "The New Title"
      // ... other relevant fields ...
    }
  },
  "actor": {
    "name": "system" // Or user identifier
  },
  "client": {
    "id": "bookstore-app",
    "source": "INTERNAL"
  },
  "result": {
    "code": "SUCCESS",
    "message": "Operation completed successfully"
  }
}

Requirements

  • Use AuditLogger: ALL audit log entries MUST be generated using the static methods provided by the AuditLogger utility class.
  • Log Significant Business Events: Only log high-level, meaningful business operations (e.g., resource creation, update, deletion, key access), not low-level implementation details.
  • Log After Success: Audit log entries for successful operations MUST be created after the core business logic (e.g., database commit) has completed successfully within the same transaction context.
  • Do Not Log Sensitive Data: Avoid including sensitive personal information (e.g., passwords, detailed financial data, PII unless strictly necessary and compliant with regulations) in audit log messages or extraInfo fields. Redact or omit if necessary.
  • Use Correct Methods: Use the appropriate AuditLogger method for the event type.
  • Log All Authentication Attempts: ALL authentication attempts MUST be logged regardless of outcome (login, logout, failed authentication, session timeout).
  • Log All User-Initiated Activities: ALL user-initiated activities MUST be logged (CRUD operations, searches, file uploads, exports).

Read the full file on GitHub · 161 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3mo ago First seen · 161 lines · 1,298 tokens per session scan A fba726cc26c3

Subscribe to this mod's changes

audit-logging is a cursor rule published in the GitHub repository e-gov/cursor-prompts (35 stars, last pushed 7mo ago), licensed MIT. It adds 1,298 tokens to every session, about $0.0052 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

audit-logging compared with cursor rules from other repositories

audit-logging next to 6 cursor rules from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
audit-logginge-gov/cursor-promptsCursor rule357mo agoMITA1,298Cursor
ponytailDietrichGebert/ponytailCursor rule203k10d agoMITA604Cursor
angular-20angular/angularCursor rule102ktodayMITA0Cursor
dev-standardapache/supersetCursor rule76ktodayApache-2.0A1,147Cursor
prefer-assertions-over-defensive-checksprisma/ormCursor rule48ktodayApache-2.0A0Cursor
prefer-direct-imports-over-module-mocksprisma/ormCursor rule48ktodayApache-2.0A0Cursor
shared-plane-packagesprisma/ormCursor rule48ktodayApache-2.0A0Cursor