with one click
sentinel-rule
Create or edit a Sentinel rule through guided conversation
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
Menu
Create or edit a Sentinel rule through guided conversation
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
Based on SOC occupation classification
| name | sentinel-rule |
| description | Create or edit a Sentinel rule through guided conversation |
| user-invocable | true |
Create a new Sentinel rule through guided conversation. Understand what the user wants to protect, ask clarifying questions, draft the rule, get approval, write it.
Check that .claude/sentinel/rules/ exists. If not, tell the user to run /sentinel-init first and stop.
Rules are YAML files in .claude/sentinel/rules/. Each rule has these fields:
id: rule-name # unique identifier (defaults to filename stem)
trigger: file_write # file_write | bash | mcp | any
severity: block # block (deny) | warn (allow + warning) | info (context only)
scope: # glob patterns — rule fires if any match
- "src/core/billing/**"
exclude: # glob patterns — exempt even if scope matches
- "**/*.test.ts"
backend: "claude" # optional per-rule backend override (ollama|claude|copilot)
model: "gemma3:12b" # optional per-rule model override
post: true # (info only) opt-in to PostToolUse LLM synthesis
prompt: | # evaluation prompt with {{template_vars}}
CONTEXT: {{action_summary}}
RULE: ...
Respond ONLY with JSON: {"violation": true/false, "confidence": 0.0-1.0, "reason": "one line"}
severity: info rules provide contextual advice to the agent without blocking or warning. Two modes:
PreToolUse static — the prompt field is rendered with template variables and returned directly as additionalContext. No LLM call, zero latency.
id: payments-ownership
trigger: file_write
severity: info
scope:
- "src/payments/**"
prompt: |
This directory is owned by the Payments team.
Changes require review from @payments-team.
Slack: #payments-eng
PostToolUse synthesized — add post: true to opt the rule into PostToolUse evaluation. The LLM receives session context + tool output + domain knowledge and responds with {"context": "..."}.
id: migration-awareness
trigger: file_write
severity: info
post: true
scope:
- "**/migrations/**"
prompt: |
DOMAIN KNOWLEDGE: This codebase uses a payments microservice.
- OpenAPI spec at api/v2/openapi.yaml must reflect DB changes
- CHANGELOG.md must be updated for any migration
Based on the session context and the tool action,
provide a brief, relevant contextual reminder.
Respond with JSON: {"context": "your message (max 80 words)"}
New template variables available in PostToolUse rules:
{{tool_output}} — the tool's response/result{{session_context}} — the accumulator's latest rolling summary of the sessionfile_write (Write, Edit, NotebookEdit):
{{file_path}} — target file path{{content_snippet}} — first N chars of content{{content_length}} — total content lengthbash (Bash):
{{command}} — the full command stringmcp (MCP tools like mcp__server__tool):
{{server_name}} — MCP server name{{mcp_tool}} — MCP tool name{{mcp_arguments}} — arguments JSON (truncated)server:tool, tool, or serverAll triggers also have:
{{action_summary}} — human-readable action description{{tool_name}} — raw Claude Code tool name{{trigger}} — normalized trigger typeseverity: warn. Promote to block after verifying precision via telemetry.block/warn rules: Respond ONLY with JSON: {"violation": true/false, "confidence": 0.0-1.0, "reason": "one line"}. For info rules with post: true: Respond with JSON: {"context": "your message (max 80 words)"}.block rules prevent the agent from acting — accuracy matters more than speed. Use a larger model (e.g., model: "gemma3:12b") for block rules that evaluate content semantically (secrets, PII, SQL safety). Leave warn rules and simple pattern rules on the default small model for speed.info for context, not enforcement. Info rules provide knowledge that helps the agent make better decisions. Use for ownership info, related-file reminders, policy awareness. Add post: true when the advice needs to consider what the tool actually did.Read the example rules in ${CLAUDE_PLUGIN_ROOT}/examples/ for real-world patterns covering file_write, bash, and mcp triggers.
Ask the user one question: "What do you want to protect or prevent?"
Listen for: what kind of action (file write, command, MCP call), what area of the codebase, what specific behavior to catch, and why it matters.
Ask 2-4 targeted follow-up questions, one at a time. Focus on:
warn. Use info for ownership info, related-file reminders, or policy awareness that should never block.Do not ask about prompt template details. Keep it focused. If the user picks severity: block and the rule evaluates content semantically (not just file paths), recommend either model: "gemma3:12b" (Ollama, ~2x latency) or backend: "claude" with model: "haiku" (cloud, higher accuracy) and explain the tradeoff.
Generate the complete rule YAML. For the prompt field:
Present the full YAML to the user and ask: "Does this look right?"
On approval, write the rule to .claude/sentinel/rules/<rule-id>.yaml.
The rule-id should be a kebab-case slug derived from the rule's purpose (e.g., billing-protection, no-force-push, mcp-prod-guard).
If the user wants changes, revise and present again. Only write after explicit approval.
After the rule is written, suggest these to the user:
/sentinel-stats — monitor this rule's performance after it fires (requires log_file in config)/sentinel-rule — create another rule to protect a different concern/sentinel-config — tune model, thresholds, or timeouts if neededView or update Sentinel configuration
Scaffold Sentinel config and rules directory in the current repository, installing prerequisites if needed
Show Sentinel telemetry stats — rule performance, latency, violations, and hottest targets
Dismiss a draft Sentinel rule and prevent re-proposal
List pending draft Sentinel rules with provenance
Scan documentation files for conventions and generate draft Sentinel rules