streaming-export-safety

Enforces streaming APIs for large Excel, CSV, JSON, and PDF exports to prevent OOM failures.

1.0k|109|Updated Jan 4, 2026
One-click install
npx skills add https://github.com/doccker/cc-use-exp --skill streaming-export-safety
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: streaming-export-safety
Source: https://github.com/doccker/cc-use-exp/tree/main/.cursor/skills/streaming-export-safety
Command: npx skills add https://github.com/doccker/cc-use-exp --skill streaming-export-safety

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Large file exports built entirely in memory cause OOM crashes, Full GC storms, leftover temp files, and HTTP timeouts. This Skill detects risky export patterns in Java, Python, Go, and Node.js code and replaces them with streaming APIs and asynchronous task patterns.

Core Features & Use Cases

  • Streaming API Enforcement: Converts XSSFWorkbook, openpyxl, excelize, and ExcelJS in-memory writes into SXSSF, write_only, StreamWriter, and stream-based equivalents with correct flush/dispose handling.
  • Format-Specific Pitfall Detection: Covers Excel, CSV, JSON (including JSONL alternatives), and PDF export traps such as missing Flush() calls, non-streamable PDF libraries, and full-array JSON serialization.
  • Async Export Task Pattern: Replaces synchronous HTTP export endpoints with task-ID submission, background execution, object-storage upload, and status polling.
  • Use Case: When reviewing a Spring controller that builds a 100k-row Excel report in memory, the Skill rewrites it to use SXSSFWorkbook with windowed rows, proper dispose() in finally, and an async task returning a download URL.

Quick Start

Review my export code for memory safety and convert any in-memory Excel, CSV, JSON, or PDF generation over 10,000 rows to streaming APIs with async task handling.

Frequently Asked Questions about streaming-export-safety

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I export large Excel files in Java without OutOfMemoryError?

Use SXSSFWorkbook with a window size (e.g., 100 rows) instead of XSSFWorkbook, which keeps the entire sheet in memory. Enable temp-file compression, write to an OutputStream, and always call dispose() in a finally block to remove temporary files.

What is the difference between XSSFWorkbook and SXSSFWorkbook?

XSSFWorkbook loads the whole workbook into memory, while SXSSFWorkbook streams rows beyond a sliding window to temp files. SXSSF cannot randomly access flushed rows, does not support formula recalculation or cloneSheet, and requires dispose() to clean up.

How do I write large CSV files in Go without losing data?

Use encoding/csv with csv.NewWriter and write rows one at a time. You must call w.Flush() (commonly via defer) because the writer buffers data in memory; forgetting Flush leaves all rows unwritten to disk.

Does openpyxl support streaming writes for large Excel files?

Yes, create the workbook with Workbook(write_only=True) and append rows via ws.append(). In write-only mode you cannot use ws.cell() for random access or modify previously written rows.

Why does my export endpoint return 504 gateway timeout?

Synchronous exports taking over 30 seconds get cut off by Nginx or gateways and block HTTP threads. Convert the endpoint to submit an async task that returns a task ID immediately, generates the file in the background, uploads it to object storage, and exposes a status polling endpoint.

When should I use JSONL instead of a JSON array for exports?

Use JSONL when exporting very large datasets, since each line is an independent JSON object that downstream consumers can parse incrementally. Standard JSON arrays require reading the entire file before parsing, which reintroduces memory pressure.