Skip to content
rmnr
DocsTourSlicesBest PracticeAgentsInstall

Command Palette

Search for a command to run...

New

Slice · AI prompt

Audit Log — Workspace Events

Backend-only audit event recorder with framework-neutral TypeScript. createAuditLogger injects tenant/actor identity and preserves action/entity/diff/metadata/IP/user-agent evidence through host bindings; read-only query/export tools remain server-gated. React/Next stays the default contract while explicit Svelte/SvelteKit installs reuse the same source with no duplicate UI or framework runtime dependency.

Resource detail View source
Copy this prompt into Claude / Codex / Cursor
audit-log.prompt.mdmarkdown
# Install `audit-log` — Audit Log — Workspace Events

> Backend-only audit event recorder with framework-neutral TypeScript.

📚 Knowledge base : https://resource.rahmanef.com/llms.txt
📦 Slice detail   : https://resource.rahmanef.com/slices/audit-log
🧠 JSON catalog   : https://resource.rahmanef.com/api/knowledge?slice=audit-log
🔗 Source         : https://github.com/rahmanef63/resource-site/tree/main/frontend/slices/audit-log

## 1. Install

```bash
npx rahman-resources add audit-log
# alias: npx rr add audit-log
```

The CLI copies `frontend/slices/audit-log/` into your project + augments `.env.example` + installs npm deps automatically. Run it from your project root.

## 2. What it ships

- peer slices (cascade install):
  - `convex-auth` — Event actor resolved via authenticated user.
- convex feature paths: `convex/features/audit-log`

## 3. Wire it up

Run `npx rr add audit-log` (or `--framework sveltekit`; both copy the same framework-neutral source). Create a logger with `createAuditLogger(tenantAdapter, bindings)` and call it inside server-checked mutations/actions with `{ action, entityType, entityId, diff?, metadata?, ipAddress?, userAgent? }`. TenantAdapter resolves tenant + actor; the consumer binding enforces `audit.write`. Agent tools `audit-log.query` and `audit-log.export` are read-only and the supplied list binding must enforce `audit.read` server-side.

## Rules of engagement

- shadcn-only UI primitives. No raw `<button>` / `<dialog>` / native date or file inputs.
- 200-line hard cap per source file (extract neighbours when over).
- All Convex queries hit an index (`.withIndex(...)`); never bare `.collect()`.
- Public mutations/queries declare `args:` validators + authz.
- Full ruleset: https://resource.rahmanef.com/best-practice

The agent will fetch /llms.txt for the full ruleset and use /api/knowledge for the JSON catalog.