Claude Skill

br-audit-enrichment

Configure Better Route 1.1 audit events and safe enrichment. Use when logging route outcomes, authenticated identity, hashed idempotency keys, trusted client IPs, domain action metadata, or ensuring telemetry failures cannot change API behavior.

LLM Mart · 0 points · 0 views 0 listing impressions 0 install-command copies
Virus-scanned Reviewed automatically before listing.

Full trust report

Download lonsdale201-wp-agent-skills-better-route_br-audit-enrichment-52f6020.zip · 1 KB
Part of lonsdale201/wp-agent-skills — 226 skills

Install

skills CLI npx skills add https://github.com/Lonsdale201/wp-agent-skills/tree/main/better-route/br-audit-enrichment
Claude Code claude plugin marketplace add https://llmmart.ai/marketplace.json && claude plugin install lonsdale201-wp-agent-skills@llmmart
Git git clone https://github.com/Lonsdale201/wp-agent-skills.git

The skills CLI installs just this skill, for any of its supported agents. Claude Code installs the whole lonsdale201/wp-agent-skills collection as a plugin from our marketplace. Git is the plain clone.

Skill manifest

Better Route audit enrichment

Run authentication first, enrichment second, and audit logging around the downstream handler.

use BetterRoute\Middleware\Audit\AuditEnricherMiddleware;
use BetterRoute\Middleware\Audit\AuditMiddleware;

$router->middleware([
    $auth,
    new AuditEnricherMiddleware(
        staticFields: ['resource' => 'account', 'action' => 'update'],
        clientIpResolver: $trustedProxyResolver,
        includeClientIp: true
    ),
    new AuditMiddleware($logger),
]);

AuditEnricherMiddleware writes to the context audit attribute. It copies the normalized authentication provider, user ID, and subject; hashes an Idempotency-Key with SHA-1 for correlation; optionally resolves client IP; and merges reviewed static fields. Existing fields are retained, while later enrichment values with the same name win.

AuditMiddleware logs success or error with route, method, status, duration, correlation metadata, and enrichment. Logger exceptions are swallowed deliberately: observability is best-effort and must not change a successful response or mask the application exception already in flight.

Rules

  • Never include bearer tokens, cookies, nonces, application passwords, HMAC secrets/signatures, payment data, full bodies, or raw idempotency keys.
  • Treat SHA-1 here only as a non-secret correlation fingerprint, not as a security proof.
  • Use a trusted-proxy-aware resolver before recording or acting on forwarded client IPs.
  • Keep static values bounded and public-safe. Do not pass attacker-controlled payload arrays as static fields.
  • Protect the log sink with access control, retention limits, rotation, and output escaping in viewers.
  • Alert separately when the logging backend is unavailable; the request path intentionally will not fail.

Test successful responses, ApiException, unexpected exceptions, logger failure, missing authentication context, and spoofed forwarded headers.

Source references: src/Middleware/Audit/AuditEnricherMiddleware.php, src/Middleware/Audit/AuditMiddleware.php, src/Observability/AuditEventFactory.php.

References

Files (wp-agent-skills)
  • agents
    • openai.yaml 219 B
      interface:
        display_name: "Better Route Audit Enrichment"
        short_description: "Enrich better-route audit events safely."
        default_prompt: "Use better-route audit enrichment middleware for sensitive REST operations."
      
  • SKILL.md 2.7 KB
    ---
    name: br-audit-enrichment
    description: Configure Better Route 1.1 audit events and safe enrichment. Use when logging route outcomes, authenticated identity, hashed idempotency keys, trusted client IPs, domain action metadata, or ensuring telemetry failures cannot change API behavior.
    metadata:
      wp-skills-author: "Soczó Kristóf"
      wp-skills-contact: "mailto:lonsdale201@hotmail.com"
      wp-skills-plugin: "better-route"
      wp-skills-plugin-version-tested: "1.1.0"
      wp-skills-php-min: "8.1"
      wp-skills-last-updated: "2026-07-13"
    ---
    
    # Better Route audit enrichment
    
    Run authentication first, enrichment second, and audit logging around the downstream handler.
    
    ```php
    use BetterRoute\Middleware\Audit\AuditEnricherMiddleware;
    use BetterRoute\Middleware\Audit\AuditMiddleware;
    
    $router->middleware([
        $auth,
        new AuditEnricherMiddleware(
            staticFields: ['resource' => 'account', 'action' => 'update'],
            clientIpResolver: $trustedProxyResolver,
            includeClientIp: true
        ),
        new AuditMiddleware($logger),
    ]);
    ```
    
    `AuditEnricherMiddleware` writes to the context `audit` attribute. It copies the normalized authentication provider, user ID, and subject; hashes an `Idempotency-Key` with SHA-1 for correlation; optionally resolves client IP; and merges reviewed static fields. Existing fields are retained, while later enrichment values with the same name win.
    
    `AuditMiddleware` logs success or error with route, method, status, duration, correlation metadata, and enrichment. Logger exceptions are swallowed deliberately: observability is best-effort and must not change a successful response or mask the application exception already in flight.
    
    ## Rules
    
    - Never include bearer tokens, cookies, nonces, application passwords, HMAC secrets/signatures, payment data, full bodies, or raw idempotency keys.
    - Treat SHA-1 here only as a non-secret correlation fingerprint, not as a security proof.
    - Use a trusted-proxy-aware resolver before recording or acting on forwarded client IPs.
    - Keep static values bounded and public-safe. Do not pass attacker-controlled payload arrays as static fields.
    - Protect the log sink with access control, retention limits, rotation, and output escaping in viewers.
    - Alert separately when the logging backend is unavailable; the request path intentionally will not fail.
    
    Test successful responses, `ApiException`, unexpected exceptions, logger failure, missing authentication context, and spoofed forwarded headers.
    
    Source references: `src/Middleware/Audit/AuditEnricherMiddleware.php`, `src/Middleware/Audit/AuditMiddleware.php`, `src/Observability/AuditEventFactory.php`.
    
    ## References
    
    - Official documentation: <https://lonsdale201.github.io/better-docs/docs/better-route/agents>
    

Comments (0)

Sign in to join the conversation.

No comments yet.

Reviews (0)

No reviews yet.

Related