بنقرة واحدة
ordine-create-rule
Use when 需要在 Ordine 系统中创建 Rule(自定义检查规则),定义检查脚本、严重级别和适用对象类型。触发词:创建规则、新建rule、添加检查规则、自定义lint规则。
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Use when 需要在 Ordine 系统中创建 Rule(自定义检查规则),定义检查脚本、严重级别和适用对象类型。触发词:创建规则、新建rule、添加检查规则、自定义lint规则。
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
Use when 需要了解 Ordine 系统的整体架构和快速上手指南,包括核心概念、实体关系、CLI 和 API 使用方法。触发词:ordine入门、快速开始、ordine是什么、系统架构、ordine overview。
Use when 需要通过 Ordine 浏览项目文件系统,列出目录内容或获取递归目录树。触发词:浏览文件、查看目录、文件系统浏览、目录树、browse filesystem。
Use when Pipeline 运行失败或结果异常,需要读取 Job 的 Trace 日志、分析错误原因并给出修复建议。触发词:browse traces、job失败、排查运行失败、trace日志、pipeline报错、job error。
Use when 需要在 Ordine 系统中创建新的 Best Practice(最佳实践),包含条件、内容、代码片段和检查清单条目。触发词:创建最佳实践、新建bestpractice、添加编码规范、添加实践规范。
Use when 需要在 Ordine 系统中创建新的 Operation(原子操作),定义执行器(skill/script)、输入输出和接受的对象类型。触发词:创建操作、新建operation、添加检查操作、添加修复操作。
Use when 需要在 Ordine 系统中创建新的 Pipeline(质量检查流水线),包括定义节点(folder/operation/output)和边(连接关系),通过 REST API 或 UI 完成。触发词:创建流水线、新建pipeline、设计工作流、构建检查流程。
| name | ordine-create-rule |
| description | Use when 需要在 Ordine 系统中创建 Rule(自定义检查规则),定义检查脚本、严重级别和适用对象类型。触发词:创建规则、新建rule、添加检查规则、自定义lint规则。 |
Rule 是 Ordine 中的自定义检查规则,包含可执行的检查脚本(checkScript),能够对代码进行自动化验证。
CLI 当前不直接支持 Rule CRUD。使用 REST API 操作。
# 列出所有规则
curl -s http://localhost:9433/api/rules | python3 -m json.tool
# 按分类过滤
curl -s "http://localhost:9433/api/rules?category=naming" | python3 -m json.tool
# 按启用状态过滤
curl -s "http://localhost:9433/api/rules?enabled=true" | python3 -m json.tool
# 查看单个
curl -s http://localhost:9433/api/rules/rule_xxx | python3 -m json.tool
# 创建
curl -X POST http://localhost:9433/api/rules \
-H "Content-Type: application/json" \
-d '{
"id": "rule_no_template_classname",
"name": "禁止模板字符串 className",
"description": "检查是否存在 className 使用模板字符串而非 cn() 的情况",
"category": "style",
"severity": "warning",
"checkScript": "grep -rn \"className={\`\" --include=\"*.tsx\" --include=\"*.jsx\" $TARGET_PATH",
"scriptLanguage": "bash",
"acceptedObjectTypes": ["folder", "code-file"],
"enabled": true,
"tags": ["classname", "style", "react"]
}'
# 更新(PUT = upsert)
curl -X PUT http://localhost:9433/api/rules \
-H "Content-Type: application/json" \
-d '{ "id": "rule_no_template_classname", "severity": "error" }'
# 部分更新
curl -X PATCH http://localhost:9433/api/rules/rule_no_template_classname \
-H "Content-Type: application/json" \
-d '{ "enabled": false }'
# 删除
curl -X DELETE http://localhost:9433/api/rules/rule_no_template_classname
| 字段 | 类型 | 说明 |
|---|---|---|
id | string | 唯一标识,格式:rule_<描述> |
name | string | 规则名称 |
description | string | null | 规则描述 |
category | RuleCategory | 分类:naming, structure, testing, style, performance, security |
severity | string | null | 严重级别:error, warning, info |
checkScript | string | null | 检查脚本内容 |
scriptLanguage | string | null | 脚本语言:bash, javascript, python |
acceptedObjectTypes | string[] | null | 接受的对象类型 |
enabled | boolean | 是否启用 |
tags | string[] | null | 标签 |
rule_<动作或描述> — 如 rule_no_template_classname, rule_one_component_per_filerule_no_ 开头表示禁止型规则rule_require_ 开头表示强制型规则checkScript 中可使用 $TARGET_PATH 变量代表目标路径:
# bash 示例 — 检查是否有 console.log
grep -rn "console\.log" --include="*.ts" --include="*.tsx" $TARGET_PATH
# bash 示例 — 检查文件命名
find $TARGET_PATH -name "*.tsx" | while read f; do
basename=$(basename "$f" .tsx)
if [[ ! "$basename" =~ ^[A-Z] ]]; then
echo "FAIL: $f — 组件文件名必须大写开头"
fi
done
脚本返回 exit code 0 表示通过,非零表示失败。