kilimcininkoroglu/cli-tweaks/audit-replay
Claude Code and agent skill by kilimcininkoroglu/cli-tweaks
- community
- ext:[{"type":"hook","description":"Pre/post lifecycle hooks"}]
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-replaySemi-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:
- 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.
- 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
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.
| Reference | Consult for | |
|---|---|---|
references/databases.md | Full schema + event-store queries for all 4 databases (PostgreSQL, MySQL, SQLite, MongoDB) and a per-DB delta table | |
references/languages.md | Per-language building blocks for all 8 languages (id-gen, cookie, fire-and-forget, error hook, middleware) | |
references/admin-ui.md | Complete 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:
| Language | Frameworks | Database (all 4 supported) | |
|---|---|---|---|
| Go | Echo, Gin, Chi, Fiber, net/http | PostgreSQL, MySQL, SQLite, MongoDB | |
| Node.js | Express, Fastify, Koa, Next.js | PostgreSQL, MySQL, SQLite, MongoDB | |
| Python | Flask, Django, FastAPI | PostgreSQL, MySQL, SQLite, MongoDB | |
| PHP | Laravel, Symfony, plain | MySQL, PostgreSQL, SQLite, MongoDB | |
| Ruby | Rails, Sinatra | PostgreSQL, MySQL, SQLite, MongoDB | |
| Java | Spring Boot, Quarkus, Micronaut | PostgreSQL, MySQL, SQLite, MongoDB | |
| C# | ASP.NET Core | PostgreSQL, MySQL, SQLite, MongoDB | |
| Rust | Axum, Actix, Rocket | PostgreSQL, 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:
- Session/cookie mechanism — existing session middleware, cookie library, auth system
- Database layer — ORM, query builder, raw SQL, migration system
- Admin panel — existing admin routes, templates, authentication
- Template engine — where to inject rrweb scripts
- 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:
| Property | Value | |
|---|---|---|
| Name | visitor_id | |
| Value | 32-char hex string (crypto/rand) | |
| Path | / | |
| Max-Age | 1 year (365 24 3600) | |
| HttpOnly | true | |
| SameSite | Lax | |
| Secure | true (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.
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):
| Operation | SQL | Description | |
|---|---|---|---|
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 $1 | Session list for admin | |
GetVisitorTimeline(visitorID) | SELECT * FROM audit_events WHERE visitor_id=$1 ORDER BY created_at ASC | Full 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 seq | Fetch and concatenate batches in order for playback | |
GetReplaySessions(visitorID) | SELECT id, page_url, started_at FROM replay_sessions WHERE visitor_id=$1 | List 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):
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 Type | When | Data to Record | |
|---|---|---|---|
page_view | Any page render | {path, referrer} | |
search | Search form submitted | {query, results_count} | |
view_item | Detail/product page opened | {item_id, item_name} | |
change_prefs | User changes settings | {setting_name, old_value, new_value} | |
form_submit | Any form submission | {form_name, success} | |
error | Error page shown | {error_code, error_message} | |
login | User logs in | {method} | |
click_action | Significant 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:
| Framework | Hook | |
|---|---|---|
| Go/Echo | e.HTTPErrorHandler custom wrapper | |
| Express | app.use((err, req, res, next) => ...) | |
| Django | Custom middleware process_exception | |
| FastAPI | @app.exception_handler(Exception) | |
| Laravel | App\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
- SKILL.md in the repositoryCheckingfactory/skills/audit-replay/SKILL.md
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
[](https://verified-skill.com/skills/kilimcininkoroglu/cli-tweaks/audit-replay)