Stream structured content to persistent SQLite storage with automatic session break recovery. Core principle: The content IS the state. Every stream_write is automatically persistent...
Agent instructions for using the streaming-output MCP to produce persistent, recoverable output.
This skill enables you to stream structured content to persistent SQLite storage with automatic session break recovery. Use it when producing reports, analysis results, task lists, or any structured output that needs to survive session interruptions.
Core Principle: The content IS the state. Every stream_write is automatically persistent.
Version 2.0 Features:
CRITICAL: Always follow this protocol at the start of any streaming task.
IF you have a document_id (from previous session or user):
1. Call stream_status(document_id) FIRST
2. Check for resume_from field
3. If preserved_context exists, READ IT and CONTINUE from that point
4. Do NOT restart blocks from scratch
IF you don't have a document_id:
1. Call stream_start() to create new document
2. Optionally use a template for structure
3. Begin writing blocks in sequence
Session breaks happen. When they do:
preserved_contextUse templates for common document types with pre-defined structure:
| Template | Use Case | Pre-declared Blocks |
|---|---|---|
security-audit |
Security assessments | executive_summary, scope, findings, recommendations |
code-review |
PR/code reviews | summary, critical_issues, suggestions, approval_status |
sprint-retrospective |
Sprint retros | what_went_well, improvements, action_items |
technical-spec |
Technical specs | overview, requirements, architecture, implementation_plan |
adr |
Architecture decisions | context, decision, consequences, alternatives |
research-report |
Research docs | abstract, methodology, findings, conclusions |
task-list |
Task tracking | No pre-declared blocks (dynamic) |
To use a template:
{
"title": "Q4 Security Audit",
"template": "security-audit"
}
List available templates:
stream_templates({})
Initialize a new document.
// Minimal
{"title": "Code Review Report"}
// With template
{
"title": "Security Assessment",
"template": "security-audit"
}
// Custom structure
{
"title": "Custom Report",
"schema_type": "report",
"blocks": [
{"key": "summary", "type": "section"},
{"key": "findings", "type": "finding"}
]
}
Write content to a block. Each write is atomic and SHA-256 verified.
{
"document_id": "doc_...",
"block_key": "summary",
"content": {
"title": "Executive Summary",
"body": "This audit identified 3 critical vulnerabilities..."
},
"block_type": "section"
}
Block Types:
| Type | When to Use | Required Fields |
|---|---|---|
section |
Narrative content | title, body |
task |
Actionable items | id, title, status |
finding |
Analysis results | id, severity, description |
decision |
ADR-style decisions | id, title, decision, rationale |
raw |
Arbitrary JSON | content |
Content Schemas:
// section
{"title": "...", "body": "..."}
// task
{"id": "T-001", "title": "...", "status": "pending|in_progress|complete", "assignee": "...", "notes": "..."}
// finding
{"id": "F-001", "severity": "critical|high|medium|low|info", "description": "...", "evidence": "...", "recommendation": "..."}
// decision
{"id": "ADR-001", "title": "...", "context": "...", "decision": "...", "rationale": "...", "alternatives": [...]}
Check document state. Always call after session breaks.
// List recent documents
{}
// Check specific document with verification
{"document_id": "doc_...", "verify": true}
Response Fields:
{
"resume_from": "findings", // ← Start here
"preserved_context": {
"block_key": "findings",
"partial_content": "Found 3 SQL injection..."
},
"summary": {
"total": 5,
"complete": 2,
"pending": 3
}
}
Read document content in various formats.
// As JSON
{"document_id": "doc_...", "format": "json"}
// As Markdown
{"document_id": "doc_...", "format": "markdown"}
// Specific blocks
{"document_id": "doc_...", "format": "markdown", "blocks": ["summary", "recommendations"]}
Export document to a file.
{
"document_id": "doc_...",
"format": "html",
"output_path": "~/Documents/report.html"
}
Supported Formats:
markdown - Clean Markdown with headershtml - Styled HTML with embedded CSSjson - Full structured datatext - Plain text without formattingyaml - YAML representationcsv - Tabular format (best for tasks/findings)Mark document as complete after all blocks are written.
{"document_id": "doc_..."}
Returns verification of completion status.
Delete a document and all its blocks.
{"document_id": "doc_..."}
List available document templates.
{} // Returns all 7 templates with their structure
1. Call stream_status(document_id)
2. Response: resume_from: "analysis", preserved_context: "The security analysis..."
3. Action: Read preserved_context, CONTINUE from that point
4. Call stream_write("analysis", {complete_content}, repair=true)
1. Call stream_status(document_id)
2. Response: resume_from: "analysis", no preserved_context
3. Action: Check complete blocks, re-analyze source, write fresh
User: "Continue the security report from yesterday"
1. stream_status() - list recent documents
2. Identify by title/date
3. stream_status(document_id) - get details
4. Follow resume_from to continue
DO NOT:
repair=true when continuing interrupted blocks1. stream_start(title="Q4 Security Audit", template="security-audit")
→ Creates doc with: executive_summary, scope, findings, recommendations
2. stream_write(doc_xxx, "executive_summary", {title: "...", body: "..."})
3. stream_write(doc_xxx, "scope", {title: "...", body: "..."})
4. stream_write(doc_xxx, "findings", {severity: "critical", ...})
5. stream_write(doc_xxx, "recommendations", {title: "...", body: "..."})
6. stream_finalize(doc_xxx)
→ Document finalized
7. stream_export(doc_xxx, format="html", output_path="~/reports/q4-audit.html")
→ Exported to file
User: "Continue the security report"
1. stream_status()
→ Lists recent docs, find "Security Audit"
2. stream_status("doc_xxx")
→ resume_from: "findings", preserved_context: {partial: "Scanned 45/120..."}
3. Read preserved_context, note endpoint 45
4. Continue from endpoint 46
5. stream_write(doc_xxx, "findings", {complete}, repair=true)
1. Complete document with stream_write calls
2. stream_read(doc_xxx, format="markdown")
→ Preview in chat
3. stream_export(doc_xxx, format="html", output_path="~/report.html")
→ HTML file for sharing
4. stream_export(doc_xxx, format="json", output_path="~/backup.json")
→ JSON backup for archival
| Command | Purpose |
|---|---|
/stream-init |
Initialize a new document |
/stream-status |
Check document status and resume point |
/stream-read |
Read document content |
/stream-write |
Write content to a block |
/stream-export |
Export document to file |
Documents are stored in: ~/.claude/streaming-output/streams.db
This SQLite database persists across sessions.
# Document Title
*Status: finalized | Created: 2026-01-14*
## Executive Summary
Content here...
## Findings
- **[CRITICAL]** Finding 1
- **[HIGH]** Finding 2
Styled HTML with:
block_key,type,title,severity,status
finding_1,finding,SQL Injection,critical,
task_1,task,Fix auth,in_progress,