jonpurvis/lawman
Lawman adds automatic validation to Laravel Eloquent models. Define validation rules directly on a model and have them enforced before saving, helping keep model data consistent without repeating validation logic across your app.
Lawman generates a Markdown "context" file that describes your Laravel application's structure — models, relationships, controllers, routes, commands and so on — so an AI assistant (Claude Code, Cursor, Copilot) can reason about your codebase without crawling it every time. It is a development tool, not a runtime dependency.
composer require jonpurvis/lawman --dev
php artisan vendor:publish --tag="lawman-config"
php artisan lawman:generate
Look first at config/lawman.php — it controls which sections are emitted and where the output lands. Everything you'll want to tune lives there.
First use case: run the command once on an existing app, skim the generated Markdown to confirm it captured the pieces you care about, then point your AI tool at it (e.g. reference it from CLAUDE.md, .cursor/rules, or paste it into a fresh chat). The immediate win is that you stop re-explaining "we use action classes, money is stored in minor units, Order has a state machine" in every session.
Commit the generated file, regenerate deliberately. Treat it like documentation, not a build artifact. Regenerating on every save produces noisy diffs and burns tokens re-reading unchanged sections. A good rhythm is: regenerate at the start of a feature branch, commit alongside the work, and let reviewers see the architectural delta.
Regenerate as a Composer script. Wire it to something explicit rather than automatic:
"scripts": {
"lawman": ["@php artisan lawman:generate"]
}
Then composer lawman after pulling a branch with structural changes. Avoid post-install-cmd — it fires in CI and on every deploy for no benefit.
Scope the config per project. For a large app the default output is enormous. Trim sections you don't need an assistant to know about (e.g. drop migrations once the schema is stable, keep models and routes). The signal-to-noise ratio of the file is the single biggest lever on how useful it is.
Layer project-specific conventions on top. The generated structure tells an assistant what exists; it doesn't tell it how you work. Keep a hand-written CLAUDE.md / conventions doc next to the generated file and reference both — Lawman for the map, your own notes for the rules.
Use it in a modular/monorepo setup by running the generator once per application directory rather than trying to produce one giant file, and keep each output next to the app it describes.
For onboarding, the same file doubles as a genuinely readable architecture summary for a new hire — one of the cheaper wins from adopting the package.
require-dev. There's no reason for this to be installed in production; a --no-dev deploy will then simply not have it.config/lawman.php. If you've ever run php artisan config:cache locally, config edits appear to do nothing. This is the most common "it's broken" report.composer.json. Helpers and output formatting are the parts most likely to shift between minor releases; a floating constraint means your committed file changes shape on a composer update and the diff looks like architecture churn..gitignore. The package may or may not ship an ignore entry for the output path — decide intentionally rather than discovering it in a PR.How can I help you explore Laravel packages today?