fixing-rule-violations

oimiragieo's avatarfrom oimiragieo

Provides detailed fix instructions for coding rule violations. Uses the rule index to locate violated rules and extract fix patterns. Use when code violates rules or when the user asks how to fix compliance issues.

⭐1stars🔀0forks📁View on GitHub🕐Updated Jan 11, 2026

When & Why to Use This Skill

The Fixing Rule Violations skill streamlines the remediation of coding standard breaches by providing precise, actionable fix instructions. It leverages a centralized rule index to identify violations and generates step-by-step code transformations, ensuring project compliance and consistent code quality across the development lifecycle.

Use Cases

  • Automated Remediation: Quickly resolve violations flagged by rule auditors or linters with precise, context-aware code changes.
  • Compliance Enforcement: Ensure codebases adhere to security, performance, or architectural standards by following guided fix patterns and 'before/after' examples.
  • Developer Onboarding: Help new team members learn and apply project-specific coding conventions through real-time feedback and fix instructions.
  • Legacy Code Refactoring: Systematically update older code segments to meet modern compliance and style requirements using the rule index mapping.
namefixing-rule-violations
descriptionProvides detailed fix instructions for coding rule violations. Uses the rule index to locate violated rules and extract fix patterns. Use when code violates rules or when the user asks how to fix compliance issues.
version1.0.0
allowed-toolsread, grep, glob, search, codebase_search, edit, write
Fixing Rule Violations - Provides actionable fix instructions for rule violations by locating violated rules in the index and extracting fix patterns. - Code violates a specific rule - User reports a compliance issue - Rule auditor identifies violations - User asks "How do I fix this rule violation?" - Code review finds standards violations

Step 1: Identify the Violation

Determine what rule was violated:

  • From rule-auditor: Violation report with rule name/path
  • From user: Description of the issue
  • From code: Analyze code to identify which rule applies

Step 2: Load Rule Index

Load the rule index to locate the violated rule:

  • @.claude/context/config/rule-index.json

Step 3: Find Violated Rule

Search the index for the violated rule:

  • By name: Search rules array for matching name
  • By path: If path is known, find rule with matching path
  • By technology: Query technology_map if rule type is known

Step 4: Load Rule File

Load the full rule file to get fix instructions:

  • Read the rule file from the path in the index
  • Extract sections related to the violation
  • Find fix patterns and examples

Step 5: Extract Fix Instructions

From the rule file, extract:

  • What's wrong: The violation pattern
  • Why it's wrong: Explanation from the rule
  • How to fix: Specific fix instructions
  • Example: Before/after code examples

See reference/fix-patterns.md for common fix patterns.

Step 6: Generate Fix Instructions

Provide actionable fix with:

  • Exact code changes: Show before/after
  • Step-by-step: Break down complex fixes
  • Context: Explain why the fix works
  • Verification: How to verify the fix
  1. Be Specific: Provide exact code changes, not vague suggestions
  2. Show Examples: Always include before/after code
  3. Explain Why: Help user understand the fix
  4. Step-by-Step: Break complex fixes into clear steps
  5. Verify: Include verification steps
**Output Format**

Structure fix instructions clearly:

## Fix for [Rule Name] Violation

**Violated Rule**: [rule name]
**Rule Path**: [path from index]
**Violation Location**: [file:line]

### The Problem

[Description of what's wrong]

### Why This Violates the Rule

[Explanation from rule file]

### How to Fix

**Step 1**: [Action]
\`\`\`[language]
[Code showing fix]
\`\`\`

**Step 2**: [Action]
\`\`\`[language]
[Code showing fix]
\`\`\`

### Before and After

**Before** (violates rule):
\`\`\`[language]
[violating code]
\`\`\`

**After** (compliant):
\`\`\`[language]
[fixed code]
\`\`\`

### Verification

[How to verify the fix works]
**Common Violation Types**:

TypeScript Violations:

  • Using any instead of proper types
  • Missing type annotations
  • Incorrect interface definitions

React/Next.js Violations:

  • Missing 'use client' directive
  • Using useEffect for data fetching
  • Not using Server Components when possible

Python Violations:

  • Missing type hints
  • Not using async/await properly
  • Incorrect error handling

Code Quality Violations:

  • Magic numbers
  • Unclear variable names
  • Missing error handling

For each type, see fix-patterns.md for standard fixes.