GitHub - sahin/ai-rules

14 min read Original article β†—

πŸš€ Sahin Claude Code Rules - The Ultimate Claude Code Framework

Version Status Compliance Framework

Transform Claude Code from a helpful tool into a disciplined, systematic, and highly efficient development partner

Quick Start β€’ 12 Core Rules β€’ Agent Framework β€’ Visual Workflow β€’ Implementation β€’ Connect


🌐 Connect with Sahin

LinkedIn Twitter


πŸ“– Table of Contents

Page 1: Introduction & Why This Framework
Page 2: Quick Start & Setup
Page 3: The 12 Core Rules
Page 4: Visual Workflow Architecture
Page 5: High-ROI Development Strategy
Page 6: Testing-First Methodology
Page 7: Agent Framework
Page 8: Automation & Hooks
Page 9: Dynamic Rule Loading
Page 10: Context Management
Page 11: Quality Gates & Compliance
Page 12: Performance & Metrics
Page 13: Implementation Guide


Page 1: Introduction & Why This Framework

🎯 The Problem with Unstructured Claude Code Usage

Using Claude Code without proper rules leads to:

  • ❌ Immediate Coding: Starts writing code without understanding requirements
  • ❌ Context Loss: Forgets project patterns and conventions mid-task
  • ❌ Inconsistent Style: Different coding approaches in the same codebase
  • ❌ Over-Engineering: Creates unnecessary abstractions and complexity
  • ❌ Test Blindness: Writes code without tests or breaks existing ones

βœ… The Sahin AI Rules Solution

This framework optimizes Claude Code through:

  • βœ… Plan-First Coding: Every feature starts with structured planning
  • βœ… Project-Aware Context: Loads relevant coding standards dynamically
  • βœ… Efficient Solutions: Reuse existing code, minimize new additions
  • βœ… Test-Driven Development: Write tests before implementation
  • βœ… Task Management: TodoWrite tool tracks every coding task
  • βœ… Automated Workflows: Git hooks, test runners, and commit automation
  • βœ… Specialized Agents: AI agents for complex testing and analysis tasks

πŸ“Š Proven Results

Metric Before Claude Code With This Framework Improvement
Code Planning 5% 20% Better architecture
Lines per Feature 200 50 75% less code
Test Coverage 40% 95% Full user flow testing
Visual Regression Manual Automated 100% coverage
Production Bugs 12/week 2/week 83% reduction
Code Reuse 20% 80% 4x improvement
Development Speed Baseline 2.5x 150% faster

Page 2: Quick Start & Setup

πŸš€ Installation (5 Minutes)

# 1. Clone the Repository
git clone https://github.com/sahin/ai-rules.git
cd ai-rules

# 2. Copy to Your Project (Works with Claude Code, Cursor, etc.)
cp -r .claude/rules /your/project/.claude/rules/
cp -r .claude/docs /your/project/.claude/docs/
cp CLAUDE.md /your/project/

