kilimcininkoroglu/cli-tweaks/audit-replay

Claude Code and agent skill by kilimcininkoroglu/cli-tweaks

Trust tier 2
  • community
  • ext:[{"type":"hook","description":"Pre/post lifecycle hooks"}]
LLM review pending
Source check pending

Checking that the SKILL.md file is still in the repository.

Adds user action tracking and visual session replay to a web project: a backend audit event log with a per-visitor admin timeline, and rrweb DOM recording replayed as video. Both systems share a `visitor_id` cookie. Covers 8 languages and 4 databases.

Install

npx vskill@latest install kilimcininkoroglu/cli-tweaks/audit-replay

Semi-extensibleMentions customization, but needs skill-specific knowledge. Read the extensible skills standard

SKILL.md

The same SKILL.md was published earlier as kilimcininkoroglu/cli-tweaks/audit-replay.

Audit Log + Session Replay

Add user action tracking and visual session replay to any web project. Two systems working together:

  1. Audit Event Log — Backend event sourcing. Every user action (search, page view, form submit, preference change) recorded as a timestamped event in the database. Admin panel shows per-visitor timeline.
  2. Session Replay — Frontend DOM recording via rrweb. Mouse movements, clicks, scrolls, and page mutations captured and replayed as video in admin panel.

Both systems share a visitor_id cookie for correlation.

Usage

/audit-replay # Full setup: scan project, add both systems
/audit-replay scan # Scan only — show what would change
/audit-replay events-only # Add only audit event log (no rrweb)
/audit-replay replay-only # Add only session replay (assumes events exist)

References

This skill carries detailed references. Consult the relevant file before implementing that part — they hold the full per-stack detail kept out of the flow below, so the runtime only loads what the target project needs.

ReferenceConsult for
references/databases.mdFull schema + event-store queries for all 4 databases (PostgreSQL, MySQL, SQLite, MongoDB) and a per-DB delta table
references/languages.mdPer-language building blocks for all 8 languages (id-gen, cookie, fire-and-forget, error hook, middleware)
references/admin-ui.mdComplete admin-panel spec (filters, search, pagination, security) + end-user consent/opt-out UI

How It Works

Phase 1: Project Detection

Detect the project's language, framework, database, and admin panel:

LanguageFrameworksDatabase (all 4 supported)
GoEcho, Gin, Chi, Fiber, net/httpPostgreSQL, MySQL, SQLite, MongoDB
Node.jsExpress, Fastify, Koa, Next.jsPostgreSQL, MySQL, SQLite, MongoDB
PythonFlask, Django, FastAPIPostgreSQL, MySQL, SQLite, MongoDB
PHPLaravel, Symfony, plainMySQL, PostgreSQL, SQLite, MongoDB
RubyRails, SinatraPostgreSQL, MySQL, SQLite, MongoDB
JavaSpring Boot, Quarkus, MicronautPostgreSQL, MySQL, SQLite, MongoDB
C#ASP.NET CorePostgreSQL, MySQL, SQLite, MongoDB
RustAxum, Actix, RocketPostgreSQL, MySQL, SQLite, MongoDB

All eight languages and all four databases are fully supported — pull the matching block from references/languages.md and references/databases.md. The pattern is the same regardless of stack; only the API names and SQL dialect change.

Identify:

  1. Session/cookie mechanism — existing session middleware, cookie library, auth system
  2. Database layer — ORM, query builder, raw SQL, migration system
  3. Admin panel — existing admin routes, templates, authentication
  4. Template engine — where to inject rrweb scripts
  5. Static file serving — where to place rrweb JS files
Phase 2: Visitor ID

Every visitor gets a persistent anonymous ID via cookie. Implementation depends on framework:

Cookie specification:

PropertyValue
Namevisitor_id
Value32-char hex string (crypto/rand)
Path/
Max-Age1 year (365 24 3600)
HttpOnlytrue
SameSiteLax
Securetrue (production) / false (localhost)

