levels/L1-context/library/ — Reference standards to enforce
levels/L3-enforcement/hooks/ — Hook configurations for integration
1---2name: enforcement-agent3description: Build a project-specific standards enforcement agent4---56# Enforcement Agent Skill78Create an agent that automatically checks code changes against documented standards in real-time.910## Context1112An enforcement agent runs automatically before/after code edits to verify compliance. Unlike ceremonies (which are human-driven reviews), enforcement agents provide instant feedback while you're writing code.1314## Domain Context1516The Standards Enforcer Agent checks code against standards and reports violations with specific fixes. It reads:17181. Changed files (from git diff or provided list)192. Applies a file-to-standards mapping203. Reads applicable standards214. Checks code against each rule225. Reports violations with severity and fixes2324Reference: `levels/L3-enforcement/agents/standards-enforcer.md`2526## Instructions27281. **Define file-to-standards mapping** — Which files trigger which standards?29 - Create a mapping table: File Pattern → Applicable Standards30 - Example:31 ```32 *.ts, *.tsx → docs/standards/engineering/typescript.md33 src/api/** → docs/standards/engineering/api-design.md34 *.md → docs/standards/quality/documentation.md35 ```36 - Be specific about patterns (use glob format)37 - One file pattern can map to multiple standards38 - Deliverable: Complete file-to-standards mapping39402. **Set severity levels** — Categorize violations by impact41 - **ERROR** — Blocks merge, violates security or core principles42 - **WARN** — Should be fixed, degrades maintainability/accessibility43 - **INFO** — Nice to fix, style/preference44 - For each standard rule, determine its severity45 - Document why: "ERROR because of security implication"46 - Deliverable: Standards with severity levels assigned47483. **Write output format** — How should violations be reported?49 - Standard format (see reference):50 ```51 [SEVERITY] file:line52 Rule: standard#section53 Expected: [what rule requires]54 Found: [what code does]55 Fix: [concrete code example]56 ```57 - Deliverable: Output format template58594. **Integrate with PR workflow** — Where does enforcement happen?60 - **Option A:** Pre-hook (before tool use) — Catches obvious violations early61 - **Option B:** Post-hook (after tool use) — Catches complex violations after code written62 - **Option C:** As explicit command — User runs `/enforce` to check63 - Choose based on team preferences (balance between helpfulness and interruption)64 - Deliverable: Decision on integration point65665. **Test with examples** — Verify agent works correctly67 - Create 3-5 test scenarios: compliant code, code with WARNING, code with ERROR68 - Run agent on test scenarios69 - Verify: Correct violations detected, severity assigned correctly, fixes are actionable70 - Deliverable: Test results showing agent works as expected71726. **Document [CUSTOMIZE] markers** — Make agent reusable across projects73 - Standard names that will change between projects: [CUSTOMIZE]74 - File paths that are project-specific: [CUSTOMIZE]75 - Severity levels that might differ: [CUSTOMIZE]76 - Deliverable: Agent definition with [CUSTOMIZE] markers for portability7778## Anti-Patterns79801. **Hardcoding rules instead of reading standards** — Fragile enforcement81 - Wrong: Agent has rule logic embedded in code: `if (hasAnyType) { error() }`82 - Right: Agent reads standard file and extracts rules dynamically83 - Impact: When standard updates, agent is out of sync84 - Guard: Agent should always reference standard files, not embed rules85862. **Overly strict enforcement blocking productivity** — Team disables agent87 - Wrong: Agent blocks on style issues (indentation, comment length)88 - Right: Agent blocks on substantive issues (security, architecture violations)89 - Impact: Team disables agent because it's too noisy90 - Guard: Discuss with team: which violations should ERROR vs WARN vs INFO?91923. **False positives from ambiguous standards** — Creates noise93 - Happens when: Standard rule is vague and can be interpreted multiple ways94 - Example: "Code should be clean" → no clear violation95 - Guard: Only enforce standards with specific, measurable rules96 - If you can't code it as a check, it's too vague to enforce97984. **Agent doesn't cite the standard** — User can't understand violation99 - Wrong: "Remove any type" (no citation)100 - Right: "Remove any type (see docs/standards/engineering/typescript.md#Type Safety)"101 - Impact: User doesn't know why violation matters102 - Guard: Every violation message must include standard file + section name103104## Further Reading105106- `levels/L3-enforcement/agents/standards-enforcer.md` — Reference agent definition107- `levels/L1-context/library/` — Reference standards to enforce108- `levels/L3-enforcement/hooks/` — Hook configurations for integration
Run npx skillmds@latest add sethdford/enforcement-agent in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
Build a project-specific standards enforcement agent It is listed under AI & ML on SkillMD.
This skill has not completed SkillMD's automated safety review yet. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
sethdford (@sethdford) published this skill. Their other Agent Skills are listed on their SkillMD profile.