structure — промпт для Claude Code: работа с листами Excel
Промпт structure для структурных операций с Excel: вставка и удаление строк, колонок, листов, защита листов. Требует соблюдать батчинг — структурные изменения отдельно от записи данных.
Apache-2.0 ★ 12 746 обновлён 2026-10-29
.claude/commands/structure.mdЧто делает structure
Промпт описывает восемь операций для изменения структуры книги Excel: insert_rows, delete_rows, insert_cols, delete_cols, add_sheet, delete_sheet, duplicate_sheet, move_sheet, set_sheet_hidden и protect_sheet. Все структурные операции сдвигают адреса ячеек и автоматически обновляют формулы.
Критичное требование: структурные операции нельзя смешивать в одном батче с записью данных или форматированием. Правильный порядок — подать структурные изменения, вызвать get_workbook_context заново, потом записать содержимое. При создании нового листа через add_sheet нужно явно задать rows и columns, если данных больше 1000 строк или 20 колонок — дефолтная сетка отбрасывает всё за её границей.
При удалении строк или колонок формулы, ссылающиеся на удалённые ячейки, превращаются в #REF! — промпт советует проверять предупреждения перед применением.
Какие задачи решает
- вставить строки или колонки в середину листа Excel без ручного сдвига данных
- добавить новый лист с заданным числом строк перед импортом большого массива
- защитить лист паролем и разрешить только сортировку и фильтры
- удалить лист или скрыть его, сохранив остальные видимыми
- избежать ошибки
#REF!при удалении строк, на которые ссылаются формулы
Примеры запросов агенту
- Вставь три пустые строки перед второй строкой в листе
sheetId:123, а потом заполни их данными из массива - Создай новый лист
resultsс 5000 строками и 30 колонками, потом скопируй туда таблицу изdata - Защити лист
summaryпаролемqwerty, запрети редактирование, но разреши вставку строк и автофильтр
Как установить structure
Вручную: положить файлы
.claude/commands/structure.mdКак использовать
Вставьте текст в начало диалога или в инструкции проекта
Вопросы о structure
Как установить structure в Claude Code?
Скопируй промпт в .claude/commands/structure.md в корне проекта.
Что делает промпт structure?
Описывает команды для изменения структуры Excel-книги: вставку и удаление строк, колонок, листов, защиту листов и правила батчинга — структурные операции нельзя миксовать с записью данных.
Почему structure требует разделять структурные операции и запись данных в разные батчи?
Структурные операции сдвигают адреса ячеек. Новые адреса появляются только после применения батча, поэтому запись в «новые строки» в том же батче вызовет ошибку — нужно сначала применить структурные изменения, перечитать контекст, потом писать.
Исходный текст
structure.md · Apache-2.0
# Structural changes guide (structure)
## Operation definitions
- `{op:"insert_rows", sheetId, row:2, count:1}` — row is 1-based; new rows are inserted **before** that row.
- `{op:"delete_rows", sheetId, row, count}` — deletes count rows starting at row.
- `{op:"insert_cols", sheetId, column:"C", count}` — new columns are inserted before that column; column uses the column letter.
- `{op:"delete_cols", sheetId, column, count}`
- `{op:"add_sheet", name, rows?, columns?}` — creates a blank worksheet (no sheetId needed). The grid defaults to **1000 rows × 20 columns**; writes beyond the grid are rejected and formula spills truncate at its edge, so pass `rows`/`columns` sized to the expected data (plus a little headroom) when it will hold more — e.g. `{op:"add_sheet", name:"ja", rows:6700}` before copying ~6600 rows into it.
- `{op:"delete_sheet", sheetId}` — deletes a worksheet; the last remaining sheet cannot be deleted. Formulas on other sheets referencing the deleted sheet become #REF! (listed in the preview warnings); for real xlsx files there is an additional fail-closed guard on save (sheets referenced by formulas/charts/defined names refuse deletion).
- `{op:"duplicate_sheet", sheetId, name?}` — copies a whole worksheet (contents and formats); name is auto-generated when omitted. Unavailable in large-file streaming mode; sheets containing pivot tables cannot be duplicated.
- `{op:"set_sheet_hidden", sheetId, hidden:true|false}` — hides/shows a worksheet; at least one sheet must stay visible.
- `{op:"move_sheet", sheetId, position:1}` — moves to the 1-based tab position.
## Sheet protection
`{op:"protect_sheet", sheetId, protected:true|false, password?, allow?}` — **layout-class**, can share a batch with content/format operations (exempt from the batching discipline below). Written into the file on save and enforced in the editor (locked cells refuse edits). `password` is optional plaintext: it is hashed when protecting and required to unprotect a password-protected sheet. `allow` lists what stays permitted while protected (selectLockedCells, selectUnlockedCells, formatCells, formatColumns, formatRows, insertColumns, insertRows, insertHyperlinks, deleteColumns, deleteRows, sort, autoFilter, pivotTables, objects, scenarios); unlisted flags are false except the two select flags.
## Mandatory batching discipline
Structural operations move cell addresses and **cannot appear in the same batch as content/format/sort-layout operations**. The correct rhythm:
1. Submit the structural changes alone first (multiple structural ops may share a batch, applied in order, effective on submit)
2. Call get_workbook_context / read_range again for the shifted layout
3. Then submit the content/format changes
## Formula references
- On row/column insertion/deletion, all A1 references in the workbook's formulas are rewritten automatically for the shift (including absolute $ references and cross-sheet prefixed references).
- Formulas whose reference target is deleted entirely become **#REF!** — the preview warnings list the affected cells precisely. When this happens, ask the user to confirm, or proactively suggest a fix.
- Range references (like SUM(B2:B10)) shrink automatically on partial deletion — you don't need to repair formulas by hand.
## Common mistakes
- ❌ insert_rows followed by writing into the "new rows" in the same batch — rejected by the mixed-batch rule, and the new rows' addresses don't exist before apply.
- ❌ Continuing to write with old addresses right after a structural change applies — re-read the context first.
- ❌ Using delete_rows to clear data — when you only want to clear contents, use clear_range (structure unchanged, formula references unaffected).
© genspark-ai · Apache-2.0 · genspark-ai/genoffice