Code is read far more often than it is written. Coding standards reduce the effort of reading it: consistent naming, structure and conventions mean anyone on the team, or an AI assistant, can find their way around and change things safely.
The best standards are short, automated wherever possible, and agreed by the people who follow them.
Core practices
- Clear naming
- Names that say what something is or does, in the language of the business domain.
- DRY
- Don't repeat yourself: share logic that represents the same knowledge, but don't merge code that only looks similar.
- KISS
- Keep it simple: the simplest design that meets the need.
- YAGNI
- You aren't gonna need it: don't build for imagined future requirements.
- Small functions
- Functions that do one thing and fit on a screen are easier to test and review.
Error handling and logging
Handle errors explicitly, close to where they can be dealt with, and never swallow them silently. Log with structure and context, such as request IDs, but never log secrets or sensitive personal data. Consistent error formats in APIs make life easier for every consumer.
Testing as a standard
Make tests part of the definition of done: new behaviour comes with tests, and bug fixes come with a test that reproduces the bug. Fast, reliable tests are what make refactoring and AI-assisted changes safe.
Automate the standards
Formatters, linters and static analysis enforce most style rules automatically and end debates in code review. Run them in the editor, in pre-commit hooks and in CI. Reserve human review for design, logic and clarity, which tools can't judge.
Standards for AI-assisted development
Write your key conventions into a repository context file so AI assistants follow them: commands, structure, naming, error handling, and things to avoid. Back them with the same automated checks, so AI-generated code meets the same bar as human code. When the assistant repeats a mistake, add the correction to the file.
Getting agreement
Standards work when the team owns them. Start from an established style guide for your language, discuss only the points that matter to the team, and record decisions briefly with the reason. Revisit them when new tools, such as AI assistants, change how code is written.
Make the standards easy to follow: templates, editor settings and automated fixes do more than any document.
Readability as a team habit
A useful test is whether a new team member could understand a change without asking the author. Code reviews that ask "is this clear?" as well as "is this correct?" build readability into the team's habits over time.
How to put it into practice
- Agree a short coding standard per language, written by the team.
- Adopt a formatter and linter, and run them automatically.
- Add static analysis and security scanning to CI.
- Make tests part of the definition of done.
- Write key conventions into the repository context file for AI assistants.
- Review and update the standard every six months.
Common mistakes
- Long standards documents nobody reads.
- Arguing about formatting in code review instead of automating it.
- Applying DRY so aggressively that unrelated code becomes coupled.
- Letting AI-generated code bypass the usual checks.
How to measure progress
- Share of repositories with automated formatting and linting.
- Review comments about style (should fall to near zero).
- Test coverage of critical code and time to onboard new engineers.
- Repeat review findings, which signal gaps in the standard.