技能表

数据 社区

技能解读

当前原文的自动摘译,尚未人工审校。

上下文指针

参考(不要急于加载): 路径:.claude/context/formats/subagent-return.md 目的:返回验证 加载于:仅子代理执行 注意:此技能是一个薄包装。上下文由委托代理加载,而不是由该技能加载。

直接调用

用户显式运行 /sheet 命令 用户使用 .xlsx 文件运行 /edit 命令

隐式调用(任务执行期间)

当实施代理遇到以下任何模式时: 计划步骤语言模式:“使用 [内容] 创建电子表格 [文件].xlsx” “使用 [列/数据] 创建 xlsx [文件]” “将 [文件].xlsx 编辑为 [更改]”

何时不触发

请勿调用: 电子表格到表格的转换(对 /table 使用 Skill-filetypes-spreadsheet) 简单的 CSV/TSV 读取(直接使用 Read 工具) 拨款预算创建(对 /budget 使用 Skill-budget) PDF/DOCX 操作(使用其他文件类型技能)

1. 输入验证

验证所需的输入:file_path - 必须提供;用于编辑/分析的必须存在;用于创建模式可能尚不存在 instruction - 描述所需操作的自然语言指令(必需) mode - 其中之一:“创建”、“编辑”、“分析”(从上下文和文件存在推断)

流狐档案 运行与权限由流狐静态检查推断,不代表作者声明或实际测试结果。
领域
数据
作者声明的智能体
未找到明确声明;不据此推断已兼容或已测试
静态检查
88 / 100 · 启发式扫描,不代表运行安全
运行环境证据
未执行;当前没有隔离运行测试证据
作者 / 版本 / 许可证
@benbrastmckie · 未声明许可证
上下文用量评级
低消耗
接入复杂程度
需简单配置
是否需要外部接口密钥
不需要
兼容的系统
未声明(默认跨平台)
运行环境要求
未检出明确要求
检测到的文件与系统行为
  • 只读
  • 允许写入 / 修改
  • 命令执行
网络行为
仅限本地
安装命令数
无(仅作为资料)

需要注意: 未声明工具权限范围;实际权限由运行环境决定。

作者说明文件(原文) SKILL.md

# XLSX Skill

Thin wrapper that routes XLSX creation, editing, and analysis requests to the `sheet-agent`, which manipulates spreadsheets using openpyxl and pandas via Bash.

## Context Pointers

Reference (do not load eagerly):
- Path: `.claude/context/formats/subagent-return.md`
- Purpose: Return validation
- Load at: Subagent execution only

Note: This skill is a thin wrapper. Context is loaded by the delegated agent, not this skill.

## Trigger Conditions

This skill activates when:

### Direct Invocation
- User explicitly runs `/sheet` command
- User runs `/edit` command with a .xlsx file

### Implicit Invocation (during task implementation)

When an implementing agent encounters any of these patterns:

**Plan step language patterns**:
- "Create spreadsheet [file].xlsx with [content]"
- "Create xlsx [file] with [columns/data]"
- "Edit [file].xlsx to [change]"
- "Edit spreadsheet [file] to [change]"
- "Add formulas to [file].xlsx"
- "Add formatting to [file].xlsx"
- "Update [file].xlsx with [data]"
- "Analyze [file].xlsx for [purpose]"

**File extension detection**:
- Target file has extension: `.xlsx`, `.xlsm`
- Operation type: create, edit, update, modify, analyze, add formulas, add formatting

**Task description keywords**:
- "XLSX creation"
- "spreadsheet creation"
- "xlsx editing"
- "spreadsheet editing"
- "add formulas"
- "add formatting"
- "xlsx analysis"

### When NOT to Trigger

Do not invoke for:
- Spreadsheet-to-table conversion (use skill-filetypes-spreadsheet for /table)
- Simple CSV/TSV reading (use Read tool directly)
- Grant budget creation (use skill-budget for /budget)
- PDF/DOCX operations (use other filetypes skills)
- Presentation operations (use skill-presentation)

---

## Execution

### 1. Input Validation

Validate required inputs:
- `file_path` - Must be provided; for edit/analyze must exist; for create mode may not exist yet
- `instruction` - Natural language instruction describing the desired operation (required)
- `mode` - One of: "create", "edit", "analyze" (inferred from context and file existence)

