|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +CmdScale.EntityFrameworkCore.TimescaleDB is an Entity Framework Core provider extension that integrates TimescaleDB features (hypertables, compression, continuous aggregates, reorder policies, etc.) into EF Core's migration and scaffolding system. The library extends Npgsql.EntityFrameworkCore.PostgreSQL. |
| 8 | + |
| 9 | +**Detailed documentation:** See `.claude/reference/` for architecture, patterns, and file organization. |
| 10 | + |
| 11 | +## Build and Test Commands |
| 12 | + |
| 13 | +```bash |
| 14 | +dotnet build # Build the solution |
| 15 | +dotnet test # Run all tests (requires Docker for Testcontainers) |
| 16 | +dotnet test --filter "FullyQualifiedName~TestName" # Run single test |
| 17 | +dotnet restore # Restore dependencies |
| 18 | +``` |
| 19 | + |
| 20 | +### Test Coverage |
| 21 | + |
| 22 | +Coverage reports are always generated under `tests/Eftdb.Tests/TestResults/`. |
| 23 | + |
| 24 | +```bash |
| 25 | +# Run tests with coverage |
| 26 | +dotnet test tests/Eftdb.Tests --settings tests/Eftdb.Tests/coverlet.runsettings --collect:"XPlat Code Coverage" |
| 27 | + |
| 28 | +# Generate HTML report (use -sourcedirs to resolve source locally instead of via Source Link) |
| 29 | +reportgenerator -reports:"tests/Eftdb.Tests/TestResults/**/coverage.cobertura.xml" -targetdir:"tests/Eftdb.Tests/TestResults/CoverageReport" -reporttypes:Html -sourcedirs:"src/" |
| 30 | +``` |
| 31 | + |
| 32 | +The HTML report will be at `tests/Eftdb.Tests/TestResults/CoverageReport/index.html`. |
| 33 | + |
| 34 | +### Local Development |
| 35 | + |
| 36 | +```bash |
| 37 | +docker-compose up -d # Start TimescaleDB container |
| 38 | +docker-compose down -v # Reset database (destructive) |
| 39 | +``` |
| 40 | + |
| 41 | +### Testing Project/Package References |
| 42 | + |
| 43 | +```powershell |
| 44 | +Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process |
| 45 | +.\Scripts\Switch-References.ps1 -Mode Project # For development |
| 46 | +.\Scripts\Switch-References.ps1 -Mode Package # To test as NuGet consumer |
| 47 | +``` |
| 48 | + |
| 49 | +## Coding Standards |
| 50 | + |
| 51 | +### C# Style Guidelines |
| 52 | + |
| 53 | +**Type Declarations:** Use explicit types with `new()` target-typed initializer: |
| 54 | +```csharp |
| 55 | +StoreObjectIdentifier storeIdentifier = new(); // Correct |
| 56 | +var storeIdentifier = new StoreObjectIdentifier(); // Incorrect |
| 57 | +``` |
| 58 | + |
| 59 | +**Collection Expressions:** Use `[]` syntax and spread operator: |
| 60 | +```csharp |
| 61 | +List<string> items = ["item1", "item2"]; // Correct |
| 62 | +List<string> allItems = [.. existingItems, .. newItems]; // Correct |
| 63 | +``` |
| 64 | + |
| 65 | +**Async Programming:** Use `async/await` with `ConfigureAwait(false)` in library code. |
| 66 | + |
| 67 | +**Primary Constructors:** Use for classes that only assign parameters to fields: |
| 68 | +```csharp |
| 69 | +private class TestContext(string connectionString) : DbContext { } |
| 70 | +``` |
| 71 | + |
| 72 | +**Static Methods:** Make methods static when they don't depend on instance state. |
| 73 | + |
| 74 | +**Comments:** XML docs on public members; neutral voice; no pronouns or enumerations. Do not overuse comments to explain "what" code does - prefer clear code. Use comments to explain "why" or complex logic. The code should be self-explaining in most cases. |
| 75 | + |
| 76 | +### Architectural Principles |
| 77 | + |
| 78 | +**DRY:** Centralize constants in `DefaultValues.cs`, use `SqlBuilderHelper`, share patterns via extractors. |
| 79 | + |
| 80 | +**SoC:** Keep classes focused - extractors read metadata, differs compare models, generators produce SQL/C#. |
| 81 | + |
| 82 | +## Key Patterns (Quick Reference) |
| 83 | + |
| 84 | +| Pattern | Description | See | |
| 85 | +|---------|-------------|-----| |
| 86 | +| Service Registration | `UseTimescaleDb()` configures all services | `reference/patterns.md` | |
| 87 | +| Convention System | `IEntityTypeAddedConvention` processes attributes | `reference/patterns.md` | |
| 88 | +| Dual Configuration | Annotations + Fluent API → same annotations | `reference/patterns.md` | |
| 89 | +| IFeatureDiffer | Per-feature differ with model extractor | `reference/patterns.md` | |
| 90 | +| Runtime vs Design-Time | `isDesignTime` parameter changes quote escaping | `reference/patterns.md` | |
| 91 | +| Column Name Resolution | Always use `StoreObjectIdentifier` + `GetColumnName()` | `reference/patterns.md` | |
| 92 | + |
| 93 | +## Agent Workflow |
| 94 | + |
| 95 | +``` |
| 96 | +New Feature → [1] eftdb-feature-initializer |
| 97 | + → [2] eftdb-feature-implementer |
| 98 | + → [3] eftdb-scaffold-support |
| 99 | + → [4] test-writer |
| 100 | + → [5] example-feature-generator |
| 101 | + → [6] git-committer (/prepare-commit) |
| 102 | +``` |
| 103 | + |
| 104 | +| Agent | Purpose | Skill | |
| 105 | +|-------|---------|-------| |
| 106 | +| `eftdb-feature-initializer` | Creates Operations, FluentAPI, Attributes, Conventions | | |
| 107 | +| `eftdb-feature-implementer` | Creates Differ, Extractor, Generator | | |
| 108 | +| `eftdb-scaffold-support` | Creates Scaffolding Extractor, Applier (Design-time) | | |
| 109 | +| `eftdb-bug-fixer` | Fixes bugs in runtime/design-time code | | |
| 110 | +| `test-writer` | Creates unit and integration tests | | |
| 111 | +| `test-coverage-planner` | Analyzes test coverage gaps | `/coverage-plan` | |
| 112 | +| `example-feature-generator` | Creates usage examples | | |
| 113 | +| `git-committer` | Formats, tests, stages, generates commit message | `/prepare-commit` | |
| 114 | +| `code-detective` | Investigates bugs, traces history | | |
| 115 | +| `pr-code-reviewer` | Reviews PR changes against patterns | `/review` | |
| 116 | +| `eftdb-docs-writer` | Writes and updates documentation | | |
| 117 | +| `changelog-generator` | Generates changelog entries for the documentation page | | |
| 118 | + |
| 119 | +### Agent Boundaries |
| 120 | + |
| 121 | +| Agent | Allowed | Forbidden | |
| 122 | +|-------|---------|-----------| |
| 123 | +| `eftdb-feature-initializer` | `src/Eftdb/` (Operations, Configuration) | Design, Tests, Samples | |
| 124 | +| `eftdb-feature-implementer` | `src/Eftdb/` + `src/Eftdb.Design/` | Tests, Samples | |
| 125 | +| `eftdb-scaffold-support` | `src/Eftdb.Design/` only | All others | |
| 126 | +| `eftdb-bug-fixer` | `src/Eftdb/`, `src/Eftdb.Design/` | Tests (read-only), Samples | |
| 127 | +| `test-writer` | `tests/` only | src/, Samples | |
| 128 | +| `example-feature-generator` | `samples/` only | src/, Tests | |
| 129 | + |
| 130 | +## Reference Documentation |
| 131 | + |
| 132 | +- `.claude/reference/architecture.md` - Project structure, library organization |
| 133 | +- `.claude/reference/patterns.md` - Key patterns with code examples |
| 134 | +- `.claude/reference/file-organization.md` - File location quick reference |
| 135 | +- `.claude/agents/` - Detailed agent prompts |
0 commit comments