code-rules

code-rules is a skill for Claude Code from claude-office-skills/claude-office-plugin. It costs 26 tokens per session (1,421 once invoked), scanned A, original, MIT.

A set of rules for generating WPS spreadsheet code in one JavaScript block. It specifies how to address cells, use the active sheet, protect existing data, and return a result.

In plain words
What is it for?
Use it when generating spreadsheet automations for analysis, modeling, formatting, or new worksheets, especially when the code must follow strict WPS conventions.
Why use it?
It reduces errors caused by split code, hard-coded sheet names, unsupported spreadsheet APIs, or accidentally overwriting a user’s data.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Part of the claude-wps-excel plugin — 26 skills, 14 commands, 8 agents, 2 MCP servers shipped together

Good fit Use it when generating spreadsheet automations for analysis, modeling, formatting, or new…

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/claude-office-skills/claude-office-plugin/code-rules
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add claude-office-skills/claude-office-plugin --skill code-rules
Clone the repo
git clone --depth 1 https://github.com/claude-office-skills/claude-office-plugin

Made for: Claude Code.

Or install claude-wps-excel, the plugin that ships this one along with the rest of its 26 skills, 14 commands, 8 agents, 2 MCP servers.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for code-rules

README.md
[![agentmods](https://agentmods.dev/badge/skills/claude-office-skills/claude-office-plugin/code-rules.svg)](https://agentmods.dev/skills/claude-office-skills/claude-office-plugin/code-rules)
Your own site
<a href="https://agentmods.dev/skills/claude-office-skills/claude-office-plugin/code-rules"><img src="https://agentmods.dev/badge/skills/claude-office-skills/claude-office-plugin/code-rules.svg" alt="Measured on agentmods" height="20"></a>
Per session 26 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,421 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00026 $0.01421
Opus 5 $0.00013 $0.00711
Sonnet 5 $0.00005 $0.00284
Haiku 4.5 $0.00003 $0.00142

Measured 7d ago against content hash 04f1ff8680a5, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

code-rules scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 7d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/bundled/code-rules/SKILL.md · 110 lines

How it starts

The opening of the file, as written. The whole thing — 110 lines — stays where its author put it; the contents beside it link to each section on GitHub.

代码生成规则(严格遵守)

⚠️ 最重要的规则:所有操作必须在一个代码块中完成!

绝对禁止拆分代码

  • 禁止将代码拆成 "Part 1", "Part 2", "Part 3" 等多段
  • 禁止写 "先运行这段,再运行下一段"
  • 无论任务多复杂(DCF 建模、财务分析、仪表板),都必须在一个 javascript 块中完成
  • 如果代码太长(>300行),优先简化设计而非拆分代码

代码规范

  1. 一个代码块完成所有逻辑(不可拆分!)
  2. 代码顶部必须定义 CL() 辅助函数
  3. 禁止使用 ws.Cells()、ws.Rows()、ws.Columns(),全部用 ws.Range() 替代
  4. 代码最后一行是返回值字符串
  5. 始终用中文回复和注释
  6. 列宽用 ws.Range("A:A").ColumnWidth = N
  7. 行高用 ws.Range("1:1").RowHeight = N

⚠️ 始终使用 ActiveSheet(禁止硬编码 sheet 名称)

操作当前表时,必须用 Application.ActiveSheet,绝对不要用 wb.Sheets.Item("表名") 硬编码 sheet 名称。因为用户可能已经重命名了 sheet,硬编码名称会导致代码操作错误的 sheet 或报错。

// ✅ 正确
var ws = Application.ActiveSheet;

// ❌ 错误:sheet 可能已被重命名
// var ws = wb.Sheets.Item("库存管理系统");

仅在明确需要跨 sheet 操作(如从源表读数据写到新表)时,才通过 WPS 上下文提供的 sheetName 引用特定 sheet。

不要覆盖用户已有数据

  • 数据分析/趋势分析/建模任务:必须新建工作表,不得在现有工作表上执行 Clear() 或覆盖数据
// 创建新工作表(正确模式)
var wb = Application.ActiveWorkbook;
var srcWs = Application.ActiveSheet; // 先保存原始数据表引用
var ws;
try { ws = wb.Sheets.Item("分析结果"); ws.UsedRange.Clear(); } catch(e) {
  wb.Sheets.Add();
  ws = wb.ActiveSheet;
  ws.Name = "分析结果";
}
ws.Activate(); // 必须激活新工作表
// 从 srcWs 读取原始数据,写入 ws 做分析
  • ⚠️ wb.Sheets.Add() 返回 null,必须用 wb.ActiveSheet 获取新建的工作表引用
  • ⚠️ 新建工作表后必须调用 ws.Activate() 让用户能看到结果
  • 仅当用户明确说"修改/替换/清除现有数据"时,才在 ActiveSheet 上操作

WPS JSAPI 兼容性(VS Excel VBA / Office.js 关键差异)

⚠️ 这是 WPS Office JS 宏环境,不是 Excel VBA 也不是 Office.js! 以下差异必须严格遵守:

VBA / Office.js 写法(❌ 错误) WPS JSAPI 写法(✅ 正确)
ws.Cells(row, col) ws.Cells.Item(row, col)ws.Range(CL(col)+row)
ws.Rows(5) ws.Range("5:5")
ws.Columns("D") ws.Range("D:D")
ws.Columns("D:F") ws.Range("D:F")
Worksheets(1) Worksheets.Item(1)
wb.Sheets("名称") wb.Sheets.Item("名称")
chart.SeriesCollection(1) chart.SeriesCollection.Item(1)
Range("A1").Value Range("A1").Value2(写入)/ Range("A1").Value()(读取)
ActiveSheet(无前缀) Application.ActiveSheet
ActiveWorkbook(无前缀) Application.ActiveWorkbook
[A1] = 5 Range("A1").Value2 = 5
.Select / .Activate(无括号) .Select() / .Activate()(必须加括号)
AddChart2(-1, type, ...) AddChart2(0, type, ...)(Style -1 返回 null)
chartWs.Cells.Clear() chartWs.UsedRange.Clear()

Read the full file on GitHub · 110 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 7d ago First seen · 110 lines · 26 tokens per session scan A 04f1ff8680a5

Subscribe to this mod's changes

code-rules is a skill published in the GitHub repository claude-office-skills/claude-office-plugin (9 stars, last pushed 5mo ago), licensed MIT. It adds 26 tokens to every session and 1,421 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.