Skip to content

docs: add null-narrowing and log-mocking conventions to CLAUDE.md#260

Open
kinyoklion wants to merge 1 commit intomainfrom
rlamb/coding-conventions-claude-md
Open

docs: add null-narrowing and log-mocking conventions to CLAUDE.md#260
kinyoklion wants to merge 1 commit intomainfrom
rlamb/coding-conventions-claude-md

Conversation

@kinyoklion
Copy link
Copy Markdown
Member

@kinyoklion kinyoklion commented Apr 28, 2026

Two patterns that should be applied consistently across the repo:

  • Prefer Dart 3 case-pattern null narrowing (if (x case final v?)) over the ! operator. Case-patterns introduce a non-null local without runtime assertion, avoiding surprise TypeErrors.
  • For tests that capture log output, use mocktail's Mock implements LDLogAdapter plus verify(...).captured rather than hand-rolling a capturing adapter. This matches the pattern used in five existing test files (validating_persistence_test.dart, hook_runner_test.dart, env_context_modifier_test.dart, operations_test.dart, anonymous_context_modifier_test.dart).

CLAUDE.md is loaded into context for every Claude Code session in this repo, so codifying these here makes them the default for both human contributors and AI agents.


Note

Low Risk
Low risk: documentation-only changes with no runtime behavior impact.

Overview
Updates CLAUDE.md to codify two new conventions: prefer Dart 3 case-pattern null narrowing over !, and standardize log-capture in tests using mocktail (Mock implements LDLogAdapter + verify(...captureAny())) with validating_persistence_test.dart as the reference pattern.

Reviewed by Cursor Bugbot for commit d6dfe53. Bugbot is set up for automated code reviews on this repo. Configure here.

Two patterns that should be applied consistently across the repo:

- Prefer Dart 3 case-pattern null narrowing (`if (x case final v?)`)
  over the `!` operator. Case-patterns introduce a non-null local
  without runtime assertion, avoiding surprise `TypeError`s.
- For tests that capture log output, use mocktail's
  `Mock implements LDLogAdapter` plus `verify(...).captured` rather
  than hand-rolling a capturing adapter. This matches the pattern
  used in five existing test files
  (validating_persistence_test.dart, hook_runner_test.dart,
  env_context_modifier_test.dart, operations_test.dart,
  anonymous_context_modifier_test.dart).

CLAUDE.md is loaded into context for every Claude Code session in
this repo, so codifying these here makes them the default for both
human contributors and AI agents.
@kinyoklion kinyoklion requested a review from a team as a code owner April 28, 2026 23:20
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.

1 participant