Spreadsheets
Handle tabular data with exact values, minimal diffs, recipient-scoped data handling, atomic writes, and structural
validation.
Invariants
- Keep precision-sensitive amounts as strings and compute with
decimal.Decimal or DuckDB DECIMAL(38, 18), never
binary floats.
- Touch only requested rows, columns, formulas, and formatting. Existing file conventions override house defaults.
- For newly authored text tables, prefer TSV, UTF-8 without BOM, LF, one trailing newline, lowercase
snake_case
headers, ISO dates, . decimals, and - nulls.
- Read unknown text tables with BOM-tolerant UTF-8; never write a BOM.
- Write in place atomically through a sibling temporary file, validate it, then replace the target.
- Escape external cells beginning with
=, +, or @; a bare - null is exempt. Formula-prefix cells in trusted
authored data are observations, not proof of injection.
- Treat transaction, bank, exchange, and tax data as user-owned. Use unredacted samples in internal agent reports when
materially useful; use
--redact-samples for public or third-party disclosures or when the user asks.
Factual Profiling
Resolve helper paths from this SKILL.md. Profile unknown data before choosing a transformation tool:
uv run "<skill-dir>/scripts/profile.py" <file>
The JSON output has schema_version: 2. It reports structural facts, header quality, cardinality/statistics when qsv is
available, frequency facts, formula-prefix cells, workbook metadata, and local tool availability. It contains no tool
recommendations and does not infer identifiers from uniqueness. Choose the tool from the requested transformation,
provenance, output format, and preservation requirements.
Use --external-data only when the cells came from an external or otherwise untrusted source and will be written to a
formula-capable consumer. With that flag, formula-prefix cells affect status; without it, legitimate formulas such as
=SUM(...) remain factual observations and do not fail the profile.
Tool Routing
| Need |
Tool |
| Fast structural preview/validation |
uv run "<skill-dir>/scripts/peek.py" <file> |
| Factual local quality profile |
uv run "<skill-dir>/scripts/profile.py" <file> |
| Counts, stats, frequencies, select, dedupe |
qsv |
| Joins, pivots, aggregation, conversion |
DuckDB with all_varchar = true |
| Exact custom transforms |
uv run Python, stdlib csv, decimal.Decimal |
| New text table or intentional schema change |
Read references/text-table-design.md first |
Any .xlsx/.xlsm input or output |
Read references/xlsx.md first |
| Exact transformation/validation recipes |
Read references/recipes.md only when needed |
Prefer qsv --cache-threshold 0 where supported. When qsv stdout must remain TSV, use -o out.tsv; stdout otherwise
defaults to CSV.
Workflow
- For a new text table or intentional schema change, read
references/text-table-design.md and record the intended
table interface plus migration surface.
- Inspect with
peek.py; add profile.py when cardinality, formula prefixes, metadata, or available tooling matters.
For a no-shape-change edit, save the peek JSON. For intentional row/schema changes, record the expected width and
invariants.
- Decide whether formula-prefix cells are dangerous from provenance and output context. Decide the smallest tool that
preserves values and formatting. Avoid pandas unless necessary; if used, load every column as strings.
- Apply the transformation atomically. For idempotent appends with legitimate duplicate rows, use multiset difference
rather than set deduplication.
- Validate:
- unchanged shape:
peek.py --strict --expect-like <before-report>;
- changed shape:
peek.py --strict --expect-columns <n> plus task-specific counts/keys;
- authored house TSV: add
--house;
- formulas:
uv run "<skill-dir>/scripts/recalc.py" <file.xlsx> and require success.
- Report paths, row/column effects, validation, and any workbook features that could not be preserved.
For human output, lead with ### 📊 Spreadsheet — ✅ updated only after the write and required validation pass, or
### 📊 Spreadsheet — 🔎 inspected, no files written for read-only work. On required validation failure, use
### 📊 Spreadsheet — ⛔ not deliverable. Include profile JSON only when it materially supports the report, and keep
JSON, cells, headers, formulas, paths, commands, and diagnostics undecorated.
Generated Financial Artifacts
Treat generated financial tables and reports as outputs. Before editing, identify their source inputs and the
project-provided validation and regeneration commands. Edit only the sources, validate them, then regenerate affected
outputs; never hand-edit generated tables or reports. Cap financial output to counts and file references unless raw rows
materially support the task or were requested. Perform an external-disclosure review before sending financial data
outside the agent workspace.
Completion requires the requested artifact, an intentional diff, atomic replacement where applicable, and structural
plus domain validation evidence. A new or changed text-table schema also requires a defined table interface and a
complete migration of affected producers, consumers, existing rows, generated artifacts, and validators.
1---2name: spreadsheets3description: Use when CSV, TSV, or Excel (.xlsx) is the primary input/output: design or review text-table schemas; inspect, transform, validate, convert, or recalc formulas; or create/fix spreadsheets. Do not trigger when tabular data is incidental.4---5
6# Spreadsheets
7
8Handle tabular data with exact values, minimal diffs, recipient-scoped data handling, atomic writes, and structural
9validation.
10
11## Invariants
12
131. Keep precision-sensitive amounts as strings and compute with `decimal.Decimal` or DuckDB `DECIMAL(38, 18)`, never
14 binary floats.
152. Touch only requested rows, columns, formulas, and formatting. Existing file conventions override house defaults.
163. For newly authored text tables, prefer TSV, UTF-8 without BOM, LF, one trailing newline, lowercase `snake_case`
17 headers, ISO dates, `.` decimals, and `-` nulls.
184. Read unknown text tables with BOM-tolerant UTF-8; never write a BOM.
195. Write in place atomically through a sibling temporary file, validate it, then replace the target.
206. Escape external cells beginning with `=`, `+`, or `@`; a bare `-` null is exempt. Formula-prefix cells in trusted
21 authored data are observations, not proof of injection.
227. Treat transaction, bank, exchange, and tax data as user-owned. Use unredacted samples in internal agent reports when
23 materially useful; use `--redact-samples` for public or third-party disclosures or when the user asks.
24
25## Factual Profiling
26
27Resolve helper paths from this `SKILL.md`. Profile unknown data before choosing a transformation tool:
28
29```sh
30uv run "<skill-dir>/scripts/profile.py" <file>
31```
32
33The JSON output has `schema_version: 2`. It reports structural facts, header quality, cardinality/statistics when qsv is
34available, frequency facts, formula-prefix cells, workbook metadata, and local tool availability. It contains no tool
35recommendations and does not infer identifiers from uniqueness. Choose the tool from the requested transformation,
36provenance, output format, and preservation requirements.
37
38Use `--external-data` only when the cells came from an external or otherwise untrusted source and will be written to a
39formula-capable consumer. With that flag, formula-prefix cells affect `status`; without it, legitimate formulas such as
40`=SUM(...)` remain factual observations and do not fail the profile.
41
42## Tool Routing
43
44| Need | Tool |
45| ------------------------------------------- | ------------------------------------------------ |
46| Fast structural preview/validation | `uv run "<skill-dir>/scripts/peek.py" <file>` |
47| Factual local quality profile | `uv run "<skill-dir>/scripts/profile.py" <file>` |
48| Counts, stats, frequencies, select, dedupe | `qsv` |
49| Joins, pivots, aggregation, conversion | DuckDB with `all_varchar = true` |
50| Exact custom transforms | `uv run` Python, stdlib `csv`, `decimal.Decimal` |
51| New text table or intentional schema change | Read `references/text-table-design.md` first |
52| Any `.xlsx`/`.xlsm` input or output | Read `references/xlsx.md` first |
53| Exact transformation/validation recipes | Read `references/recipes.md` only when needed |
54
55Prefer `qsv --cache-threshold 0` where supported. When qsv stdout must remain TSV, use `-o out.tsv`; stdout otherwise
56defaults to CSV.
57
58## Workflow
59
601. For a new text table or intentional schema change, read `references/text-table-design.md` and record the intended
61 table interface plus migration surface.
622. Inspect with `peek.py`; add `profile.py` when cardinality, formula prefixes, metadata, or available tooling matters.
63 For a no-shape-change edit, save the peek JSON. For intentional row/schema changes, record the expected width and
64 invariants.
653. Decide whether formula-prefix cells are dangerous from provenance and output context. Decide the smallest tool that
66 preserves values and formatting. Avoid pandas unless necessary; if used, load every column as strings.
674. Apply the transformation atomically. For idempotent appends with legitimate duplicate rows, use multiset difference
68 rather than set deduplication.
695. Validate:
70 - unchanged shape: `peek.py --strict --expect-like <before-report>`;
71 - changed shape: `peek.py --strict --expect-columns <n>` plus task-specific counts/keys;
72 - authored house TSV: add `--house`;
73 - formulas: `uv run "<skill-dir>/scripts/recalc.py" <file.xlsx>` and require success.
746. Report paths, row/column effects, validation, and any workbook features that could not be preserved.
75
76For human output, lead with `### 📊 Spreadsheet — ✅ updated` only after the write and required validation pass, or
77`### 📊 Spreadsheet — 🔎 inspected, no files written` for read-only work. On required validation failure, use
78`### 📊 Spreadsheet — ⛔ not deliverable`. Include profile JSON only when it materially supports the report, and keep
79JSON, cells, headers, formulas, paths, commands, and diagnostics undecorated.
80
81## Generated Financial Artifacts
82
83Treat generated financial tables and reports as outputs. Before editing, identify their source inputs and the
84project-provided validation and regeneration commands. Edit only the sources, validate them, then regenerate affected
85outputs; never hand-edit generated tables or reports. Cap financial output to counts and file references unless raw rows
86materially support the task or were requested. Perform an external-disclosure review before sending financial data
87outside the agent workspace.
88
89Completion requires the requested artifact, an intentional diff, atomic replacement where applicable, and structural
90plus domain validation evidence. A new or changed text-table schema also requires a defined table interface and a
91complete migration of affected producers, consumers, existing rows, generated artifacts, and validators.