Skip to content

docs: add Claude Code style rule for dal.cpp project#8

Merged
wegamekinglc merged 1 commit intomasterfrom
add-claude-code-style-rule
Apr 4, 2026
Merged

docs: add Claude Code style rule for dal.cpp project#8
wegamekinglc merged 1 commit intomasterfrom
add-claude-code-style-rule

Conversation

@wegamekinglc
Copy link
Copy Markdown
Owner

Add a code-style.md rule under .claude/rules/ summarizing the project's naming conventions, formatting, type idioms, error handling patterns, and test conventions for Claude Code to follow.

Add a code-style.md rule under .claude/rules/ summarizing the
project's naming conventions, formatting, type idioms, error
handling patterns, and test conventions for Claude Code to follow.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a Claude Code rule file documenting dal.cpp’s established C++ style conventions so automated edits align with existing patterns in the repository.

Changes:

  • Introduces .claude/rules/code-style.md describing formatting, naming, type idioms, error handling, and test conventions for dal.cpp.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

- Short `if`/loops: not on single line
- Short functions: allowed on single line
- Namespace indent: all
- Standard: C++17
Copy link

Copilot AI Apr 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The “Formatting (enforced by .clang-format)” section lists “Standard: C++17”, but .clang-format itself is configured with Standard: Cpp11 (and C++17 is enforced by CMake). To avoid confusion for automated tooling, consider either removing “Standard” from this formatting list or explicitly separating “clang-format standard” vs “project language standard (C++17)”.

Suggested change
- Standard: C++17
- `.clang-format` standard: Cpp11
- Project language standard: C++17 (enforced by CMake)

Copilot uses AI. Check for mistakes.
| Element | Convention | Examples |
|----------------------|-------------------------------|---------------------------------------------------|
| Classes/Structs | PascalCase + trailing `_` | `Date_`, `Vector_<>`, `ThreadPool_`, `Model_<T_>` |
| Template params | Single letter + `_` | `T_`, `E_`, `LHS_`, `RHS_`, `OP_` |
Copy link

Copilot AI Apr 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The template parameter naming rule says “Single letter + _”, but the examples and the codebase use multi-letter template params like LHS_, RHS_, and OP_ (e.g., in dal/math/aad/expr.hpp). Updating the rule to match actual usage (e.g., “Uppercase identifier + trailing _”) would make this guide more accurate.

Suggested change
| Template params | Single letter + `_` | `T_`, `E_`, `LHS_`, `RHS_`, `OP_` |
| Template params | Uppercase identifier + `_` | `T_`, `E_`, `LHS_`, `RHS_`, `OP_` |

Copilot uses AI. Check for mistakes.
Comment on lines +17 to +27
| Element | Convention | Examples |
|----------------------|-------------------------------|---------------------------------------------------|
| Classes/Structs | PascalCase + trailing `_` | `Date_`, `Vector_<>`, `ThreadPool_`, `Model_<T_>` |
| Template params | Single letter + `_` | `T_`, `E_`, `LHS_`, `RHS_`, `OP_` |
| Functions/Methods | PascalCase | `FromExcel()`, `AddDays()`, `GeneratePath()` |
| Member variables | Trailing `_` | `serial_`, `spot_`, `vol_`, `name_` |
| Local variables | snake_case | `num_paths`, `batch_size`, `n_threads` |
| Constants/Macros | UPPER_SNAKE_CASE | `BATCH_SIZE`, `EPSILON`, `FORCE_INLINE` |
| Files | lowercase, no separators | `threadpool.cpp`, `blackscholes.hpp` |
| Test files | `test_` prefix, snake_case | `test_vectors.cpp`, `test_date.cpp` |
| Namespaces | PascalCase or lowercase | `Dal`, `Dal::AAD`, `namespace exception` |
Copy link

Copilot AI Apr 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The file naming convention “lowercase, no separators” doesn’t match existing filenames that include underscores / leading underscores (e.g., dal/storage/_repository.*, tests/storage/test__repository.cpp). Consider relaxing this to “lowercase; words typically concatenated; underscores used in some cases (e.g., private/internal prefixes)”.

