Automating Code Governance: Moving Beyond CLAUDE.md Instructions

AI Coding Daily////3 min read

Overview

AI coding assistants rely heavily on context files like CLAUDE.md to follow project standards. However, LLMs often overlook text-based instructions in large files. This tutorial explores shifting these rules from passive documentation to active automation using Laravel tools. By offloading linting, type-checking, and architecture validation to the machine, you ensure 100% compliance while saving valuable context window tokens.

Prerequisites

To follow this guide, you should be comfortable with the PHP ecosystem and Laravel framework. Familiarity with Composer for package management and basic knowledge of CI/CD concepts like pre-commit hooks will help you implement these automations effectively.

Automating Code Governance: Moving Beyond CLAUDE.md Instructions
Prompt to Automate Some CLAUDE.md Rules #claudecode

Key Libraries & Tools

  • Laravel Pint: A zero-config PHP code style fixer built on top of PHP-CS-Fixer.
  • Larastan: A wrapper around PHPStan specifically designed to handle Laravel's magic methods and relationships.
  • Pest PHP: A testing framework that includes powerful architectural testing capabilities.

Code Walkthrough

Automating Style with Pint

Instead of asking an AI to "always use curly braces," define these in pint.json. This ensures the rules are enforced every time you run the tool.

{
    "preset": "laravel",
    "rules": {
        "braces": true,
        "no_empty_comment": true,
        "no_unused_imports": true
    }
}

You can trigger this via a pre-commit hook or directly through Claude Code events to fix styling immediately after the AI edits a file.

Enforcing Strict Types with Larastan

Move rules regarding return types and type hints out of your markdown files. Larastan catches missing type hints in relationship methods and method signatures far more reliably than an LLM.

# phpstan.neon
parameters:
    level: 5
    paths:
        - app
    checkMissingIterableValueType: true

Architectural Tests with Pest

Use Pest PHP to prevent developers (and AI) from using forbidden functions or violating folder structures.

// tests/ArchTest.php
arch('globals')
    ->expect(['dd', 'dump', 'ray'])
    ->not->toBeUsed();

arch('app')
    ->expect('App\Models')
    ->toOnlyBeUsedIn('App\Repositories');

Syntax Notes

When configuring pint.json, notice the use of boolean flags to toggle specific PSR standards. In Larastan (and PHPStan), the level parameter is your primary lever for strictness; higher levels require more explicit type definitions.

Practical Examples

By moving 22 lines of text-based rules into these tools, you save roughly 800 tokens per prompt. In a real-world CI/CD pipeline, this setup prevents "style drift" where different AI models might interpret

Topic DensityMention share of the most discussed topics · 14 mentions across 9 distinct topics
Larastan
21%· products
Laravel
14%· products
Pest PHP
14%· products
PHPStan
14%· products
Claude Code
7%· products
Other topics
29%
End of Article
Source video
Automating Code Governance: Moving Beyond CLAUDE.md Instructions

Prompt to Automate Some CLAUDE.md Rules #claudecode

Watch

AI Coding Daily // 1:47

This channel is not for vibe-coders. It's for professional devs who want to use AI as powerful assistant, while still keeping the control of their codebase. My name is Povilas Korop, and I'm passionate about coding with AI. So I started this THIRD YouTube channel, in addition to my other ones Laravel Daily and Filament Daily. You will see a lot of my experiments with AI: I will try new things and share my discoveries along the way.

What they talk about
AI and Agentic Coding News
Who and what they mention most
Laravel
34.8%24
Anthropic
17.4%12
Filament
14.5%10
PHP
11.6%8
3 min read0%
3 min read