Skill 寫法圖鑑

xlsx-author

Anthropic | Office 與 PDF | 原文 | Apache-2.0

headless 模式下用 openpyxl 在磁碟上產出 xlsx 檔

中文翻譯

---
name: xlsx-author
description: 在磁碟上產出 .xlsx 檔案(headless),而不是操作開著的 Excel 活頁簿。適用於沒有開啟 Office app 的 managed-agent session。
---

# xlsx-author

在 **headless** 模式(managed-agent / CMA 模式)下執行,而且需要把 Excel 活頁簿當成**檔案成品**交付,而不是透過 `mcp__office__excel_*` 編輯開著的活頁簿時,就用這個 skill。

## 輸出約定

- 寫到 `./out/<name>.xlsx`。如果 `./out/` 不存在就建立它。
- 在最後的訊息裡回傳相對路徑,讓編排層可以收走檔案。

## 怎麼建立活頁簿

寫一個簡短的 Python script,用 Bash 執行。使用 `openpyxl`:

```python
from openpyxl import Workbook
from openpyxl.styles import Font, PatternFill

wb = Workbook()
ws = wb.active; ws.title = "Inputs"
ws["B2"] = "Revenue"; ws["C2"] = 1_250_000_000
ws["C2"].font = Font(color="0000FF")           # blue = hardcoded input
calc = wb.create_sheet("DCF")
calc["C5"] = "=Inputs!C2*(1+Inputs!C3)"        # black = formula
wb.save("./out/model.xlsx")
```

## 慣例(比照 `audit-xls`)

- **藍/黑/綠。** 藍 = 寫死的輸入、黑 = 公式、綠 = 連到其他工作表/檔案的連結。
- **計算儲存格不准有寫死的值。** 每個計算儲存格都是公式;每個輸入都放在 Inputs 分頁。
- 任何會被簡報或備忘錄引用的值,都要用**具名範圍**。
- **平衡檢查。** 放一個 Checks 分頁,檢查是否勾稽(資產負債表平衡、現金流量表對得上現金等),並顯示 TRUE/FALSE。
- **一個檔案一個模型。** 除非明確要求,不要往現有活頁簿裡追加內容。

## 什麼時候不要用

如果有 `mcp__office__excel_*` 工具可用(Cowork plugin 模式),就改用那些,它們會操作使用者開著的活頁簿,並有審查檢查點。這個 skill 只是 headless 執行時產出檔案的備案。

英文原文

---
name: xlsx-author
description: Produce a .xlsx file on disk (headless) instead of driving a live Excel workbook — for managed-agent sessions with no open Office app.
---

# xlsx-author

Use this skill when running **headless** (managed-agent / CMA mode) and you need to deliver an Excel workbook as a **file artifact** rather than editing a live workbook via `mcp__office__excel_*`.

## Output contract

- Write to `./out/<name>.xlsx`. Create `./out/` if it does not exist.
- Return the relative path in your final message so the orchestration layer can collect it.

## How to build the workbook

Write a short Python script and run it with Bash. Use `openpyxl`:

```python
from openpyxl import Workbook
from openpyxl.styles import Font, PatternFill

wb = Workbook()
ws = wb.active; ws.title = "Inputs"
ws["B2"] = "Revenue"; ws["C2"] = 1_250_000_000
ws["C2"].font = Font(color="0000FF")           # blue = hardcoded input
calc = wb.create_sheet("DCF")
calc["C5"] = "=Inputs!C2*(1+Inputs!C3)"        # black = formula
wb.save("./out/model.xlsx")
```

## Conventions (mirror `audit-xls`)

- **Blue / black / green.** Blue = hardcoded input, black = formula, green = link to another sheet/file.
- **No hardcodes in calc cells.** Every calculation cell is a formula; every input lives on an Inputs tab.
- **Named ranges** for any value referenced from a deck or memo.
- **Balance checks.** Include a Checks tab that ties (BS balances, CF ties to cash, etc.) and surfaces TRUE/FALSE.
- **One model per file.** Do not append to an existing workbook unless explicitly asked.

## When NOT to use

If `mcp__office__excel_*` tools are available (Cowork plugin mode), use those instead — they drive the user's live workbook with review checkpoints. This skill is the file-producing fallback for headless runs.