ID generation — use the language's crypto-secure random, not UUIDs. Examples: Node.js crypto.randomBytes(16).toString('hex'), Python secrets.token_hex(16), Go hex.EncodeToString of 16 crypto/rand bytes. The generator and cookie-set call for all 8 languages are in references/languages.md.

Injection point — add to the existing session/preference/auth middleware. If none exists, create a minimal middleware that reads/writes the cookie on every request. See references/languages.md for the per-framework middleware injection point.

Phase 3: Database Schema

Create three tables (audit_events, replay_sessions, replay_events). The schema below is PostgreSQL (canonical); full DDL for MySQL, SQLite, and MongoDB plus a per-database delta table is in references/databases.md. Use the project's migration system if one exists; otherwise create a standalone SQL file.

sql
-- Audit events: one row per user action
CREATE TABLE IF NOT EXISTS audit_events (
id BIGSERIAL PRIMARY KEY,
visitor_id TEXT NOT NULL,
event_type TEXT NOT NULL,
event_data JSONB NOT NULL DEFAULT '{}',
path TEXT NOT NULL DEFAULT '',
created_at TIMESTAMPTZ NOT NULL DEFAULT now()
);
CREATE INDEX IF NOT EXISTS idx_audit_visitor ON audit_events(visitor_id, created_at DESC);
CREATE INDEX IF NOT EXISTS idx_audit_created ON audit_events(created_at DESC);
-- Replay sessions: one row per recording session (metadata only)
CREATE TABLE IF NOT EXISTS replay_sessions (
id BIGSERIAL PRIMARY KEY,
visitor_id TEXT NOT NULL,
page_url TEXT NOT NULL DEFAULT '',
started_at TIMESTAMPTZ NOT NULL DEFAULT now(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT now()
);
-- Replay events: append-only batches (never rewrite one growing JSONB array)
CREATE TABLE IF NOT EXISTS replay_events (
id BIGSERIAL PRIMARY KEY,
session_id BIGINT NOT NULL REFERENCES replay_sessions(id),
seq INTEGER NOT NULL,
batch JSONB NOT NULL,
created_at TIMESTAMPTZ NOT NULL DEFAULT now()
);
CREATE INDEX IF NOT EXISTS idx_replay_visitor ON replay_sessions(visitor_id, started_at DESC);
CREATE INDEX IF NOT EXISTS idx_replay_events_session ON replay_events(session_id, seq);

Other databases (quick deltas): MySQL JSON / BIGINT AUTO_INCREMENT / DATETIME; SQLite TEXT (JSON as text) / INTEGER PRIMARY KEY AUTOINCREMENT; MongoDB three collections with the same fields. The append-only replay_events design makes the replay path identical across all SQL databases (no JSON-array-append operator needed). Full DDL + the per-DB delta table (placeholder, JSON type, autoincrement, timestamp, interval, JSON-read syntax) is in `references/databases.md`.

Phase 4: Event Store Layer

Create a data access layer with these operations (SQL shown canonical PostgreSQL — per-database syntax in references/databases.md, per-language fire-and-forget in references/languages.md):

OperationSQLDescription
LogEvent(visitorID, eventType, path, data)INSERT INTO audit_events ...Fire-and-forget, errors discarded
GetRecentSessions(limit)SELECT visitor_id, COUNT(*), MIN(created_at), MAX(created_at) FROM audit_events GROUP BY visitor_id ORDER BY MAX(created_at) DESC LIMIT $1Session list for admin
GetVisitorTimeline(visitorID)SELECT * FROM audit_events WHERE visitor_id=$1 ORDER BY created_at ASCFull event timeline
SaveReplayEvents(visitorID, sessionID, seq, events, url)INSERT INTO replay_events (create the replay_sessions row on the first batch)Append one batch — see note below
GetReplaySession(id)SELECT batch FROM replay_events WHERE session_id=$1 ORDER BY seqFetch and concatenate batches in order for playback
GetReplaySessions(visitorID)SELECT id, page_url, started_at FROM replay_sessions WHERE visitor_id=$1List replays for a visitor
CleanupOldEvents(retentionDays)DELETE FROM audit_events WHERE created_at < now() - interval ...Retention cleanup

SaveReplayEvents — append-only batches: Each batch is a NEW row in replay_events (INSERT (session_id, seq, batch)), never an append into one growing array. A single appended JSONB array forces every write to rewrite the whole TOAST-ed value (≈O(n²) writes, rows ballooning to MBs); separate rows keep each write O(1) and behave identically on PostgreSQL, MySQL, and SQLite — no DB-specific JSON-merge operator required. For MongoDB, insert each batch as its own document. On playback, read batches ordered by seq and concatenate them.

Orphan session handling: If sendBeacon fires before the first batch response (sessionId is null), a new session is created. This may produce duplicate sessions for the same page visit. Acceptable trade-off — replay player can show both.

LogEvent pattern — fire-and-forget. Never block the request. Discard errors. Do NOT reuse the request context in the detached task — it is cancelled when the handler returns and can kill the insert mid-flight (silent event loss):

go
// Go — fresh context, NOT the request ctx (which is cancelled on handler return)
go func() {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
s.pool.Exec(ctx, "INSERT INTO ...", args...)
}()
// Node.js — rejection intentionally swallowed
db.query("INSERT INTO ...", args).catch(() => {});
// Python — keep a reference so the task isn't garbage-collected; needs a running loop
task = asyncio.create_task(db.execute("INSERT INTO ...", args))
_bg_tasks.add(task); task.add_done_callback(_bg_tasks.discard)

The fire-and-forget pattern for all 8 languages (incl. Java CompletableFuture, C# Task.Run, Rust tokio::spawn) is in references/languages.md.

Phase 5: Event Recording Points

Identify user-facing handlers and add LogEvent calls. Common event types:

Event TypeWhenData to Record
page_viewAny page render{path, referrer}
searchSearch form submitted{query, results_count}
view_itemDetail/product page opened{item_id, item_name}
change_prefsUser changes settings{setting_name, old_value, new_value}
form_submitAny form submission{form_name, success}
errorError page shown{error_code, error_message}
loginUser logs in{method}
click_actionSignificant button clicks{action, target}

SPA note: In single-page apps, server-side handlers only see the initial document load — all in-app navigation happens client-side. Emit page_view from the client on each route change (reuse the History API hook from Phase 6) and POST it to a lightweight /api/event endpoint, or the audit log misses every in-app navigation.

Error event capture: Hook into the framework's error handler to log error events automatically:

FrameworkHook
Go/Echoe.HTTPErrorHandler custom wrapper
Expressapp.use((err, req, res, next) => ...)
DjangoCustom middleware process_exception
FastAPI@app.exception_handler(Exception)
LaravelApp\Exceptions\Handler::report()

Error hooks and middleware injection points for all 8 languages (incl. Rails, Spring, ASP.NET Core, Axum) are in references/languages.md.

Rules:

  • Never log sensitive data (passwords, tokens, PII)
  • Keep event_data small (< 1KB per event)
  • Use consistent event_type naming (snake_case)
  • Always include the request path
Phase 6: rrweb Recording (Frontend)

Download rrweb and create a recorder script:

Files to add:

This is the start of the file. Read the full SKILL.md on GitHub.

Security

  • Security scanPassed, 100 of 100Pattern checks on the skill's files.
  • Model reviewNot runA model review is scheduled for the next rescan.

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

Repository stars
7
7-day trend score
10

Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 16 May 2026, 6 months ago.

Extension points

  • hookPre/post lifecycle hooks

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/kilimcininkoroglu/cli-tweaks/audit-replay/badge)](https://verified-skill.com/skills/kilimcininkoroglu/cli-tweaks/audit-replay)

Something wrong with this skill or its page? Tell us.