CLAUDE.md for a PHP project
A project file that stops Claude Code rewriting your conventions, reformatting untouched files or inventing a framework you do not use.
# Project
PHP 8.1, no framework. MariaDB via PDO. nginx. Deployed by uploading files - there is no build step.
## Rules
- Make the smallest edit that solves the problem. Do not reformat code you were not asked to change.
- Never introduce a dependency, a package manager or a build step without asking first.
- Follow the conventions already in the file you are editing, even where they differ from your defaults.
- All SQL goes through prepared statements. No string interpolation into queries, ever.
- Escape on output with htmlspecialchars($v, ENT_QUOTES, 'UTF-8'), not on input.
- UTF-8 throughout. Do not add HTML entities, escapes or encoding conversions to text.
## Layout
- config/ - bootstrap, database, shared helpers
- pages/ - one file per route, rendered by the front controller
- api/ - JSON endpoints, each validates permissions itself
- assets/ - plain CSS and JS, no compilation
## When you are done
State which files you changed and why. If you could not finish something, say so plainly instead of leaving a stub that looks complete.Notes from the author
Drop it in the repository root. Claude Code reads it at the start of every session, so it replaces the block of rules most people paste into the first message. Trim it hard, because a long file buries the rules that matter. The no-build-step line saves the most time on projects deployed by FTP.
For information only, not professional advice. You use it at your own risk and we are not liable for any loss or damage. See the disclaimer.
Tagged