Repository conventions: preferences, CLAUDE.md, headers, formatting #1

Closed
UnflavoredMeson/Primal_Plus_Plus
opened 2026-11-24 20:15:46 +00:00 by UnflavoredMeson · 0 comments
Owner

Why

Every later issue writes code under these rules. In the fork they arrived after the port, and a lot of code was reworked to meet them (casts, const, trailing return types, include order). Setting them first means nothing is written twice.

Decided

  • The rules are the fork's Preferences: C++23 only (features clang, GCC and MSVC all support), trailing return types, west const everywhere it fits, ::Foo() for global calls, std:: for C library calls, braces on every body, designated initializers, std::expected for fallible functions (never .value()), no issue numbers in code comments.
  • Formatting is the ufps-based .clang-format with InsertBraces and sorted, grouped includes; .editorconfig for the editors.
  • New files get the two-line Charles Smith MIT header; Arash's headers stay on his files, and a port of one of his files says so on line 3.
  • CLAUDE.md holds what the repo is, how to build, test and run, and the current state. The rules live in .claude/rules/, one file per topic, which Claude Code loads on its own (area files are limited to their folders with paths: frontmatter). Both are shared state between the two machines.
  • .claude/rules/ is the canonical rulebook; the wiki holds the history and the evidence behind each rule. New decisions go into the rule file for their topic.
  • Mechanical commits (a reformat) go in .git-blame-ignore-revs.

Read first

  • Preferences (all of it; it's the rulebook you're about to adopt).
  • README.
  • Arash's files on master for the existing style: Engine/Common/CommonHeaders.h, Engine/Components/Entity.cpp.

Steps

  • 1. Split Preferences into topic files in .claude/rules/ (workflow, cpp-style, error-handling, comments-headers, formatting-lint, architecture, and area files with paths: for ECS/actors, reflection, renderer, ContentTools, editor). Drop what only applied to the fork's history (Avalonia notes, the WPF editor's C# rules beyond "frozen", Gitea, old issue numbers), and keep every code rule.
  • 2. Write CLAUDE.md: what Primal_Plus_Plus is, where things are, how the issues work (milestones, the roadmap issue). Keep it short; the rules are in .claude/rules/.
  • 3. Add .clang-format and .editorconfig from the fork. Run clang-format over a single file you will touch soon and read the diff, so you know what the style does.
  • 4. Add .git-blame-ignore-revs (empty for now) and tell git to use it: git config blame.ignoreRevsFile .git-blame-ignore-revs.
  • 5. Commit.

Done when

  • .claude/rules/, CLAUDE.md, .clang-format, .editorconfig and .git-blame-ignore-revs are committed.
  • You can explain, without looking, why trailing return types and std::expected were chosen.

Claude can help with

  • Splitting Preferences into .claude/rules/: Claude drafts the files and marks what's fork-only; you review and trim.
  • Answering "why is this rule here" from the wiki.

Learn

  • What clang-format's InsertBraces and include categories do.
  • Why std::expected instead of exceptions in an engine built without exceptions on MSVC.
## Why Every later issue writes code under these rules. In the fork they arrived after the port, and a lot of code was reworked to meet them (casts, `const`, trailing return types, include order). Setting them first means nothing is written twice. ## Decided - The rules are the fork's [Preferences](https://forgejo.unflavoredmeson.com/UnflavoredMeson/Primal_Plus_Plus/wiki/Preferences): C++23 only (features clang, GCC and MSVC all support), trailing return types, west `const` everywhere it fits, `::Foo()` for global calls, `std::` for C library calls, braces on every body, designated initializers, `std::expected` for fallible functions (never `.value()`), no issue numbers in code comments. - Formatting is the ufps-based `.clang-format` with `InsertBraces` and sorted, grouped includes; `.editorconfig` for the editors. - New files get the two-line Charles Smith MIT header; Arash's headers stay on his files, and a port of one of his files says so on line 3. - `CLAUDE.md` holds what the repo is, how to build, test and run, and the current state. The rules live in `.claude/rules/`, one file per topic, which Claude Code loads on its own (area files are limited to their folders with `paths:` frontmatter). Both are shared state between the two machines. - `.claude/rules/` is the canonical rulebook; the wiki holds the history and the evidence behind each rule. New decisions go into the rule file for their topic. - Mechanical commits (a reformat) go in `.git-blame-ignore-revs`. ## Read first - [Preferences](https://forgejo.unflavoredmeson.com/UnflavoredMeson/Primal_Plus_Plus/wiki/Preferences) (all of it; it's the rulebook you're about to adopt). - [README](https://forgejo.unflavoredmeson.com/UnflavoredMeson/Primal_Plus_Plus/wiki/README). - Arash's files on `master` for the existing style: `Engine/Common/CommonHeaders.h`, `Engine/Components/Entity.cpp`. ## Steps - [x] 1. Split [Preferences](https://forgejo.unflavoredmeson.com/UnflavoredMeson/Primal_Plus_Plus/wiki/Preferences) into topic files in `.claude/rules/` (workflow, cpp-style, error-handling, comments-headers, formatting-lint, architecture, and area files with `paths:` for ECS/actors, reflection, renderer, ContentTools, editor). Drop what only applied to the fork's history (Avalonia notes, the WPF editor's C# rules beyond "frozen", Gitea, old issue numbers), and keep every code rule. - [x] 2. Write `CLAUDE.md`: what Primal_Plus_Plus is, where things are, how the issues work (milestones, the roadmap issue). Keep it short; the rules are in `.claude/rules/`. - [x] 3. Add `.clang-format` and `.editorconfig` from the fork. Run clang-format over a single file you will touch soon and read the diff, so you know what the style does. - [x] 4. Add `.git-blame-ignore-revs` (empty for now) and tell git to use it: `git config blame.ignoreRevsFile .git-blame-ignore-revs`. - [x] 5. Commit. ## Done when - [x] `.claude/rules/`, `CLAUDE.md`, `.clang-format`, `.editorconfig` and `.git-blame-ignore-revs` are committed. - [x] You can explain, without looking, why trailing return types and `std::expected` were chosen. ## Claude can help with - Splitting Preferences into `.claude/rules/`: Claude drafts the files and marks what's fork-only; you review and trim. - Answering "why is this rule here" from the wiki. ## Learn - What clang-format's `InsertBraces` and include categories do. - Why `std::expected` instead of exceptions in an engine built without exceptions on MSVC.
Sign in to join this conversation.
No description provided.