Works with the AI Agents you already use

    Spring Audit Implementation

    by Puneet Swarup

    1

    Checks the record. The field-by-field review an auditor actually applies: actor, action, resource, outcome, timestamp, correlation, source.

    $19

    Secure checkout via Stripe

    Money-back guarantee

    Converts to your local currency at checkout

    Security scanned
    Spring Audit Implementation

    Spring Audit Implementation

    Example session with this skill installed

    Request

    Review our audit logging implementation and tell me what's wrong with it.
    

    What the agent did

    Ran python scripts/verify.py . against the service, then read the two worst findings at
    their file and line before proposing anything.

    Output (trimmed)

    
    ## Findings, worst first
    
    | # | Check | Severity | Where | Problem |
    |---|---|---|---|---|
    | 1 | A | high | `PaymentService.java`:21 | audit call in transfer() shares the business transaction, so a rollback erases the record of the attempt |
    | 2 | B | high | `PaymentService.java`:18 | audit failure in transfer() is swallowed by an empty catch |
    | 3 | C | high | `PaymentService.java`:21 | audit call in transfer() passes unmasked personal data: cardNumber |
    | 5 | E | medium | `AuditAspect.java`:8 | aspect declares no @Order, so it may run inside the business transaction |
    
    

    What the agent then said

    Three of these are the same bug wearing different clothes. transfer() writes its audit
    row inside the transaction, so a failed transfer leaves no record of the attempt — and the
    attempt is the part an auditor asks for. The empty catch at line 18 means that when the
    sink is down, you would never know. And the card number goes into the record as-is, so
    masking it in the UI has masked nothing.

    Fix in this order: give the audit write its own transaction with REQUIRES_NEW, replace
    the empty catch with an error log plus a counter, and mask the card number where the
    record is built. Then add the test that proves it — assert a failed transfer still leaves
    one audit row. If you cannot write that assertion, the decoupling is not real.


    • Read your context and instructions
    • Compiled the spring audit implementation

    I have analyzed the PaymentService and implemented a decoupled audit trail. I used Propagation.REQUIRES_NEW to ensure the audit record is committed even if the primary transaction rolls back due to a business exception.

    Next steps

    1. Run python scripts/verify.py to ensure the new record call meets field requirements.
    2. Add a integration test using @Test to verify repository.findAll().size() == 1 after a forced InsufficientFundsException.
    3. Verify that account_number in the database contains only the masked values.

    Connects securely to your tools. The creator never sees your data.

    About this skill

    The gap in most Spring Boot audit logging is not that someone forgot to log. It is that they logged inside the transaction, and the rollback took the record with it.

    This skill implements audit logging correctly, and checks an implementation that already exists.

    What it does

    Verifies. A script reads the Java sources and reports six failures, each with a file and line:

    • Audit call inside the business transaction, where a rollback erases it
    • Audit failure swallowed by an empty catch, so gaps are invisible
    • Personal data reaching the sink unmasked
    • Audit written to the application log instead of a sink
    • An aspect with no @Order, which silently becomes the first problem
    • A transactional state change with no audit call at all

    Implements. Working code for the four patterns — explicit call at the state change, aspect ordered outside the transaction, filter for request-level facts, and a transactional outbox for when nothing may be lost — plus the sink interface, the masking utility and the correlation id.

    Checks the record. The field-by-field review an auditor actually applies: actor, action, resource, outcome, timestamp, correlation, source. And the three structural questions: is the store append-only, does a rolled-back operation leave a record, is retention stated and enforced.

    How it works

    It reads method bodies and annotations, not file names. The transaction check looks for an audit call inside a @Transactional method without REQUIRES_NEW and without an async publish — which is the exact shape of the bug. The masking check looks at what is passed to the audit call, not at whether a masking utility exists somewhere in the repository.

    It is deliberately quiet on code that is already correct: run against a well-built audit library, it reports zero findings.

    Where it stops

    • Regex-based Java parsing, not a compiler. It cannot follow an audit call across three classes, or see audit done in a gateway, proxy or database trigger.
    • It cannot tell whether the sink is disabled by configuration in production.
    • It does not decide your retention policy, your legal basis for processing, or which regulation applies. Those are decisions with a name against them.
    • It writes no Kotlin, XML-defined endpoints or GraphQL resolvers.

    It is the fix for the gaps found by the free spring-audit-coverage skill. If you have not established where your gaps are yet, start there — this skill assumes you know which endpoints you are fixing.

    Java/Spring Boot only. No Kotlin or GraphQL support. Regex-based verification cannot trace cross-class call chains. Does not manage retention policies or production config checks.

    How to use

    1. 1

      Connect your agent to the Agensi MCP

      Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup

    2. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 3

      Ask for what you need

      Your agent loads this skill and uses it on your task. It always asks before buying a skill.

    Reviews

    No reviews yet

    Be one of the first to try it. Every listed skill goes through the trust checks below.

    Security scanned

    Checked by our 8-point scan before listing

    Fresh listing

    Recently published to Agensi

    Money-back guarantee

    Doesn't do what its page promises? You get your money back.

    Frequently Asked Questions

    Standard Spring audit logs often roll back along with the database transaction if an error occurs. This skill ensures your audit trails survive failures by using decoupled transaction boundaries, ensuring that every failed attempt is still recorded for security purposes.

    This skill is compatible with Java-based Spring Boot environments using Maven or Gradle. It works best with AI agents capable of repository-level code analysis and file modification, such as GitHub Copilot Workspace, Cursor, or specialized DevSecOps agents.

    The skill includes the `verify.py` diagnostic script, pre-configured Spring AOP aspects for audit wiring, PII masking templates, and a suite of verification tests to ensure the audit trail remains persistent during rollbacks.

    Yes, the skill is designed to identify and mask sensitive fields like SSNs and credit card numbers at the application layer. This ensures that PII is never written to your audit repository, helping you maintain compliance with SOC 2 and PCI DSS.

    While the core logic is based on Spring Boot best practices, the skill is updated quarterly to reflect new security patches in the Spring ecosystem and evolving compliance standards. Buyers receive all version updates released within one year of purchase.

    The skill currently supports Java-based Spring Boot applications using REST or message-driven architectures. It does not support Kotlin, GraphQL-specific resolvers, or legacy XML-based Spring configurations at this time.

    New in APIs & Backend

    Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for APIs & Backend.