Suggested change
| Element | Convention | Examples |
|----------------------|-------------------------------|---------------------------------------------------|
| Classes/Structs | PascalCase + trailing `_` | `Date_`, `Vector_<>`, `ThreadPool_`, `Model_<T_>` |
| Template params | Single letter + `_` | `T_`, `E_`, `LHS_`, `RHS_`, `OP_` |
| Functions/Methods | PascalCase | `FromExcel()`, `AddDays()`, `GeneratePath()` |
| Member variables | Trailing `_` | `serial_`, `spot_`, `vol_`, `name_` |
| Local variables | snake_case | `num_paths`, `batch_size`, `n_threads` |
| Constants/Macros | UPPER_SNAKE_CASE | `BATCH_SIZE`, `EPSILON`, `FORCE_INLINE` |
| Files | lowercase, no separators | `threadpool.cpp`, `blackscholes.hpp` |
| Test files | `test_` prefix, snake_case | `test_vectors.cpp`, `test_date.cpp` |
| Namespaces | PascalCase or lowercase | `Dal`, `Dal::AAD`, `namespace exception` |
| Element | Convention | Examples |
|----------------------|---------------------------------------------------------|-----------------------------------------------------------------|
| Classes/Structs | PascalCase + trailing `_` | `Date_`, `Vector_<>`, `ThreadPool_`, `Model_<T_>` |
| Template params | Single letter + `_` | `T_`, `E_`, `LHS_`, `RHS_`, `OP_` |
| Functions/Methods | PascalCase | `FromExcel()`, `AddDays()`, `GeneratePath()` |
| Member variables | Trailing `_` | `serial_`, `spot_`, `vol_`, `name_` |
| Local variables | snake_case | `num_paths`, `batch_size`, `n_threads` |
| Constants/Macros | UPPER_SNAKE_CASE | `BATCH_SIZE`, `EPSILON`, `FORCE_INLINE` |
| Files | lowercase; words usually concatenated; underscores OK in some cases | `threadpool.cpp`, `blackscholes.hpp`, `_repository.hpp`, `storage_manager.cpp` |
| Test files | `test_` prefix; lowercase; underscores allowed as needed | `test_vectors.cpp`, `test_date.cpp`, `test__repository.cpp` |
| Namespaces | PascalCase or lowercase | `Dal`, `Dal::AAD`, `namespace exception` |

Copilot uses AI. Check for mistakes.
Comment on lines +82 to +85
- Float comparison: `ASSERT_NEAR(actual, expected, tol)` with `1e-8` to `1e-10`
- Scoped blocks `{ }` within a single `TEST` for sub-cases
- Test suites: PascalCase (`AADTest`, `VectorTest`)
- Test names: PascalCase with `Test` prefix (`TestNumberAdd`)
Copy link

Copilot AI Apr 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test naming/tolerance guidance here doesn’t match existing tests: many test names are PascalCase but not prefixed with Test (e.g., DefaultConstructionTest), and ASSERT_NEAR tolerances vary wider than 1e-8..1e-10 (there are 1e-3, 1e-6, etc.). Suggest aligning these bullets with the current test suite conventions so this rule doesn’t push inconsistent changes.

Suggested change
- Float comparison: `ASSERT_NEAR(actual, expected, tol)` with `1e-8` to `1e-10`
- Scoped blocks `{ }` within a single `TEST` for sub-cases
- Test suites: PascalCase (`AADTest`, `VectorTest`)
- Test names: PascalCase with `Test` prefix (`TestNumberAdd`)
- Float comparison: use `ASSERT_NEAR(actual, expected, tol)` with a tolerance appropriate to the values and algorithm under test (existing tests vary, e.g. `1e-3`, `1e-6`, `1e-8`)
- Scoped blocks `{ }` within a single `TEST` for sub-cases
- Test suites: PascalCase (`AADTest`, `VectorTest`)
- Test names: PascalCase; follow existing suite patterns such as `DefaultConstructionTest` rather than requiring a `Test` prefix

Copilot uses AI. Check for mistakes.
## Header Files

- Always `#pragma once` (no include guards)
- File header comment: `// Created by <author> on <date>.`
Copy link

Copilot AI Apr 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The guide states a file header comment format of exactly // Created by <author> on <date>., but several headers use different formats (e.g., /* Modified by ... */ blocks in AAD headers, and varied date formats). Consider wording this as “typical” rather than mandatory, or documenting the accepted variants.

Suggested change
- File header comment: `// Created by <author> on <date>.`
- File header comment: typically `// Created by <author> on <date>.`; existing variants such as `/* Modified by ... */` blocks and differing date formats are also accepted

Copilot uses AI. Check for mistakes.
@wegamekinglc wegamekinglc merged commit 0e2ba68 into master Apr 4, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants