writing — промпт для Claude Code: что делает и как установить
Промпт writing задаёт агенту правила правки таблиц: формулы вместо посчитанных вручную чисел, пакетные операции вместо поячеечных записей.
Apache-2.0 ★ 12 746 обновлён 2026-10-29
.claude/commands/writing.mdЧто делает writing
Это файл слэш-команды: он описывает агенту операции записи в таблицу и правила работы с формулами. Внутри перечислены set_cell, set_formula, set_range, fill_range, copy_range, move_range, convert_to_values и clear_range — у каждой свои аргументы и пределы. fill_range тиражирует блок вместе с формулами по цели, относительные ссылки сдвигаются, привязанные через $ остаются на месте.
Лимит батча — 2000 изменённых ячеек, диапазонные операции берут до 200 000. Поэтому переписывать таблицу по одной ячейке через set_cell смысла нет: упрёшься в потолок, а set_range сделает то же одним запросом. copy_range переносит блок один раз, move_range делает то же и очищает источник.
Отдельный раздел про формулы: считать вручную и вписывать готовое число запрещено. Формулы с критерием по большой колонке вроде SUMPRODUCT(1/COUNTIF(A2:A88588,A2:A88588)) отклоняются, потому что считаются квадратично. Число различных значений агент берёт из aggregate_range и отвечает текстом.
Какие задачи решает
- растянуть формулу на весь столбец одной операцией
- перенести блок строк на другой лист, сохранив формулы
- разложить большой лист по значениям одной колонки
- заморозить формулы в значения перед удалением исходных данных
- переписать диапазон целиком, чтобы не остались обрывки старых строк
Примеры запросов агенту
/writingЗаполни столбец C формулой=B2*1.2до конца таблицы- Скопируй лист
Январьв новый лист вместе с формулами - Замени формулы в
D2:D500на их текущие значения
Как установить writing
Вручную: положить файлы
.claude/commands/writing.mdКак использовать
Вставьте текст в начало диалога или в инструкции проекта
Вопросы о writing
Как установить writing в Claude Code?
Скопируйте файл команды в проект по пути .claude/commands/writing.md. После этого она вызывается как /writing.
Что делает writing?
Описывает агенту операции записи в таблицу и правила формул: пакетную запись диапазонов, заполнение, копирование и перенос блоков, заморозку формул в значения.
Почему формула SUMPRODUCT(1/COUNTIF(A2:A88588,A2:A88588)) не проходит?
Такие формулы считаются квадратично и подвесили бы приложение, поэтому их отклоняют. Различные значения агент считает через aggregate_range и отвечает текстом.
Исходный текст
writing.md · Apache-2.0
# Content writing guide (writing)
## Operation definitions
- `{op:"set_cell", sheetId, address:"B2", value}` — writes a single value (string/number/boolean/null). Optional `expectedValue` for concurrency protection.
- `{op:"set_formula", sheetId, address, formula:"=SUM(A1:A10)"}` — writes a formula, must start with =. Optional `expectedFormula`.
- `{op:"clear_cell", sheetId, address}` — clears a single cell.
- `{op:"set_range", sheetId, start:"B2", values:[[row1], [row2], …]}` — bulk write: a 2D array laid out by rows, spreading right and down from start. **values must be rectangular — every row the same length** (use null for a cell to clear; a shorter row would silently leave stale content behind). Instead of start you may pass `range:"B2:D5"`, whose size must exactly match values. **Strings starting with = are written as formulas.** Always use set_range for contiguous regions; never split them into many set_cell ops.
- **When rewriting rows of an existing table, cover the full row span**: values rows should span all of the table's columns (or the write should be paired with clear_range for the leftover cells) so no stale fragments from the old content survive next to the new one.
- `{op:"fill_range", sheetId, source:"B2", target:"B2:B88588", sourceSheetId?}` — fill/copy, Excel's fill handle as one operation: the source block's values **and formulas** tile across the target. Relative references shift per copy (=A2+1 filled down becomes =A3+1, =A4+1, …); `$`-anchored axes stay pinned. **This is THE way to fill a formula or pattern down a whole column** — one small op instead of spelling out thousands of set_range rows. Rules: write/verify the source cell(s) first, then fill; source ≤ 2000 cells; target up to **200,000 cells** and each dimension a whole multiple of the source's; an overlapping source must sit at the target's top-left (fill-down/right includes the source as the first tile); `sourceSheetId` lets the source live on another sheet (copy header rows between sheets). Fills of formulas that re-scan a large absolute range per copy (=SUM(B$2:B$88588), lookups against big tables) are rejected — use relative references so each row touches only its own cells.
- `{op:"copy_range", sheetId, source:"A1:F5000", target:"H1", sourceSheetId?, filterColumn?, filterValues?}` — copies one block to one destination exactly once (Excel copy → paste as one operation), values **and formulas**; relative references shift by the block's offset, `$`-anchored axes stay pinned. On large streamed workbooks (cached-value mode) formulas are carried live within the shared engine budget (their referenced file cells are loaded on demand); when the copied formulas' references exceed that budget — or a formula is too expensive to evaluate live — the copy writes the source cells' current values instead and the result notes how many formula cells were frozen and why. `target` is the destination's top-left cell (or a range exactly the source's size). Unlike fill_range there is no tiling and the source may be large — up to **200,000 cells** — so this is THE way to duplicate a big table or move a column's data (source and target must not overlap; `sourceSheetId` copies across sheets).
- **Filtered copy (row extraction)**: with `filterColumn` (an absolute column letter inside the source range) and `filterValues` (1–100 strings), copy_range copies **only the source rows whose cell in that column matches one of the values** (compared as text, trimmed, case-insensitive), compacted at the target with no gaps, as **static values** (formulas are not carried over). `target` must be a single anchor cell. It reads the real file data chunk by chunk, so it works on large streamed workbooks where FILTER-style formulas are rejected. This is THE way to split a big sheet by a column's values: aggregate_range the column first for the distinct values and counts, add_sheet each target with `rows` sized to its count (plus header), copy the header row with a plain copy_range, then one filtered copy_range per value with the target anchored below the header. A filter that matches zero rows fails with an error (check the actual cell values); a match count exceeding the target sheet's grid also fails and tells you how many rows were needed.
- `{op:"move_range", sheetId, source:"A2:V14", target:"A1", sourceSheetId?}` — Excel's cut → paste as one operation: copies the block exactly like copy_range (values **and** formulas, relative references shift, up to **200,000** cells), then clears the source cells. `sheetId` is the destination sheet; `sourceSheetId` lets the source live on another sheet. Source and target must not overlap; the source rows stay in place as empty cells — follow with delete_rows / delete_cols in a separate structural batch if the user wants them gone.
- **Moving existing data — pick the op by what changes**: when the user says move / cut / relocate / transfer / "put these rows on that sheet" and the content travels unchanged, use ONE move_range (or copy_range when the original must stay). Rewriting the cells through set_cell / set_range is only right when the data changes on the way (reordered or dropped columns, transposed, transformed values) or the geometry rules out a block op (overlapping source and target). Never read a block and re-type it cell by cell when move_range / copy_range can carry it: it is slower, shows the user hundreds of edits, and risks typos.
- `{op:"convert_to_values", sheetId, range:"B2:B88588"}` — freezes formulas into their current computed values (Excel's copy → paste-values), up to **200,000 cells**. Only formula cells change; values, text, and formatting stay untouched. Use when the user asks to "remove the formulas but keep the results", or before deleting source data that formulas reference. It reads what the grid holds **now**, so it must not share a batch with ops writing formulas into its range (rejected) — write the formulas in one batch, verify the results, then convert in a follow-up batch.
- `{op:"clear_range", sheetId, range:"A1:C10"}` — clears a rectangular region (up to 200,000 cells — whole columns are fine).
Limit: at most 2000 expanded cell changes per batch — the range-level ops fill_range / copy_range / move_range / convert_to_values / clear_range / find_replace / format_range are exempt and handle up to 200,000 cells each.
## Formula rules
- **Always leave calculations to formulas** — never compute values yourself and hard-code them; the table should update automatically when source data changes.
- **No array-criteria formulas over large ranges**: formulas where a criteria/lookup function receives a large range as its per-element argument — e.g. the distinct-count idiom `SUMPRODUCT(1/COUNTIF(A2:A88588,A2:A88588))` — evaluate quadratically, would freeze the app, and are rejected. For distinct counts / frequency statistics use the aggregate_range tool and report the answer in text.
- If a reference can be expressed with relative/absolute references ($), don't write a constant.
- Stay consistent with existing conventions: if earlier rows use formulas, new rows use formulas too; if earlier tax amounts are negative, newly filled ones should be negative too.
**Wrong** — computed mentally and hard-coded:
```json
{ "op": "set_cell", "sheetId": "s1", "address": "B10", "value": 5000 }
```
**Right** — let the sheet compute it:
```json
{ "op": "set_formula", "sheetId": "s1", "address": "B10", "formula": "=SUM(B2:B9)" }
```
## Share/percentage columns (where the total must be 100%)
- Keep full precision in the cells: use a formula like `=B4/SUM($B$4:$B$8)` — do **not** write rounded constants row by row, which makes the total display 100.1% or 99.9%.
- Rounding belongs to display formatting (format_range's numberFormat, at least `0.000%`), not to the stored value.
## Values and units
- Ratios/growth rates/shares and other relative values are stored as **decimals in (0,1)** (0.1234 means 12.34%); if the source data is a percent number like 26.64, divide by 100 before writing.
- Keep units, decimal places, and currency symbols consistent within a column; note the unit in the header or title (e.g. "Amount (USD millions)").
- Dates: prefer writing ISO form (2026-07-23) + a number format controlling the display.
## Find & replace (find_replace)
`{op:"find_replace", sheetId, range:"A1:D50", find:"old text", replace:"new text", matchCase?, wholeCell?}`
- Replaces **text values only**: formula cells and numbers are untouched.
- Case-insensitive by default (matchCase:true enables case sensitivity); with wholeCell:true a cell is replaced only when its whole content matches exactly.
- range is required, up to **200,000 cells** (a whole used column is fine). Ranges ≤2000 cells expand into per-cell edits (preview/undo match manual input) and must be loaded first; larger ranges apply as one range-level scan that loads each region itself.
© genspark-ai · Apache-2.0 · genspark-ai/genoffice