governance

Engineering standards and code governance enforcement. Triggers during code review discussions, PR descriptions, commit preparation, and when discussing code quality. Ensures compliance with standards.md and runs audit checks. Trigger phrases include "code review", "review this", "commit", "standards", "compliance", "code quality", "best practices", "before I merge".

allowed_tools: Bash, Read, Grep, Glob

$ 설치

git clone https://github.com/wrsmith108/governance-claude-skill /tmp/governance-claude-skill && cp -r /tmp/governance-claude-skill/skills/governance ~/.claude/skills/governance-claude-skill

// tip: Run this command in your terminal to install the skill


name: governance description: Engineering standards and code governance enforcement. Triggers during code review discussions, PR descriptions, commit preparation, and when discussing code quality. Ensures compliance with standards.md and runs audit checks. Trigger phrases include "code review", "review this", "commit", "standards", "compliance", "code quality", "best practices", "before I merge". allowed-tools:

  • Bash
  • Read
  • Grep
  • Glob

Governance Skill

Enforces engineering standards and code quality policies during development.

Standards Document: docs/architecture/standards.md Governance Documentation: docs/governance/ Audit Script: npm run audit:standards


Quick Start (First-Time Setup)

1. Run Setup Check

# Comprehensive governance setup verification
node .claude/skills/governance/scripts/governance-check.mjs

This checks CLAUDE.md, standards.md, audit script, ADRs, and pre-commit hooks with actionable fix instructions.

2. Understand the Two-Document Model

DocumentPurposeUpdate Frequency
CLAUDE.mdAI operational context (commands, URLs, quick-ref)Frequent
standards.mdEngineering policy (authoritative)Infrequent

Rule: CLAUDE.md defers to standards.md for authoritative definitions.

3. Common Operations

# Check standards compliance
npm run audit:standards

# Typecheck before commit
npm run typecheck && npm run lint && npm run test

# View pre-commit checklist
cat docs/architecture/standards.md | grep -A20 "Pre-Commit Checklist"

When This Skill Activates

During Code Review

When reviewing code or discussing PRs, automatically check:

  1. File length compliance (max 500 lines per file)
  2. Naming conventions match project standards
  3. Test coverage exists for new code
  4. No forbidden patterns (any types, hardcoded secrets)

Before Commits

When helping prepare commits, remind about:

  1. Pre-commit checklist (typecheck, lint, test)
  2. Standards audit (npm run audit:standards)
  3. Commit message format (conventional commits)

Core Standards Quick Reference

Full reference: docs/architecture/standards.md

Code Quality (§1)

StandardRequirementCheck
TypeScriptStrict mode enablednpm run typecheck
No any typesUse unknown for external dataAudit script
Max file length500 linesAudit script
JSDocRequired for public APIsAudit script

Naming Conventions (§1.2)

ElementConventionExample
ComponentsPascalCaseButton.tsx, UserCard.astro
UtilitiescamelCaseuserService.ts
VariablescamelCasegetUserById()
ConstantsSCREAMING_SNAKEconst MAX_RETRIES = 3
DB columnssnake_caseuser_id, created_at
CSS classeskebab-casenav-sidebar

Testing (§2)

LayerTargetFramework (example)
Unit tests90-100%Vitest, Jest, pytest
API routes90-100%Testing framework + supertest
E2E critical paths100%Playwright, Cypress

Workflow (§3)

  • Branching: feature/, fix/, chore/, docs/ prefixes
  • Commits: <type>(scope): <description>
  • Review: All code requires approval before merge

Compliance Check

Run the standards audit before committing:

npm run audit:standards

This checks:

  • TypeScript strict mode
  • No any types in source
  • File length limits (500 lines)
  • JSDoc on exported functions
  • Test files exist
  • Feature flags module exists
  • CLAUDE.md exists
  • ADR directory exists
  • Pre-commit hooks configured

Handling Failures

FailureResolution
File too longSplit into modules (document decision in ADR if significant)
Missing JSDocAdd documentation to exported functions
any type foundReplace with proper type or unknown
Missing testsAdd test coverage for new code

Anti-Patterns vs Correct Patterns

Code Quality

Anti-PatternCorrect PatternWhy
any typeunknown for external dataType safety at runtime boundaries
❌ 600+ line files✅ Split at 500 linesMaintainability, easier review
console.log in production✅ Proper logging or removeSecurity, performance
❌ Hardcoded secrets✅ Environment variablesSecurity best practice

Documentation

Anti-PatternCorrect PatternWhy
❌ Duplicating policy in CLAUDE.md✅ Cross-reference standards.mdSingle source of truth
❌ No JSDoc on public functions✅ JSDoc with @param, @returnsAPI discoverability
❌ Inline comments explaining "what"✅ Comments explaining "why"Code should be self-documenting

Workflow

Anti-PatternCorrect PatternWhy
❌ Committing directly to main✅ Feature branches with PRCode review, CI checks
git push --force to main✅ Never force-push protected branchesHistory integrity
❌ Skipping audit:standards✅ Run before every commitCatch issues early
❌ Merge without review✅ Require approvalQuality gate

Testing

Anti-PatternCorrect PatternWhy
❌ Tests after code✅ TDD or tests alongsideBetter design, coverage
❌ Mocking internal modules✅ Mock only external servicesTest real behavior
❌ Ignoring flaky tests✅ Fix or quarantine immediatelyCI reliability

Pre-Commit Checklist

Before every commit:

[ ] npm run typecheck     # TypeScript compiles
[ ] npm run lint          # Linter passes
[ ] npm run test          # Tests pass
[ ] npm run audit:standards  # Standards compliance
[ ] No console.log statements (use proper logging)
[ ] No hardcoded secrets
[ ] Meaningful commit message

PR Review Checklist

When reviewing or preparing PRs:

CategoryCriteria
CorrectnessDoes it work? Edge cases handled?
SecurityNo secrets, injection vulnerabilities, or auth bypasses
PerformanceNo N+1 queries, unnecessary re-renders, or memory leaks
StyleMatches project conventions, readable, maintainable
TestingTests exist for new functionality
ScopeNo unrelated changes, minimal footprint

PR Description Template

## Summary
[What this PR does in 1-2 sentences]

## Ticket
[PROJECT-XXX](link)

## Changes
- Change 1
- Change 2

## Testing
- [ ] Unit tests added/updated
- [ ] Tested in deploy preview
- [ ] Edge cases considered

## Screenshots (if UI changes)
[Before/After screenshots]

Two-Document Model

This project uses a two-document governance model:

DocumentPurposeLocation
CLAUDE.mdAI operational quick-referenceProject root
standards.mdEngineering policy (authoritative)docs/architecture/
  • CLAUDE.md is optimized for token efficiency — concise commands and context
  • standards.md is optimized for human comprehension — rationale and justifications

Rule: CLAUDE.md defers to standards.md for authoritative definitions using section references (§1.3).


Using This Skill in Other Projects

To replicate this governance model:

  1. Copy the skill:

    cp -r .claude/skills/governance /path/to/new-project/.claude/skills/
    
  2. Copy governance docs:

    cp -r docs/governance /path/to/new-project/docs/
    
  3. Create standards.md using the template at docs/governance/guardrails-template.md

  4. Create audit script using scripts/audit-standards.mjs as a starting point

  5. Add npm script:

    "audit:standards": "node scripts/audit-standards.mjs"
    
  6. Update CLAUDE.md to cross-reference standards.md


Related Documents


Last updated: December 2025 Project-level governance enforcement for Claude Code