Token导航 LogoToken导航TokenDH.com
前端设计只读github未标认证来源可访问clear审计通过

data-policies数据政策

Agent Skill

用于辅助前端页面、组件、样式和交互逻辑的开发与维护。它适合让 Agent 生成或审查 React、Next.js、Vue、Tailwind、CSS 等相关代码,整理组件结构,或定位布局和性能问题。使用时需要结合项目现有设计系统、路由和构建方式,避免只生成孤立片段;涉及页面改动时,应配合本地预览和构建检查确认视觉效果。

总安装

1,296

周安装

54

GitHub Stars

63

下载量

432
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

3

许可证

MIT

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:data-policies(数据政策)
来源仓库:https://github.com/groeimetai/snow-flow
仓库路径:skills/data-policies
安装命令:
npx skills add https://github.com/groeimetai/snow-flow --skill data-policies
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。不同来源提供的安装方式可能略有差异;本站展示可直接复制的安装命令,安装前请核对来源页面。

skills.shnpx skills
npx skills add https://github.com/groeimetai/snow-flow --skill data-policies

简介

针对 ServiceNow 平台的数据政策与字典管理系统,控制字段行为。

  • 通过 sys_dictionary 定义字段属性,sys_data_policy2 实施完整性规则。
  • 支持条件化字段行为和依赖字段管理,确保数据一致性。
  • 需谨慎配置规则优先级,避免不同策略间的冲突覆盖。
  • data-policies 属于前端设计类 Skill,可作为该场景下的辅助能力补充。

SKILL.md

Data Policies & Dictionary for ServiceNow

Data Policies enforce data integrity rules. Dictionary controls schema and field behavior.

Architecture

Dictionary (sys_dictionary)
    ├── Field Definition
    │   ├── Type, Length, Default
    │   └── Dependent Field
    └── Dictionary Overrides (sys_dictionary_override)

Data Policy (sys_data_policy2)
    └── Data Policy Rules (sys_data_policy_rule)
        └── Condition-based field behaviors

Key Tables

TablePurpose
sys_dictionaryField definitions
sys_dictionary_overrideScoped overrides
sys_data_policy2Data policies
sys_data_policy_rulePolicy rules
sys_db_objectTable definitions

Dictionary Management (ES5)

Create Table

// Create custom table (ES5 ONLY!)
var table = new GlideRecord("sys_db_object")
table.initialize()

table.setValue("name", "u_custom_table")
table.setValue("label", "Custom Table")
table.setValue("super_class", "task") // Extends task
table.setValue("is_extendable", true)
table.setValue("create_access_controls", true)
table.setValue("live_feed_enabled", false)

table.insert()

Create Field

// Create field on table (ES5 ONLY!)
var field = new GlideRecord("sys_dictionary")
field.initialize()

// Table and element
field.setValue("name", "u_custom_table")
field.setValue("element", "u_customer_name")

// Field properties
field.setValue("column_label", "Customer Name")
field.setValue("internal_type", "string")
field.setValue("max_length", 100)
field.setValue("mandatory", false)
field.setValue("read_only", false)
field.setValue("display", false)
field.setValue("active", true)

// Default value
field.setValue("default_value", "")

// Reference field specific
// field.setValue('reference', 'customer_account');
// field.setValue('reference_qual', 'active=true');

field.insert()

Field Types

// Common field types
var FIELD_TYPES = {
  STRING: "string",
  INTEGER: "integer",
  DECIMAL: "decimal",
  BOOLEAN: "boolean",
  GLIDE_DATE: "glide_date",
  GLIDE_DATE_TIME: "glide_date_time",
  REFERENCE: "reference",
  CHOICE: "choice",
  JOURNAL: "journal",
  JOURNAL_INPUT: "journal_input",
  HTML: "html",
  URL: "url",
  EMAIL: "email",
  SCRIPT: "script",
  CONDITIONS: "conditions",
}