```bash
# For edit mode: validate source exists and is xlsx/xlsm
if [ "$mode" = "edit" ]; then
  if [ ! -f "$file_path" ]; then
    return error "XLSX file not found: $file_path"
  fi
  if [[ "${file_path##*.}" != "xlsx" && "${file_path##*.}" != "xlsm" ]]; then
    return error "Source must be a .xlsx or .xlsm file: $file_path"
  fi
fi

# For analyze mode: validate source exists
if [ "$mode" = "analyze" ]; then
  if [ ! -f "$file_path" ]; then
    return error "File not found for analysis: $file_path"
  fi
fi

# For create mode: validate xlsx extension
if [ "$mode" = "create" ]; then
  if [[ "${file_path##*.}" != "xlsx" && "${file_path##*.}" != "xlsm" ]]; then
    return error "New file must have .xlsx or .xlsm extension: $file_path"
  fi
fi
```

### 2. Context Preparation

Prepare delegation context:

```json
{
  "file_path": "/absolute/path/to/spreadsheet.xlsx",
  "instruction": "Create a budget tracking spreadsheet with categories, monthly columns, and SUM formulas",
  "mode": "create",
  "metadata": {
    "session_id": "sess_{timestamp}_{random}",
    "delegation_depth": 1,
    "delegation_path": ["orchestrator", "xlsx", "skill-sheet"]
  }
}
```

### 3. Invoke Agent

**CRITICAL**: You MUST use the **Agent** tool to spawn the sheet-agent.

**Required Tool Invocation**:
```
Tool: Agent (NOT Skill, NOT Plan)
Parameters:
  - subagent_type: "sheet-agent"
  - prompt: [Include file_path, instruction, mode, metadata]
  - description: "{mode} {file_path}: {instruction}"
```

**DO NOT** use `Skill(sheet-agent)` - this will FAIL.
Agents live in `.claude/agents/` or extension agent directories, not `.claude/skills/`.
The Skill tool can only invoke skills from `.claude/skills/`.

The agent will:
- Detect available tools (openpyxl, pandas)
- Execute the requested operation (create, edit, or analyze)
- Validate the output file
- Return standardized JSON result

### 4. Return Validation

Validate return matches `subagent-return.md` schema:
- Status is one of: created, edited, analyzed, partial, failed
- Summary is non-empty and <100 tokens
- Artifacts array present with output file path
- Metadata contains session_id, agent_type, delegation info

**Status value rules**:
- `created` - New file successfully created
- `edited` - Existing file successfully modified
- `analyzed` - File read and analysis returned
- `partial` - Some operations succeeded, others failed
- `failed` - No operations applied, error occurred
- NEVER use "completed" (triggers Claude stop behavior)

### 5. Return Propagation

Return validated result to caller without modification.

---

## Return Format

See `.claude/context/formats/subagent-return.md` for full specification.

Expected successful return:
```json
{
  "status": "created",
  "summary": "Created budget.xlsx with 4 category rows, monthly columns Jan-Dec, SUM formulas for totals, and currency formatting.",
  "artifacts": [
    {
      "type": "implementation",
      "path": "/absolute/path/to/budget.xlsx",
      "summary": "XLSX workbook with formulas and formatting"
    }
  ],
  "metadata": {
    "session_id": "sess_...",
    "agent_type": "sheet-agent",
    "delegation_depth": 2,
    "delegation_path": ["orchestrator", "xlsx", "skill-sheet", "sheet-agent"],
    "tool_used": "openpyxl",
    "mode": "create",
    "sheets": 1,
    "rows": 6,
    "columns": 14
  },
  "next_steps": "Open spreadsheet to verify formulas and formatting"
}
```

---

## Error Handling

### Input Validation Errors
Return immediately with failed status if file not found, not a .xlsx/.xlsm, or instruction is empty.

### Unsupported Format
Return failed status if file extension is not .xlsx or .xlsm (for create/edit). Suggest using /convert or /table for other spreadsheet operations.

### Agent Errors
Pass through the agent's error return verbatim.

### Tool Not Available
Return failed status with installation instructions for openpyxl and pandas.

---

## MUST NOT

- Run the postflight step (git commit, status update) -- that is the command's responsibility
- Modify the return from sheet-agent before propagating
- Load context files eagerly -- only reference them when needed
- Use the Skill tool to invoke sheet-agent (use Agent tool instead)

讨论

基于 GitHub Discussions。登录 GitHub 即可参与讨论、点赞、订阅更新。