langfuse-data-handling
Manage Langfuse data export, retention, and compliance requirements. Use when exporting trace data, configuring retention policies, or implementing data compliance for LLM observability. Trigger with phrases like "langfuse data export", "langfuse retention", "langfuse GDPR", "langfuse compliance", "export langfuse traces".
Best use case
langfuse-data-handling is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Manage Langfuse data export, retention, and compliance requirements. Use when exporting trace data, configuring retention policies, or implementing data compliance for LLM observability. Trigger with phrases like "langfuse data export", "langfuse retention", "langfuse GDPR", "langfuse compliance", "export langfuse traces".
Teams using langfuse-data-handling should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/langfuse-data-handling/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How langfuse-data-handling Compares
| Feature / Agent | langfuse-data-handling | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Manage Langfuse data export, retention, and compliance requirements. Use when exporting trace data, configuring retention policies, or implementing data compliance for LLM observability. Trigger with phrases like "langfuse data export", "langfuse retention", "langfuse GDPR", "langfuse compliance", "export langfuse traces".
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
Related Guides
AI Agents for Coding
Browse AI agent skills for coding, debugging, testing, refactoring, code review, and developer workflows across Claude, Cursor, and Codex.
Best AI Skills for Claude
Explore the best AI skills for Claude and Claude Code across coding, research, workflow automation, documentation, and agent operations.
ChatGPT vs Claude for Agent Skills
Compare ChatGPT and Claude for AI agent skills across coding, writing, research, and reusable workflow execution.
SKILL.md Source
# Langfuse Data Handling
## Overview
Manage the Langfuse data lifecycle: export traces and scores via the API, configure retention policies, handle GDPR data subject requests, anonymize data for analytics, and maintain audit trails.
## Prerequisites
- `@langfuse/client` installed
- Langfuse API keys with appropriate permissions
- Understanding of your compliance requirements (GDPR, SOC2, HIPAA)
## Instructions
### Step 1: Export Trace Data via API
```typescript
import { LangfuseClient } from "@langfuse/client";
import { writeFileSync } from "fs";
const langfuse = new LangfuseClient();
async function exportTraces(options: {
fromDate: string;
toDate: string;
outputFile: string;
includeObservations?: boolean;
}) {
const allTraces: any[] = [];
let page = 1;
let hasMore = true;
while (hasMore) {
const result = await langfuse.api.traces.list({
fromTimestamp: options.fromDate,
toTimestamp: options.toDate,
limit: 100,
page,
});
for (const trace of result.data) {
const exportItem: any = {
id: trace.id,
name: trace.name,
timestamp: trace.timestamp,
userId: trace.userId,
sessionId: trace.sessionId,
metadata: trace.metadata,
tags: trace.tags,
};
if (options.includeObservations) {
const observations = await langfuse.api.observations.list({
traceId: trace.id,
});
exportItem.observations = observations.data;
}
allTraces.push(exportItem);
}
hasMore = result.data.length === 100;
page++;
// Rate limit respect
await new Promise((r) => setTimeout(r, 200));
}
writeFileSync(options.outputFile, JSON.stringify(allTraces, null, 2));
console.log(`Exported ${allTraces.length} traces to ${options.outputFile}`);
}
// Usage
await exportTraces({
fromDate: "2025-01-01T00:00:00Z",
toDate: "2025-01-31T23:59:59Z",
outputFile: "traces-january.json",
includeObservations: true,
});
```
### Step 2: Export Scores
```typescript
async function exportScores(fromDate: string, outputFile: string) {
const scores: any[] = [];
let page = 1;
let hasMore = true;
while (hasMore) {
const result = await langfuse.api.scores.list({
fromTimestamp: fromDate,
limit: 100,
page,
});
scores.push(...result.data);
hasMore = result.data.length === 100;
page++;
await new Promise((r) => setTimeout(r, 200));
}
writeFileSync(outputFile, JSON.stringify(scores, null, 2));
console.log(`Exported ${scores.length} scores to ${outputFile}`);
}
```
### Step 3: Data Retention Configuration
**Self-hosted: Set retention via environment variable:**
```yaml
# docker-compose.yml
services:
langfuse:
environment:
- LANGFUSE_RETENTION_DAYS=90
```
**Cloud: Programmatic cleanup of old data:**
```typescript
async function enforceRetention(maxAgeDays: number) {
const cutoff = new Date(Date.now() - maxAgeDays * 86400000).toISOString();
const oldTraces = await langfuse.api.traces.list({
toTimestamp: cutoff,
limit: 100,
});
console.log(`Found ${oldTraces.data.length} traces older than ${maxAgeDays} days`);
for (const trace of oldTraces.data) {
await langfuse.api.traces.delete(trace.id);
await new Promise((r) => setTimeout(r, 100)); // Rate limit
}
}
// Run as cron job
await enforceRetention(90);
```
### Step 4: GDPR Data Subject Requests
```typescript
// Handle "Right to Access" -- export all data for a user
async function handleAccessRequest(userId: string) {
const traces = await langfuse.api.traces.list({
userId,
limit: 1000,
});
const userData = {
userId,
exportDate: new Date().toISOString(),
traceCount: traces.data.length,
traces: traces.data.map((t) => ({
id: t.id,
name: t.name,
timestamp: t.timestamp,
input: t.input,
output: t.output,
metadata: t.metadata,
})),
};
writeFileSync(`gdpr-export-${userId}.json`, JSON.stringify(userData, null, 2));
return userData;
}
// Handle "Right to Erasure" -- delete all data for a user
async function handleDeletionRequest(userId: string) {
const traces = await langfuse.api.traces.list({
userId,
limit: 1000,
});
let deleted = 0;
for (const trace of traces.data) {
await langfuse.api.traces.delete(trace.id);
deleted++;
await new Promise((r) => setTimeout(r, 100));
}
console.log(`Deleted ${deleted} traces for user ${userId}`);
return { userId, tracesDeleted: deleted };
}
```
### Step 5: Data Anonymization for Analytics
```typescript
import crypto from "crypto";
function anonymizeTrace(trace: any): any {
return {
...trace,
userId: trace.userId ? crypto.createHash("sha256").update(trace.userId).digest("hex").slice(0, 16) : null,
sessionId: trace.sessionId ? crypto.createHash("sha256").update(trace.sessionId).digest("hex").slice(0, 16) : null,
input: "[REDACTED]",
output: "[REDACTED]",
metadata: {
model: trace.metadata?.model,
// Keep operational fields, remove PII
},
};
}
async function exportAnonymized(fromDate: string, outputFile: string) {
const traces = await langfuse.api.traces.list({
fromTimestamp: fromDate,
limit: 1000,
});
const anonymized = traces.data.map(anonymizeTrace);
writeFileSync(outputFile, JSON.stringify(anonymized, null, 2));
}
```
## Data Categories and Retention
| Category | Contains PII? | Default Retention | Compliance Note |
|----------|--------------|-------------------|-----------------|
| Traces (inputs/outputs) | Likely | 90 days | Scrub PII before tracing |
| Generations (LLM I/O) | Likely | 90 days | May contain user data |
| Scores | Rarely | 1 year | Typically safe to retain |
| Sessions | User ID linked | 90 days | Link to user data requests |
| Prompts | No | Indefinite | Template data only |
| Datasets | Maybe | Per use case | Review test data for PII |
## Error Handling
| Issue | Cause | Solution |
|-------|-------|----------|
| Export timeout | Too many traces | Reduce date range, use pagination |
| Missing user data | Different userId format | Verify exact userId used in traces |
| Deletion not immediate | Async processing | Allow time for propagation |
| Rate limited during export | Too many API calls | Add 200ms delay between pages |
## Resources
- [Langfuse Data Security](https://langfuse.com/docs/data-security-privacy)
- [Public API Reference](https://langfuse.com/docs/api)
- [API Reference (OpenAPI)](https://api.reference.langfuse.com/)
- [Self-Hosting Configuration](https://langfuse.com/self-hosting/configuration)Related Skills
generating-test-data
Generate realistic test data including edge cases and boundary conditions. Use when creating realistic fixtures or edge case test data. Trigger with phrases like "generate test data", "create fixtures", or "setup test database".
managing-database-tests
Test database testing including fixtures, transactions, and rollback management. Use when performing specialized testing. Trigger with phrases like "test the database", "run database tests", or "validate data integrity".
encrypting-and-decrypting-data
Validate encryption implementations and cryptographic practices. Use when reviewing data security measures. Trigger with 'check encryption', 'validate crypto', or 'review security keys'.
scanning-for-data-privacy-issues
Scan for data privacy issues and sensitive information exposure. Use when reviewing data handling practices. Trigger with 'scan privacy issues', 'check sensitive data', or 'validate data protection'.
windsurf-data-handling
Control what code and data Windsurf AI can access and process in your workspace. Use when handling sensitive data, implementing data exclusion patterns, or ensuring compliance with privacy regulations in Windsurf environments. Trigger with phrases like "windsurf data privacy", "windsurf PII", "windsurf GDPR", "windsurf compliance", "codeium data", "windsurf telemetry".
webflow-data-handling
Implement Webflow data handling — CMS content delivery patterns, PII redaction in form submissions, GDPR/CCPA compliance for ecommerce data, and data retention policies. Trigger with phrases like "webflow data", "webflow PII", "webflow GDPR", "webflow data retention", "webflow privacy", "webflow CCPA", "webflow forms data".
vercel-data-handling
Implement data handling, PII protection, and GDPR/CCPA compliance for Vercel deployments. Use when handling sensitive data in serverless functions, implementing data redaction, or ensuring privacy compliance on Vercel. Trigger with phrases like "vercel data", "vercel PII", "vercel GDPR", "vercel data retention", "vercel privacy", "vercel compliance".
veeva-data-handling
Veeva Vault data handling for enterprise operations. Use when implementing advanced Veeva Vault patterns. Trigger: "veeva data handling".
vastai-data-handling
Manage training data and model artifacts securely on Vast.ai GPU instances. Use when transferring data to instances, managing checkpoints, or implementing secure data lifecycle on rented hardware. Trigger with phrases like "vastai data", "vastai upload data", "vastai checkpoints", "vastai data security", "vastai artifacts".
twinmind-data-handling
Handle TwinMind meeting data with GDPR compliance: transcript storage, memory vault management, data export, and deletion policies. Use when implementing data handling, or managing TwinMind meeting AI operations. Trigger with phrases like "twinmind data handling", "twinmind data handling".
supabase-data-handling
Implement GDPR/CCPA compliance with Supabase: RLS for data isolation, user deletion via auth.admin.deleteUser(), data export via SQL, PII column management, backup/restore workflows, and retention policies. Use when handling sensitive data, implementing right-to-deletion, configuring data retention, or auditing PII in Supabase database columns. Trigger: "supabase GDPR", "supabase data handling", "supabase PII", "supabase compliance", "supabase data retention", "supabase delete user", "supabase data export".
speak-data-handling
Handle student audio data, assessment records, and learning progress with GDPR/COPPA compliance. Use when implementing data handling, or managing Speak language learning platform operations. Trigger with phrases like "speak data handling", "speak data handling".