formatting — Claude Code prompt: what it does, how to install
formatting instructs Claude Code on spreadsheet styling and format_range payloads, covering locale-locked currency strings, alignments, and financial palettes.
Apache-2.0 ★ 12,746 updated 2026-10-29
.claude/commands/formatting.mdWhat formatting does
The prompt defines the {op:"format_range", sheetId, range:"...", format:{...}} operation payload for ranges containing up to 200,000 cells per call. It provides rules for font families, point sizes from 1 to 409, border styles, text rotation, and three-segment number format patterns.
A critical rule enforces explicit locale prefixes for currency strings, such as [$$-409]#,##0.00. An unbracketed dollar sign transforms into a yuan symbol on Chinese-locale Excel setups, making strict locale locking essential.
For financial models, the instructions prescribe standard color coding: manual inputs use blue #0000FF, formulas remain black, and cross-sheet references take green #008000. Styling failures never block task completion, so data delivery always takes precedence over visual adjustments.
What it helps with
- Prevent currency symbol remapping across regional Excel locales
- Format large cell ranges up to 200,000 cells in a single operation
- Display negative values in red brackets while rendering zeros as dashes
- Apply standard color coding for hardcoded inputs, formulas, and sheet links
Example prompts for the agent
- Format range
B2:F20with right-aligned numbers and USD currency styling - Apply a three-section number format to column
Cwith red negative values and dash for zeros - Style the table header row with bold text,
#F2F2F2fill, and thin borders
How to install formatting
Manually: put the files in place
.claude/commands/formatting.mdHow to use
Paste the text at the start of a chat or into project instructions
Questions about formatting
How to install formatting in Claude Code?
Save the prompt file to .claude/commands/formatting.md inside your workspace directory.
Why does formatting require locale prefixes on currencies?
Excel setups with specific regional locales map an unbracketed $ symbol to local currencies like ¥. Bracketed codes like [$$-409] preserve the intended currency across environments.
What cell limit applies to the format_range operation?
A single format_range call handles ranges containing up to 200,000 cells.
Source text
formatting.md · Apache-2.0
# Formatting guide (formatting)
## Operation definition
`{op:"format_range", sheetId, range:"A1:C1", format:{…}}` — format needs at least one field; a field value of **null clears that property**:
- `bold` / `italic` / `underline` / `strikethrough`: boolean or null
- `fontFamily`: font name (e.g. "Calibri", "微软雅黑") or null
- `fontSize`: point size (1–409) or null
- `fontColor` / `fillColor`: 6-digit hex ("#RRGGBB") or null
- `numberFormat`: Excel format string (e.g. "0.00%", "#,##0.00", "yyyy-mm-dd") or null (restores General)
- `horizontalAlign`: "left" | "center" | "right" or null
- `verticalAlign`: "top" | "center" | "bottom" or null
- `wrapText`: boolean or null (word wrap)
- `textRotation`: integer from -90 to 90 (positive = counterclockwise) or "vertical" (stacked vertical text) or null
- `indent`: indent level 0–250 (0 clears), rendered on screen as left padding and written into the file
- `border`: {type:"all"|"top"|"bottom"|"left"|"right"|"none", color?:"#RRGGBB"} — **per-cell edge** semantics (every cell in the range gets that edge); "none" clears all borders
One operation per range (range-level, up to 200,000 cells — formatting a whole data column of a large file is fine); when you need to "reuse the format from somewhere", read the current state with read_formats first.
## Number formats
- Percentages: generally `0.0%`/`0.00%`; share columns (summing to 100%) at least `0.000%`
- Large numbers: `#,##0`; keep decimal places consistent within a column
- Dates: `yyyy-mm-dd`
### Currency must be locale-locked (critical, most common mistake)
**Never use bare `$#,##0.00`** — Chinese-locale Excel remaps a bare `$` to `¥`, making a USD table display CNY symbols. Always force the currency symbol with a bracketed locale prefix:
- USD: `[$$-409]#,##0.00` (or integer `[$$-409]#,##0`)
- CNY: `[$¥-804]#,##0.00`
- EUR: `[$€-x-euro2]#,##0.00`
- GBP: `[$£-809]#,##0.00`
At thousand/million scale, decimals are usually 0 (`[$$-409]#,##0`) and the unit is noted in the header (e.g. "Amount (thousands)").
### Negatives and zeros (mandatory for financial tables)
- Negatives in red parentheses: `[$$-409]#,##0;[Red]([$$-409]#,##0)`
- Zero displayed as a dash (distinguishes "0" from "blank = missing data"): `[$$-409]#,##0;[Red]([$$-409]#,##0);"-"`
- Three-section format string semantics: `positive;negative;zero`; plain-number version: `#,##0;[Red](#,##0);"-"`
> The full spec for financial statements/accounting tables (hierarchy, total rows, GAAP order, palette) is in the `financial-formatting` guide.
## Table style rules (when the user has no explicit styling requirements)
- **Headers are mandatory**: no data grid may be a bare matrix of numbers — column headers (dimension/period/metric names) are required, and cross-tabs also need row headers. Headers bold + light fill (e.g. #F2F2F2 or #D6E4F0).
- **Alignment**: numbers right-aligned, text left-aligned, dates centered or left-aligned; strictly consistent within a column and within a table.
- **Restrained font sizes**: one size for body text; section titles at most one step larger; never mix multiple font sizes within one table body.
- **Total/subtotal rows**: highlight with bold or a light fill; don't over-decorate.
- **Color accessibility**: keep high contrast between text and background; avoid harsh high-saturation palettes except to emphasize key values.
- **Financial model conventions** (when the user is building a financial model or asks for professional formatting): hard-coded inputs in blue #0000FF, formula calculations in black, cross-sheet references in green #008000.
- **Styling failures never block**: if a format-class operation is rejected, prioritize delivering correct data; do not retry styling repeatedly.
© genspark-ai · Apache-2.0 · genspark-ai/genoffice