domain
product-code
type
reference
status
todo
owner
<!-- team/role that owns code conventions -->
last_reviewed
This document defines the code style and formatting conventions for this project. Consistency matters more than any individual rule, when in doubt, follow existing patterns in the codebase.
# Check for style errors
# Auto-fix formatting
All checks must pass before a PR can be merged. The CI pipeline enforces this automatically, see operations/concept/ci-cd-pipeline .
Clarity over cleverness : write code for the next reader, not only the compiler
Explicit over implicit : avoid magic; name things for what they do
Small functions : each function should do one thing
No dead code : remove commented-out code before committing
Element
Convention
Example
Files
snake_case
http_server.go
Packages
short, lowercase, no underscores
httputil
Exported identifiers
PascalCase
UserService
Unexported identifiers
camelCase
getUserByID
Constants
PascalCase or camelCase, grouped in a const block
MaxRetryCount
Element
Convention
Example
Files / modules
snake_case
user_service.rs
Types, traits, enums
PascalCase
UserService
Functions, variables
snake_case
get_user_by_id
Constants, statics
SCREAMING_SNAKE_CASE
MAX_RETRY_COUNT
Macros
snake_case!
vec!
Element
Convention
Example
Files
snake_case
user_service.c
Functions
snake_case
get_user_by_id
Types (structs, typedefs)
snake_case with _t suffix
user_t
Constants, macros
SCREAMING_SNAKE_CASE
MAX_RETRY_COUNT
Global variables
snake_case, g_ prefix optional
g_active_count
Element
Convention
Example
Files
snake_case
user_service.cpp
Classes, structs
PascalCase
UserService
Methods, functions
camelCase
getUserById
Member variables
camelCase_ (trailing underscore)
retryCount_
Constants
kPascalCase
kMaxRetryCount
Element
Convention
Example
Files
kebab-case
user-service.ts
Classes
PascalCase
UserService
Functions, methods
camelCase
getUserById
Constants
UPPER_SNAKE_CASE
MAX_RETRY_COUNT
Private members
#prefixed or _prefixed
#cache
Element
Convention
Example
Files
snake_case
user_service.ml
Modules
PascalCase
UserService
Values, functions
snake_case
get_user_by_id
Constructors, variants
PascalCase
UserNotFound
Type names
snake_case
user_id
Element
Convention
Example
Files / modules
snake_case
user_service.py
Classes
PascalCase
UserService
Functions, variables
snake_case
get_user_by_id
Constants
UPPER_SNAKE_CASE
MAX_RETRY_COUNT
"Private" members
_prefixed
_cache
Element
Convention
Example
Files
PascalCase, matching the public class name
UserService.java
Classes, interfaces
PascalCase
UserService
Methods, variables
camelCase
getUserById
Constants
UPPER_SNAKE_CASE (static final)
MAX_RETRY_COUNT
Packages
all-lowercase, dot-separated
com.example.userservice
Element
Convention
Example
Files
PascalCase, matching the class name
UserService.cs
Classes, methods, properties
PascalCase
GetUserById
Local variables, parameters
camelCase
retryCount
Constants
PascalCase
MaxRetryCount
Private fields
_camelCase
_cache
Indentation : X spaces (no tabs)
Max line length : 100 characters
Trailing commas : yes / no
Quotes : single / double
Import / Dependency Order
Standard library / built-ins
Third-party packages
Internal packages / modules
Relative imports
Separate each group with a blank line.
Never swallow errors silently, log or propagate
Use typed/structured errors where the language supports it
Validate inputs at system boundaries; trust internal code
Tests live next to the code they test, or in a dedicated tests/ directory
Each test should be independent and not rely on shared mutable state
Test names should describe the expected behavior: should return 404 when user not found
Running the Full Validation Suite
# Replace with your actual commands
# Lint
# Type-check (if applicable)
# Tests
# Build
All four must pass before pushing.