# 3. Set Up Hooks for Claude Code (Automated testing & commits)
mkdir -p /your/project/.claude/hooks
cp .claude/hooks/* /your/project/.claude/hooks/ 2>/dev/null || true
chmod +x /your/project/.claude/hooks/*.sh

# 4. Verify Setup for Claude Code
cat /your/project/.claude/rules/manifest.json | jq '.rules | keys'

πŸ“‚ Directory Structure

your-project/
β”œβ”€β”€ CLAUDE.md                         # Configuration for Claude Code
β”œβ”€β”€ .claude/                          # Works with Claude Code, Cursor, etc.
β”‚   β”œβ”€β”€ rules/
β”‚   β”‚   β”œβ”€β”€ _mandatory/              # Always loaded for code quality
β”‚   β”‚   β”œβ”€β”€ core-standards/          # Coding standards
β”‚   β”‚   β”œβ”€β”€ general-policies/        # Technology-specific rules
β”‚   β”‚   β”‚   β”œβ”€β”€ backend/             # Node.js, Python, Go patterns
β”‚   β”‚   β”‚   β”œβ”€β”€ frontend/            # React, Vue, Angular patterns
β”‚   β”‚   β”‚   β”œβ”€β”€ testing/             # Jest, Playwright, Pytest
β”‚   β”‚   β”‚   └── ops/                 # Docker, CI/CD, deployment
β”‚   β”‚   β”œβ”€β”€ agents/                  # Specialized AI agents
β”‚   β”‚   β”œβ”€β”€ testing/                 # Comprehensive testing rules
β”‚   β”‚   └── manifest.json            # Dynamic loading config
β”‚   β”œβ”€β”€ docs/                        # Framework documentation
β”‚   β”œβ”€β”€ hooks/                       # Claude Code automation
β”‚   └── session/                     # Session state for Claude Code

⚑ First Test with Claude Code

Send this message to Claude Code:

"Create an API endpoint for user authentication with tests"

Claude Code will automatically:

  1. Load backend, testing, and security rules
  2. Create a structured implementation plan
  3. Ask for your approval before coding
  4. Write E2E tests first (Playwright/Jest)
  5. Implement minimal code to pass tests
  6. Run tests automatically after changes
  7. Commit with conventional format at session end

Page 3: The 12 Core Rules

🎯 Rule Categories

πŸ”΄ Critical Rules (Always Applied)

Rule 1: Plan-First Enforcement

  • No code without approved plan
  • Structured approach to every task
  • Clear scope definition

Rule 2: High-ROI Development

  • ROI = (Impact Γ— Frequency) / Lines of Code
  • Maximize value, minimize complexity
  • 80% reuse, 20% new code

Rule 3: Testing-First Approach

  • User story β†’ E2E test β†’ Implementation
  • 100% user flow coverage
  • Tests drive development

Rule 4: Circuit Breaker System

  • Stop β†’ Analyze β†’ Plan β†’ Approve β†’ Execute
  • Prevents immediate action
  • Ensures thoughtful approach

🟑 Automation Rules (System Intelligence)

Rule 5: Smart Testing Automation

  • Detect changed files automatically
  • Run only affected tests
  • Cache results for efficiency

Rule 6: Dynamic Rule Loading

  • Keywords trigger specific rules
  • Context-aware guidance
  • Minimize token usage

Rule 7: Auto-Commit Workflow

  • Intelligent commit messages
  • Conventional format
  • Rollback scripts included

Rule 8: Hook Orchestration

  • Pre/post action automation
  • Parallel execution
  • Quality gate enforcement

🟒 Quality Rules (Continuous Improvement)

Rule 9: Quality Gates

  • Multi-stage validation
  • Automated compliance checks
  • Performance monitoring

Rule 10: Session State Management

  • Continuous workflow tracking
  • Progress persistence
  • Context preservation

Rule 11: Error Recovery & Rollback

  • Automatic failure detection
  • Safe rollback mechanisms
  • State restoration

Rule 12: Continuous Improvement

  • Self-learning system
  • Usage pattern analysis
  • Performance optimization

Page 4: Visual Workflow Architecture

Complete System Flow

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                          SAHIN AI RULES WORKFLOW SYSTEM                        β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                                                 β”‚
β”‚  User Request β†’ Analysis β†’ Plan β†’ Approval β†’ Todo β†’ Execute β†’ Test β†’ Commit   β”‚
β”‚       ↓           ↓        ↓        ↓        ↓       ↓        ↓        ↓      β”‚
β”‚   [Natural    [Context] [Task    [User    [Auto   [Code   [Smart   [Auto      β”‚
β”‚    Language]   Rules]   List]    OK/NO]    File]   Gen]   Tests]   Save]      β”‚
β”‚                                                                                 β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Phase 1: Request Analysis & Planning

User Request: "Build login with tests"
            ↓
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚ Keyword Detectionβ”‚
    β”‚ "login" "tests"  β”‚
    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
            ↓
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚ Load Rules:     β”‚
    β”‚ β€’ Auth          β”‚
    β”‚ β€’ Testing       β”‚
    β”‚ β€’ Security      β”‚
    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
            ↓
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚ Create Plan     β”‚
    β”‚ 1. UI Form      β”‚
    β”‚ 2. Auth Logic   β”‚
    β”‚ 3. E2E Tests    β”‚
    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
            ↓
    "Would you like me to proceed?"

Phase 2: Execution Loop

Plan Approved β†’ Generate Todo
        ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Todo Queue:     β”‚
β”‚ β–‘ Login UI      β”‚
β”‚ β–‘ Auth Service  β”‚
β”‚ β–‘ E2E Tests     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
        ↓
For Each Task:
    ↓
Execute β†’ Test β†’ Verify β†’ Mark Complete
    ↓
All Complete β†’ Session Summary

Page 5: High-ROI Development Strategy

The ROI Formula

function calculateROI(feature) {
  const impact = getUserImpactScore();      // 1-10
  const frequency = getUsageFrequency();    // 1-10
  const linesOfCode = estimateLoC();        // number
  
  const roi = (impact * frequency) / linesOfCode;
  
  if (roi > 10) return "πŸš€ DO IMMEDIATELY";
  if (roi > 3)  return "βœ… SCHEDULE SOON";
  if (roi < 3)  return "⏳ DEFER OR REJECT";
}

Decision Matrix

                High Impact              Low Impact
            β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
Low LoC     β”‚     πŸš€ DO FIRST     β”‚    βœ… DO NEXT      β”‚
            β”‚                     β”‚                     β”‚
            β”‚ β€’ User login        β”‚ β€’ UI polish        β”‚
            β”‚ β€’ Critical bugs     β”‚ β€’ Nice-to-haves    β”‚
            β”‚ β€’ Core features     β”‚ β€’ Minor features   β”‚
            └─────────────────────┼──────────────────────
High LoC    β”‚    ⚠️ MINIMIZE      β”‚    ❌ AVOID        β”‚
            β”‚                     β”‚                     β”‚
            β”‚ β€’ Complex features  β”‚ β€’ Over-engineering β”‚
            β”‚ β€’ Must-have only    β”‚ β€’ Premature optim  β”‚
            β”‚ β€’ Break into steps  β”‚ β€’ Scope creep      β”‚
            β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Code Reuse Strategy

Need Feature?
     β”‚
     β–Ό
Can Reuse Existing? ──Yes──→ Use It (0 LoC)
     β”‚No
     β–Ό
Can Extend Existing? ──Yes──→ Extend It (10 LoC)
     β”‚No
     β–Ό
Can Modify Slightly? ──Yes──→ Modify It (30 LoC)
     β”‚No
     β–Ό
Must Create New? ──Yes──→ Minimize It (50+ LoC)

Target: 80% reuse, 15% extend, 5% new

Page 6: Testing-First Methodology

Playwright-First Development

User Story: "As a user, I want to login"
                ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Write E2E Test FIRST                β”‚
β”‚                                     β”‚
β”‚ test('user can login', async () => {β”‚
β”‚   await page.goto('/login');       β”‚
β”‚   await page.fill('#email', ...);  β”‚
β”‚   await page.fill('#password',...);β”‚
β”‚   await page.click('#submit');     β”‚
β”‚   expect(page.url()).toBe('/home');β”‚
β”‚ });                                 β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                ↓
     Test Fails (No Implementation)
                ↓
       Build Minimal Code to Pass
                ↓
         Test Passes β†’ Feature Done

Testing Pyramid

         /\
        /E2E\      ← 70% effort (User flows)
       /------\
      /  API   \   ← 20% effort (Integration)
     /----------\
    /   Unit     \ ← 10% effort (Functions)
   /--------------\

Smart Testing System

# Automatic test detection
Changed: src/auth.service.ts
         ↓
Detected: auth.test.ts, login.e2e.ts
         ↓
Running: 2 tests (5 seconds vs 3 minutes full suite)
         ↓
Results: βœ… All tests passed

Page 7: Agent Framework

πŸ€– Specialized AI Agents

The framework now includes specialized agents for complex tasks:

Agent Types:
  rule-learning:
    purpose: "Learns and documents new patterns from codebase"
    triggers: ["analyze", "learn", "document"]
    capabilities: ["pattern recognition", "rule generation"]
    
  frontend-validation:
    purpose: "Comprehensive frontend testing and validation"
    triggers: ["test", "validate", "frontend"]
    capabilities: ["visual testing", "accessibility", "performance"]
    
  visual-regression:
    purpose: "Visual regression testing for UI components"
    triggers: ["visual", "regression", "ui"]
    capabilities: ["screenshot comparison", "diff analysis"]

Agent Workflow Integration

Complex Task Detected
        ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Agent Selection β”‚
β”‚ Based on Task   β”‚
β”‚ Complexity      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
        ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Specialized     β”‚
β”‚ Agent Execution β”‚
β”‚ with Context    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
        ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Results         β”‚
β”‚ Integration     β”‚
β”‚ Back to Main    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Agent-Enhanced Testing

Frontend Validation Agent:

Capabilities:
  - Visual regression testing
  - Accessibility compliance (WCAG 2.1)
  - Performance benchmarking
  - Cross-browser compatibility
  - Mobile responsiveness
  - SEO optimization checks

Automated Workflows:
  - Pre-commit visual testing
  - Accessibility audit reports
  - Performance regression alerts
  - Browser compatibility matrix

Rule Learning Agent:

Capabilities:
  - Codebase pattern analysis
  - Custom rule generation
  - Best practice documentation
  - Anti-pattern detection
  - Style guide enforcement

Learning Process:
  1. Analyze existing code patterns
  2. Identify common structures
  3. Generate custom rules
  4. Validate with team feedback
  5. Auto-update rule base

Page 8: Automation & Hooks

Hook Integration Points

Hook Trigger Purpose Example
user-prompt-submit Message sent Load rules by keywords "API" β†’ loads api-design.md
pre-tool-use Before tools Validate plan approval Block if no plan
post-tool-use After edit/write Run affected tests Auto-test changes
stop Response complete Auto-commit changes Git commit with message

Hook Workflow Example

# user-prompt-submit.sh
#!/bin/bash
MESSAGE="$1"
KEYWORDS=$(echo "$MESSAGE" | grep -oE 'API|test|React|database')

for KEYWORD in $KEYWORDS; do
  case $KEYWORD in
    "API")
      load_rules "api-design" "security" "testing"
      ;;
    "test")
      load_rules "smart-testing" "playwright"
      ;;
    "React")
      load_rules "react-patterns" "typescript"
      ;;
  esac
done

Auto-Commit Flow

Session End Detected
        ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Git Status      β”‚
β”‚ 5 files changed β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
        ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Generate Messageβ”‚
β”‚ "feat: Add user β”‚
β”‚  authentication"β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
        ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Create Rollback β”‚
β”‚ rollback.sh     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
        ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Commit Changes  β”‚
β”‚ Conventional    β”‚
β”‚ format applied  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Page 9: Dynamic Rule Loading

Keyword-Based Loading System

Foundation Rules (Always Loaded):
  - core-workflow.md      # 5% tokens
  - coding-standards.md   # 3% tokens
  - documentation.md      # 2% tokens
  Total: 10% context usage

Contextual Rules (By Keywords):
  "API":      β†’ api-design.md, security.md      (+8%)
  "React":    β†’ react-patterns.md, typescript.md (+7%)
  "test":     β†’ smart-testing.md, playwright.md  (+6%)
  "database": β†’ schema.md, migrations.md         (+5%)
  "deploy":   β†’ deployment.md, git-workflow.md   (+6%)

Token Optimization Results

Before Optimization:
  All Rules Loaded: 104,676 tokens
  Context Usage: 85%
  Load Time: ~3 seconds

After Optimization:
  Smart Loading: 12,000 tokens (88% reduction)
  Context Usage: 25%
  Load Time: <500ms

Manifest Configuration

{
  "rules": {
    "api-design": {
      "summary": "RESTful API best practices",
      "file": "general-policies/backend/api-design.md",
      "triggers": ["API", "endpoint", "REST", "backend"],
      "dependencies": ["security", "testing"],
      "priority": "high",
      "tokens": 2500
    }
  }
}

Page 10: Context Management

Context Window Optimization

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                  CONTEXT WINDOW STATUS                      β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Used: 45% [β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘] β”‚
β”‚                                                             β”‚
β”‚ Breakdown:                                                 β”‚
β”‚ β€’ Foundation Rules: 10%                                    β”‚
β”‚ β€’ Context Rules: 15%                                       β”‚
β”‚ β€’ Todo File: 5%                                           β”‚
β”‚ β€’ Code Context: 15%                                        β”‚
β”‚ β€’ Available: 55%                                           β”‚
β”‚                                                             β”‚
β”‚ Status: 🟒 Safe to continue                               β”‚
β”‚ Recommendation: Can handle 3 more complex tasks           β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Task Splitting Strategy

Large Feature: "Complete auth system" (90% context)
                    ↓
            Split into Tasks
                    ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Task 1   β”‚  β”‚ Task 2   β”‚  β”‚ Task 3   β”‚
β”‚ Login UI β”‚  β”‚ Auth API β”‚  β”‚ Testing  β”‚
β”‚ 30% ctx  β”‚  β”‚ 35% ctx  β”‚  β”‚ 25% ctx  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Rule: Each task ≀ 70% context for safety margin

Todo File Management

# Tasks: Authentication System
Created: 2024-01-15
Context Budget: 70% per task

## Task Queue

### Task 1: Login UI [30% context]
- [ ] Status: Pending
- **Files**: LoginForm.tsx, styles.css
- **LoC**: ~50
- **ROI**: High (10Γ—10/50 = 2.0)

### Task 2: Auth Service [35% context]
- [ ] Status: Pending
- **Dependencies**: Task 1
- **Files**: auth.service.ts, auth.test.ts
- **LoC**: ~80

Page 11: Quality Gates & Compliance

5-Stage Quality Gate System

Stage 1: Plan Validation
    ↓ Must have clear scope
Stage 2: Code Quality
    ↓ TypeScript, ESLint pass
Stage 3: Test Coverage
    ↓ 80%+ coverage required
Stage 4: Performance Check
    ↓ Response time < 200ms
Stage 5: Security Scan
    ↓ No vulnerabilities
PASSED β†’ Deploy Ready

Compliance Tracking

Session Compliance Report:
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Rule Compliance: 100%              β”‚
β”‚ β€’ Plans Created: 5/5               β”‚
β”‚ β€’ Plans Approved: 5/5              β”‚
β”‚ β€’ Tests Written: 15/15             β”‚
β”‚ β€’ Tests Passed: 15/15              β”‚
β”‚ β€’ Quality Gates: 5/5 passed        β”‚
β”‚ β€’ Auto-commits: 3 successful       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Error Recovery Flow

Error Detected: Test Failure
        ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Capture State   β”‚
β”‚ Save to backup  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
        ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Analyze Error   β”‚
β”‚ Identify cause  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
        ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Auto-Fix or     β”‚
β”‚ Rollback        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
        ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Verify Recovery β”‚
β”‚ Run tests again β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Page 12: Performance & Metrics

System Performance Metrics

Testing Performance:
  Before: 3 minutes (full suite)
  After: 15 seconds (smart selection)
  Improvement: 92% faster

Development Speed:
  Features/Week: 8 β†’ 15 (87% increase)
  Bug Rate: 12/week β†’ 2/week (83% reduction)
  Code Reuse: 20% β†’ 80% (4x improvement)

Quality Metrics:
  Test Coverage: 40% β†’ 95%
  Plan Compliance: 60% β†’ 100%
  First-Time Success: 45% β†’ 90%

Real-Time Dashboard

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    LIVE METRICS DASHBOARD                   β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                             β”‚
β”‚ Current Session:                                           β”‚
β”‚ β€’ Tasks Completed: β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘ 8/10                        β”‚
β”‚ β€’ Tests Passed: β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ 45/45                       β”‚
β”‚ β€’ Context Used: β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘β–‘ 65%                         β”‚
β”‚ β€’ Time Saved: 2.5 hours                                   β”‚
β”‚                                                             β”‚
β”‚ Weekly Stats:                                              β”‚
β”‚ β€’ Features Shipped: 12                                     β”‚
β”‚ β€’ Average LoC/Feature: 45                                  β”‚
β”‚ β€’ ROI Score: 8.7/10                                       β”‚
β”‚                                                             β”‚
β”‚ Quality Score: ⭐⭐⭐⭐⭐ 98/100                            β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Success Mantras

πŸ›‘ "Stop and plan before you code"

Every line of code starts with a plan

πŸ§ͺ "Test what users do, not how code works"

E2E tests validate user success

πŸ“Š "Maximum impact, minimum code"

ROI drives every decision

βœ… "Ship working features, iterate later"

Perfect is the enemy of good


Page 13: Implementation Guide

Complete Setup Checklist

# 1. Initial Setup
β–‘ Copy .claude/rules/ to your project
β–‘ Copy .claude/docs/ to your project  
β–‘ Place CLAUDE.md in project root
β–‘ Set up .claude/hooks directory
β–‘ Make hooks executable

# 2. Configuration
β–‘ Configure .claude/rules/manifest.json
β–‘ Set up smart testing
β–‘ Configure auto-commit
β–‘ Initialize .claude/session tracking

# 3. Validation
β–‘ Test hook execution
β–‘ Verify rule loading from .claude/rules/
β–‘ Check test automation
β–‘ Validate commits work

# 4. Team Training
β–‘ Share .claude/docs/ documentation
β–‘ Run demo session
β–‘ Review first PR
β–‘ Gather feedback

Common Issues & Solutions

Issue Solution Prevention
Rules not loading Check manifest.json paths Validate on setup
Tests not running Verify hook permissions chmod +x hooks/*.sh
Context overflow Use task splitting Monitor context %
Commits failing Check git config Test git access
Slow performance Review rule count Use smart loading

Integration Examples

Claude Code Settings (.claude/settings.json):

{
  "claude.rulesPath": ".claude/rules",
  "claude.docsPath": ".claude/docs",
  "claude.hooksEnabled": true,
  "claude.autoCommit": true,
  "claude.testRunner": "auto-detect",
  "claude.todoTracking": true
}

CI/CD Pipeline:

- name: Run Claude Rules Check
  run: |
    .claude/hooks/validate-compliance.sh
    .claude/hooks/run-quality-gates.sh

Measuring Success

Track these KPIs weekly:

  • Features Completed: Target 10+ per week
  • Average LoC/Feature: Target < 50
  • Code Reuse Rate: Target > 80%
  • Test Coverage: Target > 90%
  • Bug Rate: Target < 2 per week
  • Plan Compliance: Target 100%

Getting Help


🌟 Start Your Transformation Today

Join hundreds of developers who have revolutionized their Claude Code workflow

git clone https://github.com/sahin/ai-rules.git
cd ai-rules && ./install.sh

⭐ Star this repo β€’ πŸ”„ Fork it β€’ πŸ“’ Share it


Built with discipline, tested with rigor, delivered with confidence

Β© 2024 Sahin AI Rules Framework | MIT License

Making Claude Code work the way it should - systematically, efficiently, and reliably