You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Update CLAUDE.md based on review comments (internal-12545)
Analyzed inline review comments across the last 100 merged GL-JS PRs to
extract recurring corrections and guidance that Claude should follow
when generating code for this project.
cc @mapbox/gl-js
---------
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: Stepan Kuzmin <stepan.kuzmin@mapbox.com>
GitOrigin-RevId: 6c0084d9ce3e7d6743debf7a7cf243b68a0c570f
- Any PR that changes rendering behavior (shader changes, draw function logic, bucket data changes) must include a render test in `test/integration/render-tests/`
169
+
- For query behavior changes, add corresponding query tests covering all affected layer types
170
+
- Render tests for bug fixes must fail without the fix; a tolerance loose enough to pass either way is useless
171
+
- Every render test `style.json` must include a `_comment` field explaining what it checks; drop unused intermediate `wait` steps
172
+
- Don't inflate render test tolerance to make a failing test pass — investigate the root cause
173
+
- Size render test expected images to the minimum needed (e.g., 32×64, not 128×128)
166
174
167
175
### Writing Unit Tests
168
176
@@ -181,10 +189,19 @@ test/
181
189
- Function descriptions: start with third-person verb (e.g., "Sets...", "Returns...")
182
190
- For functions returning values, start with "Returns..."
183
191
- Event descriptions: start with "Fired when..."
192
+
- Style-spec `doc` fields in `v8.json` render verbatim in the public API reference — use unambiguous language, avoid internal terms, and don't reference implementation details
193
+
- When adding a new property to `v8.json`, populate the `sdk-support` table and set `experimental: true` until release version is confirmed
184
194
185
195
## WebGL and Shaders
186
196
187
197
- Custom `#pragma mapbox` directives in shaders expand to uniforms or attributes
188
198
- Shader programs are dynamically generated based on style properties
189
199
- Data-driven styling creates paint vertex arrays at layout time
190
200
- See [@src/shaders/README.md](src/shaders/README.md) for shader documentation
201
+
- Use named `#define` constants for integer mode values in shaders — never bare magic numbers like `if (u_blend_mode == 1)`
202
+
- Use `#if defined(A) && defined(B)` for compound shader conditionals (not `#ifdef`); required for the Metal preprocessing pipeline
203
+
204
+
## Performance
205
+
206
+
- Allocate GPU objects (buffers, textures, bind groups, UBOs) at bucket creation or style load time; invalidate only when underlying data changes. **Never allocate GPU objects inside draw functions that run every frame.**
207
+
- In hot paths, prefer flat typed arrays (`Float32Array`, `Uint16Array`) over arrays of objects or nested arrays
0 commit comments