Skip to main content

Type

file_generation

Formats

JSON, CSV, PDF, TXT, Markdown
Purpose: The File Generation skill enables agents to create formatted files from structured data, supporting various output formats for reports, exports, and documentation.

Common Use Cases

Creating reports and documentsGenerate PDF reports, executive summaries, and formatted documents

Exporting data to different formatsConvert data to CSV for spreadsheets, JSON for APIs

Generating configuration filesCreate YAML, JSON, or INI configuration files from templates

Template-based file creationUse Jinja2 or custom templates to generate dynamic content

Supported Formats

FormatUse CasesKey Features
JSONAPI exports, config filesPretty printing, schema validation, nested structures
CSVData exports, spreadsheetsCustom delimiters, headers, Excel compatibility
PDFReports, invoices, documentsCustom styling, images, multi-page support
Text/MarkdownDocumentation, READMEsMarkdown formatting, template substitution
Format Selection: Use CSV for data exports (fast, small), PDF for formatted reports (professional), JSON for API/config (structured).

Configuration

Example Configuration:
{
  "output_directory": "/opt/generated",
  "allowed_formats": ["json", "csv", "pdf", "txt"],
  "template_directory": "/opt/templates",
  "template_engine": "jinja2",
  "json_indent": 2
}
ParameterTypeDefaultDescription
output_directorystring”/“Where files are saved
allowed_formatsarray[“json”, “csv”, “txt”]Permitted file formats
template_directorystring”/templates”Template file location
template_enginestring”jinja2”Template engine to use
json_indentnumber2JSON pretty print indentation
csv_delimiterstring”,“CSV field separator
encodingstring”utf-8”File encoding
pdf_enginestring”reportlab”PDF generation library
pdf_page_sizestring”A4”Page size (A4, Letter, etc.)

Quick Start

# Create skill
kubiya skill create --name "Report Generator" --type file_generation --enabled

# Associate with agent
kubiya skill associate agent <agent-id> <skill-id>

View Complete Examples

See full template usage, PDF generation patterns, and multi-format export examples

Template Usage

Jinja2 Templates

Create reusable templates for consistent file generation: Template File (/opt/templates/report.md.j2):
# {{ report_title }}

**Generated:** {{ timestamp }}

## Summary

{% for metric in metrics %}
- **{{ metric.name }}:** {{ metric.value }}{{ metric.unit }}
{% endfor %}

---
*Report ID: {{ report_id }}*
Agent Usage:
data = {
    "report_title": "System Health Report",
    "timestamp": "2024-01-15 10:30:00",
    "metrics": [
        {"name": "CPU Usage", "value": 45, "unit": "%"},
        {"name": "Memory Usage", "value": 62, "unit": "%"}
    ],
    "report_id": "RPT-2024-001"
}

# Generate file from template
generate_file(template="report.md.j2", output="health-report.md", data=data)

Security Best Practices

Always specify output_directory to limit where files can be written.
output_directory: "/opt/generated"  # Files can only be saved here
Use allowed_formats to control which file types can be generated.
allowed_formats: ["json", "csv", "txt"]  # No executable formats
Sanitize data before passing to templates to prevent injection attacks.
from html import escape
data["user_input"] = escape(data["user_input"])
Performance Tip: For large data exports, use CSV instead of PDF for better performance and smaller file sizes.

Solutions:
  • Verify template_directory path is correct
  • Check template file exists: ls /opt/templates/
  • Ensure worker has read permissions on template directory
Solutions:
  • Install required PDF library: pip install reportlab or pip install weasyprint
  • Verify font files are available if using custom fonts
  • Check PDF engine configuration matches installed library
Solutions:
  • Verify output_directory exists: mkdir -p /opt/generated
  • Check worker user has write permissions
  • Ensure disk space is available: df -h