DEV Community

Paul Duvall
Paul Duvall

Posted on • Originally published at paulmduvall.com

Sharing AI Development Rules Across Your Organization

Originally published on paulmduvall.com


How centralized-rules achieved 74.4% token savings and consistent AI behavior with progressive disclosure and context-aware rule loading.

Every developer on your team likely has their own AI rules file. One person's CLAUDE.md says "always write tests." Another's says "use TypeScript strict mode." A third developer just copies whatever worked on their last project. Meanwhile, your AI coding assistants—Claude Code, Cursor, GitHub Copilot, Gemini—are getting inconsistent instructions across every project and every person.

This is the AI rules governance problem, and at scale, it's costing you tokens, consistency, and quality. A central CLAUDE.md file can help, but it quickly bloats when you try to cover every scenario—and worse, it can't be specific to your particular environment or project. The AI may not even read all of it.

I built centralized-rules to solve it, based on the centralized-rules pattern I've been experimenting with. After two months of using this approach in my own work, the result: 74.4% token savings and consistent AI behavior that scales across teams.

The Enterprise AI Rules Problem

AI coding tools are now common across development teams. But each tool needs configuration to perform well—Claude Code uses CLAUDE.md and .claude/ directories, Cursor uses .cursorrules, and other tools have their own configuration patterns.

Without centralization, you get:

  • Tribal knowledge: Best practices live in individual developers' heads (and their personal config files)
  • Copy-paste chaos: Teams share rules via Slack, and they drift immediately
  • Onboarding friction: New developers spend days figuring out "how we do AI here"
  • Token waste: Loading all rules when you only need a subset for your specific context

With hundreds of developers across teams, this becomes ungovernable. You can't audit what instructions your AI tools are receiving. You can't ensure security rules are consistently applied. You can't measure whether your AI development standards are actually being followed.

The Solution: Centralized Rules with Progressive Disclosure

The core insight is simple: one source of truth, versioned in Git, with context-aware loading.

Instead of every developer maintaining their own rules, you maintain a single repository of AI development rules. But here's the key—you don't load all of them all the time. That would overwhelm the AI and waste tokens.

Instead, the system uses progressive disclosure—a technique that loads only relevant rules based on context:

  1. Detect context: Scan the project for language markers (package.json, pyproject.toml, go.mod)
  2. Match keywords: Analyze the prompt for task-specific terms (test, security, refactor)
  3. Display banner: Show which rules apply to the current task
  4. Apply rules: AI follows only the relevant coding standards

The rules themselves are organized in a four-dimensional structure:

  • Base: Universal rules that apply to all projects (git workflow, code quality, security principles)
  • Language: Language-specific rules (Python, TypeScript, Go, Java, C#, Rust)
  • Framework: Framework-specific rules (React, Django, FastAPI, Express, Spring Boot)
  • Cloud: Cloud provider rules (AWS, Vercel, with Azure and GCP extensible)

This follows the MECE principle (Mutually Exclusive, Collectively Exhaustive)—no duplication across dimensions, complete coverage of common scenarios.

How It Works

The install script auto-detects your project configuration:

# Language detection
pyproject.toml → Load Python rules
package.json → Load JavaScript/TypeScript rules
go.mod → Load Go rules

# Framework detection
"fastapi" in dependencies → Load FastAPI rules
"react" in dependencies → Load React rules

# Cloud detection
vercel.json → Load Vercel rules
Enter fullscreen mode Exit fullscreen mode

Token Efficiency

Here's the measured impact across different task types:

Task Type Files Loaded Tokens Used Tokens Saved Savings
Code Review 2 files 3,440 21,796 86.4%
Write Tests 2 files 11,163 14,073 55.8%
FastAPI Endpoint 3 files 8,608 16,628 65.9%
Git Commit 2 files 2,618 22,618 89.6%
Average 2.25 files 6,457 18,779 74.4%

Quick Start

Installation is one command, and it's idempotent (safe to run multiple times):

# Global installation (all projects)
curl -fsSL https://raw.githubusercontent.com/paulduvall/centralized-rules/main/install-hooks.sh | bash

# Project-specific installation
curl -fsSL https://raw.githubusercontent.com/paulduvall/centralized-rules/main/install-hooks.sh | bash -s -- --local
Enter fullscreen mode Exit fullscreen mode

Get Started

The repository is open source under MIT license: github.com/PaulDuvall/centralized-rules

Star it, try it, and let me know any changes you'd like to see.


Read the original and more at paulmduvall.com

Top comments (0)