// Create different field types (ES5 ONLY!)
function createField(tableName, fieldDef) {
  var field = new GlideRecord("sys_dictionary")
  field.initialize()
  field.setValue("name", tableName)
  field.setValue("element", fieldDef.name)
  field.setValue("column_label", fieldDef.label)
  field.setValue("internal_type", fieldDef.type)

  if (fieldDef.maxLength) {
    field.setValue("max_length", fieldDef.maxLength)
  }

  if (fieldDef.reference) {
    field.setValue("reference", fieldDef.reference)
  }

  if (fieldDef.choices) {
    field.setValue("choice", 1) // Has choices
  }

  return field.insert()
}

Create Choices

// Create choice list values (ES5 ONLY!)
function createChoices(tableName, fieldName, choices) {
  for (var i = 0; i < choices.length; i++) {
    var choice = new GlideRecord("sys_choice")
    choice.initialize()
    choice.setValue("name", tableName)
    choice.setValue("element", fieldName)
    choice.setValue("value", choices[i].value)
    choice.setValue("label", choices[i].label)
    choice.setValue("sequence", (i + 1) * 10)
    choice.setValue("inactive", false)
    choice.insert()
  }
}

// Usage
createChoices("incident", "u_custom_status", [
  { value: "pending", label: "Pending Review" },
  { value: "approved", label: "Approved" },
  { value: "rejected", label: "Rejected" },
])

Dictionary Overrides (ES5)

Create Override

// Create dictionary override for scoped app (ES5 ONLY!)
var override = new GlideRecord("sys_dictionary_override")
override.initialize()

// Reference the base field
override.setValue("base_table", "task")
override.setValue("base_element", "short_description")

// Target table
override.setValue("name", "u_custom_table")

// Override properties
override.setValue("column_label", "Request Summary")
override.setValue("mandatory", true)
override.setValue("read_only", false)
override.setValue("max_length", 200)

// Default value override
override.setValue("default_value", "")

override.insert()

Data Policies (ES5)

Create Data Policy

// Create data policy (ES5 ONLY!)
var policy = new GlideRecord("sys_data_policy2")
policy.initialize()

policy.setValue("model_table", "incident")
policy.setValue("short_description", "Resolution Fields Required on Resolve")
policy.setValue("active", true)

// Conditions - when policy applies
policy.setValue("conditions", "state=6") // Resolved state

// Apply to forms
policy.setValue("apply_to_client", true)
policy.setValue("apply_to_import_sets", true)
policy.setValue("apply_to_soap", true)

// Reverse
policy.setValue("reverse_if_false", true)

var policySysId = policy.insert()

// Add policy rules
addDataPolicyRule(policySysId, "resolution_code", true, false, false)
addDataPolicyRule(policySysId, "close_notes", true, false, false)

Add Policy Rules

// Add data policy rule (ES5 ONLY!)
function addDataPolicyRule(policySysId, fieldName, mandatory, readOnly, hidden) {
  var rule = new GlideRecord("sys_data_policy_rule")
  rule.initialize()
  rule.setValue("sys_data_policy", policySysId)
  rule.setValue("field", fieldName)
  rule.setValue("mandatory", mandatory)
  rule.setValue("read_only", readOnly)
  rule.setValue("visible", !hidden)
  return rule.insert()
}

Complex Data Policy

// Data policy with scripted condition (ES5 ONLY!)
var policy = new GlideRecord("sys_data_policy2")
policy.initialize()

policy.setValue("model_table", "change_request")
policy.setValue("short_description", "High Risk Change Requirements")
policy.setValue("active", true)

// Use scripted condition for complex logic
policy.setValue("use_as_condition", true)
policy.setValue(
  "script",
  "(function checkCondition(current) {\n" +
    "    // High risk changes require additional fields\n" +
    '    if (current.risk == "high") {\n' +
    "        return true;\n" +
    "    }\n" +
    "    \n" +
    "    // Also apply to changes affecting critical CIs\n" +
    "    if (current.cmdb_ci) {\n" +
    "        var ci = current.cmdb_ci.getRefRecord();\n" +
    '        if (ci.business_criticality == "1 - most critical") {\n' +
    "            return true;\n" +
    "        }\n" +
    "    }\n" +
    "    \n" +
    "    return false;\n" +
    "})(current);",
)

var policySysId = policy.insert()

