AGENT SKILL

data-export

Export App data from the browser as CSV or JSON downloads, clipboard copies, or print-friendly views. Use when the user wants a download or export button, to copy data, or a printable page. Word, Excel, PowerPoint and PDF deliverables are `document-generation`.

License 许可
AGPL-3.0
最近更新
2026-11-05
Stars
★ 43
Forks
9

01 前言 Front Matter

name
data-export
description
Export App data from the browser as CSV or JSON downloads, clipboard copies, or print-friendly views. Use when the user wants a download or export button, to copy data, or a printable page. Word, Excel, PowerPoint and PDF deliverables are `document-generation`.

03 SKILL.md 正文

Data Export — CSV, JSON, Print

No additional packages required. Uses built-in browser APIs.

CSV export (most common)

function exportToCSV(data: Record<string, unknown>[], filename: string) {
  if (data.length === 0) return

  const headers = Object.keys(data[0])
  const csvRows = [
    headers.join(","),
    ...data.map(row =>
      headers.map(h => {
        const val = String(row[h] ?? "")
        return val.includes(",") || val.includes('"') || val.includes("\n")
          ? `"${val.replace(/"/g, '""')}"`
          : val
      }).join(",")
    ),
  ]

  const blob = new Blob([csvRows.join("\n")], { type: "text/csv" })
  const url = URL.createObjectURL(blob)
  const a = document.createElement("a")
  a.href = url
  a.download = `${filename}.csv`
  a.click()
  URL.revokeObjectURL(url)
}

// Usage
<Button variant="outline" onClick={() => exportToCSV(data, "tasks-export")}>
  <Download className="h-4 w-4 mr-1" /> Export CSV
</Button>

JSON export

function exportToJSON(data: unknown, filename: string) {
  const blob = new Blob([JSON.stringify(data, null, 2)], { type: "application/json" })
  const url = URL.createObjectURL(blob)
  const a = document.createElement("a")
  a.href = url
  a.download = `${filename}.json`
  a.click()
  URL.revokeObjectURL(url)
}

Backend CSV endpoint (for large datasets)

Generate CSV on the server for datasets too large to hold in browser memory:

// backend controller
@Get("export")
exportCSV(@Res() res: Response) {
  const items = this.itemsService.findAll()
  const headers = ["id", "title", "status", "created_at"]
  const csvRows = [
    headers.join(","),
    ...items.map(item =>
      headers.map(h => {
        const val = String(item[h] ?? "")
        return val.includes(",") || val.includes('"') || val.includes("\n")
          ? `"${val.replace(/"/g, '""')}"`
          : val
      }).join(",")
    ),
  ]

  res.setHeader("Content-Type", "text/csv")
  res.setHeader("Content-Disposition", "attachment; filename=export.csv")
  res.send(csvRows.join("\n"))
}
// Frontend — download link
<a href="/api/items/export" download className="inline-flex items-center gap-1 text-sm text-primary hover:underline">
  <Download className="h-4 w-4" /> Download CSV
</a>

Print-friendly view

function PrintButton() {
  return <Button variant="outline" onClick={() => window.print()}>
    <Printer className="h-4 w-4 mr-1" /> Print
  </Button>
}

Add print styles in index.css:

@media print {
  nav, button, .no-print { display: none !important; }
  body { background: white !important; }
  * { color: black !important; box-shadow: none !important; }
}

Copy to clipboard

async function copyToClipboard(text: string) {
  await navigator.clipboard.writeText(text)
  toast.success("Copied to clipboard")
}

<Button variant="ghost" size="icon" onClick={() => copyToClipboard(item.id)}>
  <Copy className="h-4 w-4" />
</Button>

Common mistakes

  1. Not escaping CSV values — commas and quotes in data break CSV format. Always wrap values with commas/quotes/newlines in double-quotes.
  2. Not revoking object URL — URL.revokeObjectURL(url) prevents memory leaks.
  3. Large exports blocking the UI — for 10k+ rows, generate on the backend and stream the download.

04 同仓库更多 Skills

SimaDevelopment
SimaDevelopment/opsiforce

figma-use

**MANDATORY prerequisite** — you MUST invoke this skill BEFORE every `use_figma` tool call. NEVER call `use_figma` directly without loading this skill first. Skipping it causes common, hard-to-debug failures. Trigger whenever the user wants to perform a write action or a unique read action that requires JavaScript execution in the Figma file context — e.g. create/edit/delete nodes, set up variables or tokens, build components and variants, modify auto-layout or fills, bind variables to properties, or inspect file structure programmatically.

★ 43
SimaDevelopment
SimaDevelopment/opsiforce

figma-use-slides

This skill helps agents use Figma's use_figma MCP tool in the Slides context. Can be used alongside figma-use which has foundational context for using the use_figma tool.

★ 43
SimaDevelopment
SimaDevelopment/opsiforce

figma-use-motion

Motion / animation context for the `use_figma` MCP tool — animating Figma nodes via manual keyframes, animation styles, easing, and timeline duration. Load alongside figma-use whenever a task involves adding, editing, or inspecting animation on a node.

★ 43
SimaDevelopment
SimaDevelopment/opsiforce

figma-use-figjam

This skill helps agents use Figma's use_figma MCP tool in the FigJam context. Can be used alongside figma-use which has foundational context for using the use_figma tool.

★ 43
SimaDevelopment
SimaDevelopment/opsiforce

figma-swiftui

SwiftUI ↔ Figma translation. Use whenever the user mentions Swift, SwiftUI, iOS, iPhone, or iPad — in EITHER direction — translating a Figma design into SwiftUI (design → code), or pushing SwiftUI views / screens / tokens back into a Figma file (code → design). Triggers on phrases like 'implement this Figma design in SwiftUI', 'build this screen in Swift', 'push this SwiftUI view to Figma', 'mirror my Swift code in a Figma file', or whenever a Figma URL appears alongside `.swift` files / an `.xcodeproj`. Routes to a direction-specific reference doc; loads alongside `figma-use` for the code → design path.

★ 43
SimaDevelopment
SimaDevelopment/opsiforce

figma-shaders

**MANDATORY prerequisite** — load this skill before calling `create_shader` or `update_shader`. Use when the user asks to create, author, change, fix, or iterate on a shader effect, shader fill, custom effect, custom fill, or procedural shader in Figma.

★ 43