code-rules

Enforce deterministic code generation rules for automated coding tasks.

3|Updated Feb 26, 2026
One-click install
npx skills add https://github.com/claude-office-skills/claude-wps-word-plugin --skill code-rules
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: code-rules
Source: https://github.com/claude-office-skills/claude-wps-word-plugin/tree/main/skills/bundled/code-rules
Command: npx skills add https://github.com/claude-office-skills/claude-wps-word-plugin --skill code-rules

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

代码生成规范与安全约束通过强制执行一组明确的规则来避免不一致的代码输出、降低错误风险,并确保在自动化场景中生成的代码可维护和可预测。

Core Features & Use Cases

  • 仅使用 var 声明变量,避免引入隐性块级作用域的复杂性。
  • 禁止箭头函数、let、const、class、模板字符串等现代特性,确保兼容性与可预测性。
  • 代码总长度不超过 3000 字符,避免生成过长的片段影响可读性。
  • 返回值必须在最后一行返回字符串,确保调用方可直接获取结果。
  • 安全规范:所有文档操作使用 try/catch,操作前检查对象存在性,避免对空对象或未初始化对象进行修改。
  • 错误处理:提供清晰的错误信息,确保在异常时返回可观测的字符串结果。
  • 返回值规范:提供具体、描述性的返回文本,而非简单的 'done'。

Quick Start

用 Claude 产出符合本规范的代码片段。

Frequently Asked Questions about code-rules

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I enforce safe and consistent code generation in automated scripts?

Safe code generation enforces deterministic outputs by applying strict rules to variable declarations, error handling, and return values. It prevents unpredictable behavior in automated coding tasks by mandating try/catch blocks and explicit object existence checks before modifications.

Why does automated JavaScript code generation avoid let, const, and arrow functions?

Automated JavaScript code generation avoids modern features like let, const, and arrow functions to ensure maximum compatibility and predictable behavior. Using only var declarations prevents hidden block-level scope complexities during automated script execution.

What are the length limits for generated code snippets to maintain readability?

Generated code snippets must not exceed 3000 characters to maintain readability and prevent overly long outputs. This length limit ensures that automated code generation produces manageable, maintainable fragments instead of bloated scripts.

How should error handling be structured in safe code generation?

Error handling in safe code generation requires wrapping all document operations in try/catch blocks and checking object existence before modification. This approach provides clear error messages and ensures observable string results during exceptions.

What return value format is required for automated code generation outputs?

Automated code generation requires the final line to return a descriptive string. Instead of returning simple text like 'done', the output must provide specific, descriptive return text so the calling application can directly parse the result.

Can I use modern JavaScript class syntax in generated code snippets?

Modern JavaScript class syntax is prohibited in generated code snippets to ensure predictable behavior and compatibility. The safe code generation rules explicitly forbid classes, template literals, and arrow functions to maintain consistent quality.