Code Conventions

This project sets up one agreed set of code conventions for all our repositories and enforces it. It covers formatting, naming, structure, complexity, documentation, testing, security, accessibility and more. Conventions are enforced in AI-generated code via hooks, and again at a mandatory merge-request gate for both AI and human contributions. Conventions are rules, not suggestions, but rule exemption is allowed on an approval basis.

Status

Design phase. The vision and architecture are drafted and ready for review. No enforcement tooling is built yet.

Implementation targets the managed GitLab instance planned for early 2027. The current self-hosted GitLab (CE 13.9.4) is not a target. The conventions, shared configs and agent hooks don’t depend on GitLab and can be built before the migration.

Documents

Document What it covers
docs/vision.md The problem, goals and non-goals, principles, scope, mandatory merge requests, the group-by-group rollout, success measures, risks
docs/architecture.md Components, enforcement layers, key flows, the exception model, rollout mechanics, Ultimate vs Premium, tool choices, guarantees and limits
docs/conventions-catalog.md All 19 convention categories with draft rule IDs, enforcement classes, tools and a language coverage matrix

How it works, in brief

  1. One source of truth: this repository will hold the rules, the shared tool configs and the pinned tool versions.
  2. Checks as the agent writes: Claude Code and Codex hooks format and lint each file the agent edits, and block the agent from finishing while violations remain.
  3. Editor and pre-commit: format on save, plus an optional pre-commit check.
  4. Merge gate: merge requests become mandatory. A CI job on the files each MR changes blocks the merge on any violation. GitLab adds this job to every project centrally.
  5. Exceptions are recorded in each repo’s .conventions/ folder and must be approved by a conventions owner. Inline “disable” comments are not accepted.

Documentation site

The Markdown files can be served as a documentation website. README.md is the home page, and files under docs/ keep their paths and relative links. CI builds the site image on every push and deploys it from the default branch.

To preview locally:

docker build -t conventions-docs .
docker run --rm -p 127.0.0.1:3000:3000 conventions-docs

Open http://localhost:3000. Edit the Markdown files and rebuild the image to update the preview.

Fenced mermaid code blocks render as diagrams in the browser. Mermaid 11.12.2 and its diagram modules are bundled in the image and served locally, with no CDN dependency. The Docker build appends site/footer.html to the image’s copies of the Markdown files to load site/mermaid.js. The source documents stay unchanged. If a diagram is invalid, the page shows its source and a rendering error. To upgrade Mermaid, update the pinned version and archive filename in the Dockerfile, then check the diagrams in a local preview.