enforced-in-code

Automate recurring rule violations into hooks, permissions, and lint rules.

Updated May 29, 2026
One-click install
npx skills add https://github.com/Thedougler/shattered-sea-wiki --skill enforced-in-code-thedougler
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: enforced-in-code
Source: https://github.com/Thedougler/shattered-sea-wiki/tree/main/.claude/skills/enforced-in-code
Command: npx skills add https://github.com/Thedougler/shattered-sea-wiki --skill enforced-in-code-thedougler

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? When an AI agent keeps making the same mistake or a convention is violated repeatedly, reminding it in prompts wastes tokens and still fails. This Skill provides a decision framework for fixing recurring problems permanently by pushing enforcement down to the lowest layer that can catch it mechanically. ## Core Features & Use Cases - Enforcement Stack Decision Flowchart: A graph-based decision tree that routes each problem to the right layer — permissions.deny, PreToolUse hooks, PostToolUse hooks, lint rules, path-scoped rules, CLAUDE.md, or skills. - Implementation Patterns: Ready-to-use templates for adding permission denies, blocking PreToolUse hooks (exit 2), corrective PostToolUse hooks, sea lint rules, and path-scoped rules in .claude/rules/. - Use Case: If agents keep writing YAML block scalars in frontmatter summaries, the Skill guides you to add normalization to an existing PostToolUse fix script instead of adding another prompt reminder. ## Quick Start Ask the agent to enforce a recurring convention violation permanently using the enforced-in-code decision flowchart.

Frequently Asked Questions about enforced-in-code

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

FAQPage Schema
How do I stop an AI agent from repeating the same mistake?▼

Identify whether the violation is mechanically detectable with regex or file checks, then enforce it at the lowest layer: permissions.deny for blocking tool patterns, a PreToolUse hook for custom blocking logic, or a PostToolUse hook for silent auto-correction.

When should I use a PreToolUse hook versus a PostToolUse hook?▼

Use a PreToolUse hook with exit code 2 when the action must be blocked before it happens, such as rejecting edits to sensitive files. Use a PostToolUse hook when the content is acceptable but needs automatic correction after every write, like frontmatter normalization.

What is the difference between CLAUDE.md rules and path-scoped rules?▼

CLAUDE.md loads every turn and costs tokens on all work, so it suits universal behavioral guidance. Path-scoped rules in .claude/rules/ with a paths frontmatter field load only when the agent accesses matching files, costing nothing otherwise.

Can every recurring problem be automated with hooks or lint rules?▼

No. Problems requiring judgment, like prose quality, cannot be fully automated. The recommended approach is to split the problem: automate mechanical symptoms with hooks or lint checks, and guide the judgment portion with the cheapest applicable rule layer.

When should I not automate a fix?▼

Avoid automation for one-off problems, rapidly evolving standards still being figured out, and cross-file semantic checks that require understanding relationships across many files. Those belong in batch lint runs or temporary guidance until they stabilize.