Pretty Code enforces consistent code formatting across all your projects automatically on commit. It provides a single source of truth for Prettier and Laravel Pint configurations, designed for Roots Bedrock + Sage and Statamic projects.
- Requirements
- Installation & Setup
- Commands
- Updating
- PHP Formatting
- Supported File Types
- Configuration Files
- Customization per Project
- Troubleshooting
- Uninstalling
- Environments: OSX, Linux, WSL, Windows
- Node 20+
- PHP 8.1+ (for PHP formatting)
npm install --save-dev @lform/pretty-codeAfter installing, the package prints a reminder to run the init command.
npx pretty-code initRun the init command to scaffold the project. It copies the following config files to the project root, configures git hooks, and adds pretty:format, pretty:format:prettier, pretty:format:pint, and pretty:check scripts to package.json:
.prettierrc.json,.prettierignore.lintstagedrc.json.editorconfig.githooks/pint.json
Existing config files are overwritten — use git diff to review changes before committing. Pass --suggest to write new configs as suggestion files alongside your existing ones instead. In --suggest mode, Pretty Code does not update your git hooks path or rewrite package.json scripts:
npx pretty-code init --suggestThis writes:
.lintstagedrc.suggestions.json.prettierrc.suggestions.json.prettierignore.suggestions.editorconfig.suggestionspint.suggestions.json.githooks.suggestions/
# Run all formatters
npm run pretty:format
# Prettier only — JS, CSS, HTML, Blade, Antlers, JSON, YAML, etc.
npm run pretty:format:prettier
# Pint only — PHP files
npm run pretty:format:pint
# Check formatting without writing (useful in CI)
npm run pretty:checkWhen a new version of Pretty Code is released, update the package then run:
npm update @lform/pretty-code
npx pretty-code updateThis overwrites your config files with the latest package versions. Use git diff to review and selectively revert any changes you want to keep. Pass --suggest to write updated configs as .suggestions.* files instead:
npx pretty-code update --suggestLaravel Pint is the recommended PHP formatter and is included by default in both Roots Bedrock + Sage and Statamic — no separate install needed for those projects. The pint.json config file is copied to your project root during init.
For projects that cannot use Laravel Pint, a .php-cs-fixer.php baseline configuration is included in the package as a reference. To use it:
- Install PHP CS Fixer:
composer require --dev friendsofphp/php-cs-fixer- Copy the baseline config to your project root:
cp node_modules/@lform/pretty-code/.php-cs-fixer.php .php-cs-fixer.php- Update
.lintstagedrc.jsonto replace the Pint rule with PHP CS Fixer:
"*.php": "vendor/bin/php-cs-fixer fix"- Update the
pretty:format:pintscript inpackage.json:
"pretty:format:pint": "vendor/bin/php-cs-fixer fix"| Extension | Tool |
|---|---|
php |
Pint |
blade.php |
Prettier |
antlers.html, antlers.php |
Prettier |
js, jsx, ts, tsx |
Prettier |
css, scss, pcss |
Prettier |
html, htm |
Prettier |
json |
Prettier |
yaml, yml |
Prettier |
| File | Description |
|---|---|
.prettierrc.json |
Prettier configuration |
.prettierignore |
Files excluded from Prettier |
.lintstagedrc.json |
Pre-commit hook rules |
.editorconfig |
Editor-wide formatting defaults |
.githooks/ |
Git hook scripts |
pint.json |
Laravel Pint configuration |
.php-cs-fixer.php |
PHP CS Fixer baseline (reference — copy manually if needed) |
To customize formatting for a specific project, copy the relevant config file from node_modules/@lform/pretty-code/ to the project root and modify it as needed. Only copy what you need — copied files will no longer receive updates from the package manager.
To undo a customization, delete the project-level config file and it will fall back to the package default.
If you need to disable or re-enable the automated pre-commit hook:
# Disable:
git config core.hooksPath ".git/hooks"
# Re-enable:
git config core.hooksPath ".githooks"- Delete any config files copied to the project root
- Delete the
.githooksdirectory - Run
git config core.hooksPath .git/hooks - Run
npm remove @lform/pretty-code - Remove the
pretty:format,pretty:format:prettier,pretty:format:pint, andpretty:checkscripts frompackage.json