// Require additional documentation for high risk
addDataPolicyRule(policySysId, "implementation_plan", true, false, false)
addDataPolicyRule(policySysId, "backout_plan", true, false, false)
addDataPolicyRule(policySysId, "test_plan", true, false, false)
addDataPolicyRule(policySysId, "justification", true, false, false)

Field Validation (ES5)

Dictionary Attribute Validation

// Add validation to dictionary field (ES5 ONLY!)
var field = new GlideRecord("sys_dictionary")
if (field.get("name", "incident").get("element", "u_email")) {
  // Add regex validation
  field.setValue("attributes", "validate=email")
  field.update()
}

// Common validation attributes
var VALIDATION_ATTRIBUTES = {
  EMAIL: "validate=email",
  PHONE: "validate=phone_number",
  URL: "validate=url",
  CUSTOM: "validate=script", // Uses script in Calculated Value
}

Script Validation

// Calculated field with validation (ES5 ONLY!)
// Set in Dictionary > Calculated Value

// Check phone format
;(function calculate() {
  var phone = current.getValue("u_phone")
  if (!phone) return ""

  // Format validation
  var phonePattern = /^\+?[1-9]\d{1,14}$/
  if (!phonePattern.test(phone.replace(/[\s\-\(\)]/g, ""))) {
    gs.addErrorMessage("Invalid phone number format")
    return ""
  }

  return phone
})()

Schema Queries (ES5)

Get Table Fields

// Get all fields for a table (ES5 ONLY!)
function getTableFields(tableName) {
  var fields = []

  var dict = new GlideRecord("sys_dictionary")
  dict.addQuery("name", tableName)
  dict.addQuery("internal_type", "!=", "collection")
  dict.addQuery("active", true)
  dict.orderBy("element")
  dict.query()

  while (dict.next()) {
    fields.push({
      name: dict.getValue("element"),
      label: dict.getValue("column_label"),
      type: dict.getValue("internal_type"),
      mandatory: dict.getValue("mandatory") === "true",
      reference: dict.getValue("reference"),
      maxLength: dict.getValue("max_length"),
    })
  }

  return fields
}

Check Field Exists

// Check if field exists on table (ES5 ONLY!)
function fieldExists(tableName, fieldName) {
  var dict = new GlideRecord("sys_dictionary")
  dict.addQuery("name", tableName)
  dict.addQuery("element", fieldName)
  dict.query()
  return dict.hasNext()
}

MCP Tool Integration

Available Tools

ToolPurpose
snow_query_tableQuery dictionary
snow_discover_table_fieldsGet field definitions
snow_execute_script_with_outputTest dictionary scripts
snow_find_artifactFind data policies

Example Workflow

// 1. Get table fields
await snow_discover_table_fields({
  table_name: "incident",
})

// 2. Query data policies
await snow_query_table({
  table: "sys_data_policy2",
  query: "model_table=incident^active=true",
  fields: "short_description,conditions,apply_to_client",
})

// 3. Check dictionary overrides
await snow_query_table({
  table: "sys_dictionary_override",
  query: "name=u_custom_table",
  fields: "base_element,column_label,mandatory,read_only",
})

Best Practices

  1. Schema Planning - Design before implementation
  2. Field Naming - u_ prefix for custom fields
  3. Data Types - Use appropriate types
  4. Mandatory Fields - Only when truly required
  5. Data Policies - Enforce business rules
  6. Performance - Avoid complex calculated fields
  7. Documentation - Document custom schema
  8. ES5 Only - No modern JavaScript syntax

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

04

需要参考平台分布和安装热度时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

补充不同宿主或平台的使用分布数据

能力 5

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Claude Code

31.37%
按下载量换算136

Gemini CLI

22.71%
按下载量换算98

Antigravity

17.89%
按下载量换算77

windsurf

12.98%
按下载量换算56

Codex

7.55%
按下载量换算33

OpenCode

3.54%
按下载量换算15

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

只读

该 Skill 主要提供规则、说明或参考内容,本身偏只读;真正读写文件、联网或执行命令仍取决于宿主 Agent 的任务。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。

来源信息

继续浏览同类 Skills