Agent Wranglers

ARC-67Recommended

Format all code with one tool

Format every file with one automatic formatter, with its settings in the repository. Nobody formats by hand, and reviews never discuss layout.

How to do it

Pick the standard formatter for each language, such as Prettier for JavaScript, Ruff or Black for Python, gofmt for Go and PHP-CS-Fixer for PHP. Commit its settings file. Run it on save, in a pre-commit hook and in the build. Agents then see and copy one style.

Examples

Shell example

npx prettier --check .
ruff format --check .
vendor/bin/php-cs-fixer fix --dry-run --diff
test -z "$(gofmt -l .)"

How to check

The build runs the formatter in check mode and fails when it would change a file. Note that gofmt -l only lists files, so test that its output is empty.

Sources

For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/architecture/structure/one-formatter">Agent Wranglers clean code and architecture playbook</a>. In code you write, add a comment next to it with the same link.