GuideOpen

skill-rules.json - Complete Reference

Complete schema and configuration reference for .claude/skills/skill-rules.json.

skill-rules.json - Complete Reference

Complete schema and configuration reference for .claude/skills/skill-rules.json.

Table of Contents

  • [File Location](#file-location)
  • [Complete TypeScript Schema](#complete-typescript-schema)
  • [Field Guide](#field-guide)
  • [Example: Guardrail Skill](#example-guardrail-skill)
  • [Example: Domain Skill](#example-domain-skill)
  • [Validation](#validation)

File Location

Path: .claude/skills/skill-rules.json

This JSON file defines all skills and their trigger conditions for the auto-activation system.


Complete TypeScript Schema

interface SkillRules {
    version: string;
    skills: Record<string, SkillRule>;
}

interface SkillRule {
    type: 'guardrail' | 'domain';
    enforcement: 'block' | 'suggest' | 'warn';
    priority: 'critical' | 'high' | 'medium' | 'low';

    promptTriggers?: {
        keywords?: string[];
        intentPatterns?: string[];  // Regex strings
    };

    fileTriggers?: {
        pathPatterns: string[];     // Glob patterns
        pathExclusions?: string[];  // Glob patterns
        contentPatterns?: string[]; // Regex strings
        createOnly?: boolean;       // Only trigger on file creation
    };

    blockMessage?: string;  // For guardrails, {file_path} placeholder

    skipConditions?: {
        sessionSkillUsed?: boolean;      // Skip if used in session
        fileMarkers?: string[];          // e.g., ["@skip-validation"]
        envOverride?: string;            // e.g., "SKIP_DB_VERIFICATION"
    };
}

Field Guide

Top Level

FieldTypeRequiredDescription
versionstringYesSchema version (currently "1.0")
skillsobjectYesMap of skill name → SkillRule

SkillRule Fields

FieldTypeRequiredDescription
typestringYes"guardrail" (enforced) or "domain" (advisory)
enforcementstringYes"block" (PreToolUse), "suggest" (UserPromptSubmit), or "warn"
prioritystringYes"critical", "high", "medium", or "low"
promptTriggersobjectOptionalTriggers for UserPromptSubmit hook
fileTriggersobjectOptionalTriggers for PreToolUse hook
blockMessagestringOptional*Required if enforcement="block". Use {file_path} placeholder
skipConditionsobjectOptionalEscape hatches and session tracking

*Required for guardrails

promptTriggers Fields

FieldTypeRequiredDescription
keywordsstring[]OptionalExact substring matches (case-insensitive)
intentPatternsstring[]OptionalRegex patterns for intent detection

fileTriggers Fields

FieldTypeRequiredDescription
pathPatternsstring[]Yes*Glob patterns for file paths
pathExclusionsstring[]OptionalGlob patterns to exclude (e.g., test files)
contentPatternsstring[]OptionalRegex patterns to match file content
createOnlybooleanOptionalOnly trigger when creating new files

*Required if fileTriggers is present

skipConditions Fields

FieldTypeRequiredDescription
sessionSkillUsedbooleanOptionalSkip if skill already used this session
fileMarkersstring[]OptionalSkip if file contains comment marker
envOverridestringOptionalEnvironment variable name to disable skill

Example: Guardrail Skill

Complete example of a blocking guardrail skill with all features:

{
  "database-verification": {
    "type": "guardrail",
    "enforcement": "block",
    "priority": "critical",

    "promptTriggers": {
      "keywords": [
        "prisma",
        "database",
        "table",
        "column",
        "schema",
        "query",
        "migration"
      ],
      "intentPatterns": [
        "(add|create|implement).*?(user|login|auth|tracking|feature)",
        "(modify|update|change).*?(table|column|schema|field)",
        "database.*?(change|update|modify|migration)"
      ]
    },

    "fileTriggers": {
      "pathPatterns": [
        "**/schema.prisma",
        "**/migrations/**/*.sql",
        "database/src/**/*.ts",
        "form/src/**/*.ts",
        "email/src/**/*.ts",
        "users/src/**/*.ts",
        "projects/src/**/*.ts",
        "utilities/src/**/*.ts"
      ],
      "pathExclusions": [
        "**/*.test.ts",
        "**/*.spec.ts"
      ],
      "contentPatterns": [
        "import.*[Pp]risma",
        "PrismaService",
        "prisma\\.",
        "\\.findMany\\(",
        "\\.findUnique\\(",
        "\\.findFirst\\(",
        "\\.create\\(",
        "\\.createMany\\(",
        "\\.update\\(",
        "\\.updateMany\\(",
        "\\.upsert\\(",
        "\\.delete\\(",
        "\\.deleteMany\\("
      ]
    },

    "blockMessage": "āš ļø BLOCKED - Database Operation Detected\n\nšŸ“‹ REQUIRED ACTION:\n1. Use Skill tool: 'database-verification'\n2. Verify ALL table and column names against schema\n3. Check database structure with DESCRIBE commands\n4. Then retry this edit\n\nReason: Prevent column name errors in Prisma queries\nFile: {file_path}\n\nšŸ’” TIP: Add '// @skip-validation' comment to skip future checks",

    "skipConditions": {
      "sessionSkillUsed": true,
      "fileMarkers": [
        "@skip-validation"
      ],
      "envOverride": "SKIP_DB_VERIFICATION"
    }
  }
}

Key Points for Guardrails

  1. type: Must be "guardrail"
  2. enforcement: Must be "block"
  3. priority: Usually "critical" or "high"
  4. blockMessage: Required, clear actionable steps
  5. skipConditions: Session tracking prevents repeated nagging
  6. fileTriggers: Usually has both path and content patterns
  7. contentPatterns: Catch actual usage of technology

Example: Domain Skill

Complete example of a suggestion-based domain skill:

{
  "project-catalog-developer": {
    "type": "domain",
    "enforcement": "suggest",
    "priority": "high",

    "promptTriggers": {
      "keywords": [
        "layout",
        "layout system",
        "grid",
        "grid layout",
        "toolbar",
        "column",
        "cell editor",
        "cell renderer",
        "submission",
        "submissions",
        "blog dashboard",
        "datagrid",
        "data grid",
        "CustomToolbar",
        "GridLayoutDialog",
        "useGridLayout",
        "auto-save",
        "column order",
        "column width",
        "filter",
        "sort"
      ],
      "intentPatterns": [
        "(how does|how do|explain|what is|describe).*?(layout|grid|toolbar|column|submission|catalog)",
        "(add|create|modify|change).*?(toolbar|column|cell|editor|renderer)",
        "blog dashboard.*?"
      ]
    },

    "fileTriggers": {
      "pathPatterns": [
        "frontend/src/features/submissions/**/*.tsx",
        "frontend/src/features/submissions/**/*.ts"
      ],
      "pathExclusions": [
        "**/*.test.tsx",
        "**/*.test.ts"
      ]
    }
  }
}

Key Points for Domain Skills

  1. type: Must be "domain"
  2. enforcement: Usually "suggest"
  3. priority: "high" or "medium"
  4. blockMessage: Not needed (doesn't block)
  5. skipConditions: Optional (less critical)
  6. promptTriggers: Usually has extensive keywords
  7. fileTriggers: May have only path patterns (content less important)

Validation

Check JSON Syntax

cat .claude/skills/skill-rules.json | jq .

If valid, jq will pretty-print the JSON. If invalid, it will show the error.

Common JSON Errors

Trailing comma:

{
  "keywords": ["one", "two",]  // āŒ Trailing comma
}

Missing quotes:

{
  type: "guardrail"  // āŒ Missing quotes on key
}

Single quotes (invalid JSON):

{
  'type': 'guardrail'  // āŒ Must use double quotes
}

Validation Checklist

  • [ ] JSON syntax valid (use jq)
  • [ ] All skill names match SKILL.md filenames
  • [ ] Guardrails have blockMessage
  • [ ] Block messages use {file_path} placeholder
  • [ ] Intent patterns are valid regex (test on regex101.com)
  • [ ] File path patterns use correct glob syntax
  • [ ] Content patterns escape special characters
  • [ ] Priority matches enforcement level
  • [ ] No duplicate skill names

Related Files:

  • [SKILL.md](SKILL.md) - Main skill guide
  • [TRIGGER_TYPES.md](TRIGGER_TYPES.md) - Complete trigger documentation
  • [TROUBLESHOOTING.md](TROUBLESHOOTING.md) - Debugging configuration issues

Source: https://github.com/davila7/claude-code-templates/blob/main/cli-tool/components/skills/productivity/skill-developer/SKILL_RULES_REFERENCE.md

Author: davila7, Claude Code templates (davila7). License: MIT.

Shown here with formatting for the web. Keep the author and license notice when you reuse it.

Related entries

There are more like this in the members library

The Claude Code library holds 13,843 entries. Members can search all of them by meaning and read every one in full.