Skip to content

Commit 1a58a26

Browse files
committed
Update CLAUDE.md with PR style and commit guidelines
1 parent 3a7ef7e commit 1a58a26

1 file changed

Lines changed: 35 additions & 3 deletions

File tree

CLAUDE.md

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,14 @@ FHIR Package → TypeSchema Generator → TypeSchema Format → Code Generators
9595
- If a change is a direct fix for a specific previous commit, place it immediately after that commit with a `fix:` prefix in the message.
9696
- Typical commit order: source changes → test changes → regenerated examples. Example updates should be the last commit in the branch.
9797

98+
## Pull Request Style
99+
100+
- PR body should be a bullet list summarizing changes — no section headers, no test plan.
101+
- Use two-level nesting to group related items when the list is long; keep it flat when short.
102+
- Keep bullets concise and focused on what changed, not why.
103+
- When a PR changes generated code or user-facing API, include before/after code examples.
104+
- Add a short motivation line before each example explaining why the change was made.
105+
98106
## Development Guidelines
99107

100108
### TypeScript Configuration
@@ -198,6 +206,29 @@ Located in `src/api/writer-generator/`:
198206
- Each writer traverses TypeSchema index and generates code
199207
- Maintains language-specific idioms and conventions
200208

209+
## Static Assets for Generators
210+
211+
Static files that are copied verbatim into generated output live in `assets/api/writer-generator/<language>/`. Each language writer has a resolver function (e.g., `resolveTsAssets`, `resolvePyAssets`) that handles path resolution for both dev (`src/`) and dist (`dist/`) builds.
212+
213+
**Pattern:**
214+
```
215+
assets/api/writer-generator/
216+
├── typescript/profile-helpers.ts # Runtime helpers for TS profile classes
217+
└── python/
218+
├── requirements.txt
219+
├── fhirpy_base_model.py
220+
└── resource_family_validator.py
221+
```
222+
223+
**How it works:**
224+
1. Asset files are authored/maintained directly in `assets/` (included in biome linting)
225+
2. Writers copy them to output via `this.cp("filename", "filename")` — uses `Writer.cp()` which resolves via `resolveAssets`
226+
3. Each language writer sets `resolveAssets` in its constructor (e.g., TypeScript writer defaults to `resolveTsAssets`)
227+
228+
**When to use assets vs programmatic generation:**
229+
- Use assets for static runtime code shared across all generated profiles (helpers, validators, base models)
230+
- Use programmatic generation (`w.lineSM()`, `w.curlyBlock()`) for code that varies per schema/profile
231+
201232
## Common Development Patterns
202233

203234
### Adding a New Generator Feature
@@ -235,10 +266,11 @@ Located in `src/api/writer-generator/`:
235266

236267
### Generators
237268
- `src/api/writer-generator/introspection.ts` - TypeSchema introspection generation
238-
- `src/api/writer-generator/typescript.ts` - TypeScript code generation
269+
- `src/api/writer-generator/typescript/writer.ts` - TypeScript type generation
270+
- `src/api/writer-generator/typescript/profile.ts` - TypeScript profile class generation
239271
- `src/api/writer-generator/python.ts` - Python/Pydantic generation
240-
- `src/api/writer-generator/csharp.ts` - C# generation
241-
- `src/api/writer-generator/base.ts` - Common writer utilities
272+
- `src/api/writer-generator/csharp/csharp.ts` - C# generation
273+
- `src/api/writer-generator/writer.ts` - Base Writer class (I/O, indentation, `cp()` for assets)
242274

243275
### FHIR Processing
244276
- `src/typeschema/register.ts` - Package registration and canonical resolution

0 commit comments

Comments
 (0)