This is a personal tool I built for my own projects. It's public in case others find it useful, but it's tailored to my specific coding standards and workflow.
A Laravel package for enforcing code commandments through prophets who judge and absolve transgressions.
composer require --dev jessegall/code-commandmentsPublish the configuration file:
php artisan vendor:publish --tag=commandments-config| Technical Term | Biblical Term |
|---|---|
| Violation | Sin / Transgression |
| Fix/Auto-fix | Repent / Absolution |
| Warning | Prophecy |
| Validator | Prophet |
| Validator class | [Name]Prophet |
| Validators folder | Prophets/ |
| Pass | Righteous / Blessed |
| Fail | Sinful / Fallen |
| Review | Confession |
| Mark as reviewed | Absolve |
| Groups | Scrolls |
# Judge all scrolls
php artisan commandments:judge
# Judge a specific scroll
php artisan commandments:judge --scroll=backend
# Judge with a specific prophet
php artisan commandments:judge --prophet=NoRawRequest
# Judge a specific file
php artisan commandments:judge --file=app/Http/Controllers/UserController.php
# Judge multiple specific files (comma-separated)
php artisan commandments:judge --files=app/Models/User.php,app/Services/AuthService.php
# Mark files as absolved after manual review
php artisan commandments:judge --absolve# Auto-fix all sins that can be absolved
php artisan commandments:repent
# Preview what would be fixed
php artisan commandments:repent --dry-run
# Fix a specific file
php artisan commandments:repent --file=app/Http/Controllers/UserController.php
# Fix multiple specific files (comma-separated)
php artisan commandments:repent --files=app/Models/User.php,app/Services/AuthService.php# List all prophets
php artisan commandments:scripture
# List with detailed descriptions
php artisan commandments:scripture --detailed
# List prophets from a specific scroll
php artisan commandments:scripture --scroll=frontend# Create a new backend prophet
php artisan make:prophet NoMagicNumbers --scroll=backend
# Create a new frontend prophet
php artisan make:prophet NoInlineStyles --scroll=frontend --type=frontend
# Create a prophet that can auto-fix
php artisan make:prophet NoUnusedImports --repentable
# Create a prophet that requires manual review
php artisan make:prophet ComplexLogicReview --confessionInstall hooks to automatically judge your code when using Claude Code:
php artisan commandments:install-hooksThis will:
- Show the scripture (commandments) when starting a Claude Code session
- Run the judge command after Claude completes work
- Distinguish between sins (must fix) and warnings (review and absolve)
Configure your scrolls in config/commandments.php:
return [
'scrolls' => [
'backend' => [
'path' => app_path(),
'extensions' => ['php'],
'exclude' => ['Console/Kernel.php'],
'thresholds' => [
'max_method_lines' => 15,
'max_private_methods' => 3, // For ControllerPrivateMethodsProphet
'min_method_lines' => 3, // Minimum lines for a method to count
],
'prophets' => [
\JesseGall\CodeCommandments\Prophets\Backend\NoRawRequestProphet::class,
// Add more prophets...
],
],
'frontend' => [
'path' => resource_path('js'),
'extensions' => ['vue', 'ts', 'js'],
'thresholds' => [
'max_vue_lines' => 200,
],
'prophets' => [
\JesseGall\CodeCommandments\Prophets\Frontend\CompositionApiProphet::class,
// Add more prophets...
],
],
],
'confession' => [
'tablet_path' => storage_path('commandments/confessions.json'),
],
];- NoRawRequestProphet - Thou shalt not access raw request data
- NoJsonResponseProphet - Thou shalt not return raw JSON responses
- NoHasMethodInControllerProphet - Thou shalt not use has() in controllers
- NoEventDispatchProphet - Thou shalt use event() helper for dispatching
- NoRecordThatOutsideAggregateProphet - Thou shalt not use recordThat() outside aggregates
- NoValidatedMethodProphet - Thou shalt not use validated() method
- NoInlineValidationProphet - Thou shalt not use inline validation
- TypeScriptAttributeProphet - Thou shalt use #[TypeScript] on Resources
- ReadonlyDataPropertiesProphet - Thou shalt not declare readonly properties in Data class body
- FormRequestTypedGettersProphet - Thou shalt use typed getters in FormRequest
- HiddenAttributeProphet - Thou shalt hide sensitive model attributes
- NoCustomFromModelProphet - Thou shalt not use custom fromModel methods
- ControllerPrivateMethodsProphet - Thou shalt not have too many private methods in controllers
- KebabCaseRoutesProphet - Thou shalt use kebab-case for route URIs
- ConstructorDependencyInjectionProphet - Thou shalt inject dependencies via constructor
- NoFetchAxiosProphet - Thou shalt not use fetch() or axios directly
- TemplateVForProphet - Thou shalt wrap v-for in template elements
- TemplateVIfProphet - Thou shalt wrap v-if/v-else in template elements
- RouterHardcodedUrlsProphet - Thou shalt not hardcode URLs in router calls
- WayfinderRoutesProphet - Thou shalt not hardcode URLs in href attributes
- CompositionApiProphet - Thou shalt use Composition API
- ArrowFunctionAssignmentsProphet - Thou shalt use const arrow functions
- SwitchCaseProphet - Thou shalt not use switch statements
- LongVueFilesProphet - Thou shalt keep Vue files concise
- LongTsFilesProphet - Thou shalt keep TypeScript files concise
- RepeatingPatternsProphet - Thou shalt not repeat template patterns
- ScriptFirstProphet - Thou shalt put script before template
- PropsTypeScriptProphet - Thou shalt type props with TypeScript
- EmitsTypeScriptProphet - Thou shalt type emits with TypeScript
- InlineEmitTransformProphet - Thou shalt not transform data in emit handlers
- InlineTypeCastingProphet - Thou shalt not type cast in templates
- WatchIfPatternProphet - Thou shalt not use watch with if conditions
- PageDataAccessProphet - Thou shalt use typed page props
- DeepNestingProphet - Thou shalt not deeply nest template elements
- StyleOverridesProphet - Thou shalt not override child component styles
- ExplicitDefaultSlotProphet - Thou shalt use explicit default slots
- MultipleSlotDefinitionsProphet - Thou shalt type slots with defineSlots
- ConditionalArrayBuildingProphet - Consider disabled flags pattern for array building
- SwitchCheckboxVModelProphet - Thou shalt use v-model on Switch/Checkbox
- LoopsWithIndexedStateProphet - Review indexed state in loops (requires confession)
- ContentLikePropsProphet - Review content-like props (requires confession)
- InlineDialogProphet - Review inline dialog definitions (requires confession)
<?php
namespace App\Prophets\Backend;
use JesseGall\CodeCommandments\Commandments\PhpCommandment;
use JesseGall\CodeCommandments\Results\Judgment;
class NoMagicNumbersProphet extends PhpCommandment
{
public function description(): string
{
return 'Thou shalt not use magic numbers';
}
public function detailedDescription(): string
{
return 'Magic numbers should be extracted to named constants...';
}
public function judge(string $filePath, string $content): Judgment
{
$ast = $this->parse($content);
if ($ast === null) {
return $this->skip('Unable to parse PHP file');
}
// Your judgment logic here...
return $this->righteous();
}
}For Vue and TypeScript auto-fixing, install the Node.js dependencies:
cd vendor/jessegall/code-commandments/node
npm install./vendor/bin/phpunitMIT License