Skip to content

Commit f579973

Browse files
authored
docs(skills): add engineering skill library under .claude/skills (#1023)
## What Eighteen skills under `.claude/skills/`, each capturing the method and traps for one recurring class of work, so engineers and smaller models can debug, extend, validate, benchmark, and ship this kernel without prior project context. `README.md` indexes them with a suggested reading order and a glossary. **Doctrine and verification:** `debugging-doctrine`, `solid-verification`, `numerical-robustness`, `testing`. **Engine internals:** `boolean-debugging`, `analytic-preservation`, `tessellation`, `fillet-blend`. **Building:** `layer-boundaries`, `add-operation`, `wasm-bindings`, `render-verify`, `io-formats`. **Shipping:** `pr-workflow`, `profiling`, `parity-benchmarking`, `release-flow`. **Work selection:** `roadmap`, a living index of open, deferred, and terminal cases with the chase filters and the acceptance bar. ## How it was built Each skill went through research, authoring, adversarial verification, and fix stages, then cross-skill consistency and coverage passes. Every file path, symbol, and command was checked against the current tree. Several beliefs carried in from earlier work were found stale and corrected in place (tooling that now exists, a heal function that is implemented rather than a stub, a deprecation already removed). ## Scope Documentation only. No source, test, or build changes. The `roadmap` skill declares a maintenance contract: sessions that close, defer, or discover a work item update it in the same PR. <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Adds the brepkit engineering skill library under `.claude/skills` with 18 task-focused guides and references so contributors can debug, extend, verify, benchmark, and ship the kernel. Docs-only; includes an indexed `README.md` and a maintenance rule for the `roadmap` skill. - **New Features** - Eighteen skill guides across doctrine/verification, engine internals, building, shipping, and work selection, each with `SKILL.md` + `reference.md` verified against current symbols, paths, and commands. - `README.md` index with suggested reading order and glossary. - `roadmap` adds a maintenance contract: sessions that close/defer/discover work must update it in the same PR. <sup>Written for commit 3f6b648. Summary will update on new commits.</sup> <a href="https://cubic.dev/pr/andymai/brepkit/pull/1023?utm_source=github" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img alt="Review in cubic" src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a> <!-- End of auto-generated description by cubic. -->
1 parent 1813c64 commit f579973

36 files changed

Lines changed: 4492 additions & 0 deletions

File tree

.claude/skills/README.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# brepkit Skill Library
2+
3+
Distilled working knowledge for building, debugging, and shipping the brepkit B-Rep kernel:
4+
each skill captures the method and traps for one recurring class of task. Written for
5+
engineers and agents working in this repo (plus `~/Git/brepjs` for cross-repo work), with
6+
only this repo and CLAUDE.md as context.
7+
8+
## Index
9+
10+
| Skill | Reach for it when |
11+
|-------|-------------------|
12+
| [roadmap](roadmap/SKILL.md) | Picking work in an autonomous session: what is open, what is terminal, the chase filters, and the acceptance bar. |
13+
| [debugging-doctrine](debugging-doctrine/SKILL.md) | Any hard geometry bug where the first diagnosis did not hold, or before a multi-pass investigation. |
14+
| [solid-verification](solid-verification/SKILL.md) | Deciding whether a solid is actually correct: watertight, manifold, right volume, and whether a "passing" check proves anything. |
15+
| [boolean-debugging](boolean-debugging/SKILL.md) | A fuse, cut, or intersect mesh-falls-back, loses faces, gives wrong volume, fails validation, or varies across runs. |
16+
| [fillet-blend](fillet-blend/SKILL.md) | A fillet or chamfer leaves free edges, opens the shell, silently changes nothing, or you must decide whether the deprecated v1 fillet code is safe to touch. |
17+
| [analytic-preservation](analytic-preservation/SKILL.md) | An operation degrades exact analytic geometry to NURBS or a mesh, face counts explode, or you are triaging the approx census. |
18+
| [numerical-robustness](numerical-robustness/SKILL.md) | Results flip under tiny input nudges, seams and periodic geometry misbehave, or code compares, hashes, or buckets floats. |
19+
| [tessellation](tessellation/SKILL.md) | Mesh cracks at face boundaries, boundary edges or non-manifold edges appear, or you are adding a face mesher in `crates/operations/src/tessellate/`. |
20+
| [add-operation](add-operation/SKILL.md) | Adding or extending a modeling operation in `crates/operations`, end to end through tests and wasm exposure. |
21+
| [layer-boundaries](layer-boundaries/SKILL.md) | Adding a workspace dep, placing new code in a crate, adding an `EdgeCurve` or `FaceSurface` variant, or fixing a boundaries CI failure. |
22+
| [wasm-bindings](wasm-bindings/SKILL.md) | Adding `BrepKernel` methods, wiring `executeBatch`, building the wasm package, or debugging wasm-only failures. |
23+
| [io-formats](io-formats/SKILL.md) | A STEP or other file imports wrong (dropped solids, all-NURBS, hard entity errors), verifying writer round-trips, capturing a faithful fixture, or adding a format in `crates/io`. |
24+
| [render-verify](render-verify/SKILL.md) | Working on `brepkit-render` or visually verifying a solid, including headless capture of a live viewer window. |
25+
| [testing](testing/SKILL.md) | Writing or placing tests, building a faithful regression fixture, handling golden mismatches, or ending a session with unverified work. |
26+
| [profiling](profiling/SKILL.md) | An operation or benchmark is slow, a criterion bench misbehaves, or a PR needs before/after perf numbers. |
27+
| [parity-benchmarking](parity-benchmarking/SKILL.md) | Proving brepkit matches or beats the reference kernel, overlaying a local build into the gridfinity tool, or quoting any perf or parity claim. |
28+
| [pr-workflow](pr-workflow/SKILL.md) | Committing, pushing, opening, or merging a PR; hook failures, commitlint, the AI-review merge gate, worktrees. |
29+
| [release-flow](release-flow/SKILL.md) | Landing a merged brepkit change in brepjs: npm release, wasm pin bump, type sync, adapter update. |
30+
31+
## Suggested reading order for a new engineer
32+
33+
1. Doctrine and verification: `roadmap`, `debugging-doctrine`, `solid-verification`, `numerical-robustness`, `testing`.
34+
2. The engine: `boolean-debugging`, `fillet-blend`, `analytic-preservation`, `tessellation`.
35+
3. Building: `layer-boundaries`, `add-operation`, `wasm-bindings`, `io-formats`, `render-verify`.
36+
4. Shipping: `pr-workflow`, `profiling`, `parity-benchmarking`, `release-flow`.
37+
38+
## Glossary
39+
40+
- **GFA**: the General Fuse Algorithm, the boolean engine in `crates/algo` (`gfa.rs` is the orchestrator).
41+
- **PaveFiller**: the GFA intersection phase (`crates/algo/src/pave_filler/`). It finds all pairwise interferences between the operands before any faces are split.
42+
- **FF/EE/VF phases**: PaveFiller sub-phases, one per entity pair type: vertex-vertex, vertex-edge, edge-edge, vertex-face, edge-face, face-face. See `pave_filler/phase_*.rs`.
43+
- **Pave**: an intersection point on an edge, stored with its curve parameter.
44+
- **Pave block**: the edge segment between two consecutive paves; the unit the builder splits edges into.
45+
- **SD (same-domain)**: two faces (or edges) from different operands that occupy the same geometry. They must be detected and merged to one representative or booleans produce duplicates and open shells.
46+
- **PCurve**: the 2D curve in a face's UV parameter space that traces a 3D edge on that surface. Face splitting and classification run in UV space, so a wrong pcurve breaks them.
47+
- **Analytic vs NURBS**: analytic means an exact typed surface or curve (plane, cylinder, cone, sphere, torus, line, circle, ellipse). NURBS is the free-form spline representation. Keeping results analytic is brepkit's differentiator: exact downstream math, compact data, GPU meshing from parameters.
48+
- **Mesh fallback**: when a boolean cannot assemble a valid B-Rep, it degrades to a triangle-mesh boolean and re-imports the triangles as many small planar faces. Always a defect to investigate, never an acceptable result.
49+
- **Watertight**: the tessellated mesh has zero boundary edges; every triangle edge is shared by exactly two triangles.
50+
- **Manifold**: at the B-Rep level, every edge is used by exactly two faces with consistent orientation.
51+
- **Euler check**: the V - E + F consistency check in solid validation; a cheap topological invariant that catches missing or duplicated entities.
52+
- **Seam**: the edge where a closed surface's parameterization wraps around (u=0 meets u=2*pi on a cylinder). Seam edges appear twice in a face's UV boundary.
53+
- **Periodic surface**: a surface closed in one or both parameter directions (cylinder, cone, sphere, torus). Periodic wrap-around is a standing source of seam and interval bugs.
54+
- **Deflection**: the maximum allowed chord deviation between a mesh and the true surface; the knob that controls tessellation density.
55+
- **The reference kernel**: the established C++ CAD kernel brepkit benchmarks against through the brepjs harness. Parity with it, then beating it, is the project's acceptance bar; see `parity-benchmarking` for how to run the head-to-head.
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
---
2+
name: add-operation
3+
description: Use when adding a new modeling operation to crates/operations (a new pub fn taking &mut Topology and returning a SolidId or similar), when extending an existing operation with a new code path, or when an operation's tests need to prove correctness before shipping. Covers implementation traps, error handling, test placement, wasm exposure, and the verification bar.
4+
---
5+
6+
# Adding an Operation to brepkit
7+
8+
## When to use
9+
10+
You are creating or substantially extending an operation in `crates/operations/src/` (extrude/revolve/sweep class, a measure, a transform, a new primitive). CLAUDE.md Recipe 3 gives the file scaffolding. This skill adds what Recipe 3 omits: the verification bar, where tests go, and the correctness traps that produce compiles-but-wrong geometry.
11+
12+
## Quick reference
13+
14+
| Step | Command / API | Expect |
15+
|------|---------------|--------|
16+
| Scaffold | CLAUDE.md Recipe 3 | file, fn, `lib.rs` module, wasm binding, batch dispatch |
17+
| Measure | `crate::measure::solid_volume(&topo, solid, 0.001)` | relative error < 1% vs closed form |
18+
| Validate | `crate::validate::validate_solid(&topo, solid)` | `report.is_valid()` true |
19+
| Watertight | `tessellate_solid_with_tolerance` + `tessellate::is_watertight` | 0 boundary + 0 non-manifold edges (index-based); also re-check with the positional-weld helper from `tessellate_watertight.rs` |
20+
| Census | `cargo run --release --example approx_census -p brepkit-operations` | no new `brepkit_approx` probe fires for your op |
21+
| Gate | `cargo clippy --all-targets -- -D warnings && cargo fmt --all && ./scripts/check-boundaries.sh` | clean |
22+
23+
## Procedure
24+
25+
1. **Scaffold per CLAUDE.md Recipe 3.** Signature `pub fn op_name(topo: &mut Topology, ...) -> Result<SolidId, OperationsError>`.
26+
2. **Walk faces correctly.** Any solid-scoped loop over faces must use `brepkit_topology::explorer::solid_faces` (there is also `solid_edges`). See CLAUDE.md "Walking faces in a solid" for the exception rule for per-shell operations. Iterating only `outer_shell()` compiles, passes on simple boxes, and silently skips cavity faces on hollow solids.
27+
3. **Respect the borrow pattern and error rules.** Snapshot-then-allocate and closure return type annotations: see CLAUDE.md Common Pitfalls. The workspace denies `unwrap_used`, `panic`, and `unsafe_code` in production code; test modules opt out with `#![allow(clippy::unwrap_used, clippy::expect_used)]`.
28+
4. **If your op copies edges that may carry periodic curves** (`EdgeCurve::Circle` or `Ellipse`), read reference.md "Periodic edge copies" before writing the copy loop. Getting this wrong recovers the complementary arc (minor instead of major) and only reversed edges expose it.
29+
5. **Write tests** (placement below). Every geometry-producing op needs at least: a volume-vs-closed-form test, a `validate_solid` test, and a watertight-tessellation test.
30+
6. **Run the verification bar** (reference.md "Verification bar" has the exact APIs and checkpoint expectations). If the op touches analytic geometry, run the approx census; a fallback probe firing for your op means you degraded analytic surfaces to NURBS or mesh, see the analytic-preservation skill.
31+
7. **Expose to wasm** per CLAUDE.md Recipe 4; details in the wasm-bindings skill (binding module choice, `batch_*` companion, contract tests via `execute_batch()`).
32+
8. **Run the gate commands** from the quick reference before pushing.
33+
34+
## Where tests go
35+
36+
CLAUDE.md's Testing section reads as if golden and integration tests live at the repo root. They do not; the root dirs hold data and docs only.
37+
38+
| Kind | Location | Pattern |
39+
|------|----------|---------|
40+
| Unit tests | `crates/operations/src/<op>/tests.rs`, declared via `mod tests;` at the bottom of `<op>.rs` | `extrude.rs` + `extrude/tests.rs` |
41+
| Crate integration | `crates/operations/tests/*.rs` | `tessellate_watertight.rs`, `boolean_invariants.rs`, `proptest_operations.rs` |
42+
| Golden | `crates/operations/tests/golden_regression.rs`, data in `tests/golden/data/` | regenerate: `UPDATE_GOLDEN=1 cargo test --workspace golden` |
43+
| Wasm contract | wasm crate, via `execute_batch()` only | see wasm-bindings skill |
44+
45+
Do not add standalone test files under the root `tests/integration/` or `tests/golden/`; both READMEs there confirm tests are crate-level.
46+
47+
## Pitfalls: what NOT to conclude
48+
49+
| Observation | Wrong conclusion | Reality |
50+
|-------------|------------------|---------|
51+
| Volume matches closed form | Geometry is correct | Volume can read high on arc-edged results and a nearly-unmodified solid can pass. Also classify interior/exterior probe points with `crate::classify::classify_point` (ray-cast). Never trust the winding classifier for faceted or NURBS solids. |
52+
| Census reports exact analytic | Op is correct | It only proves no approximation fallback fired, not that the geometry is right. A wrong-but-analytic result passes the census. |
53+
| Mesh indices share vertices | Mesh is watertight | Watertightness is geometric: weld vertices by quantized position first, then check edge sharing. Use `tessellate::is_watertight` / `boundary_edge_count`, or copy the `boundary_edges` helper from `crates/operations/tests/tessellate_watertight.rs`. |
54+
| Box test passes | Face walk is complete | Boxes have no inner shells. Add a hollow-solid case (shell_op or boolean-cut cavity) if the op walks faces. |
55+
| Forward-edge arc test passes | Periodic edge copy is correct | Only a reversed `OrientedEdge` swaps stored vertex order vs curve parameterization. Add a reversed-half-circle test (see reference.md). |
56+
| Volume of an off-origin primitive is wrong | The measure is broken | Primitives place their base at z = 0, not centered. Check your expected value first. |
57+
| Cone surface points land off the cone | ConicalSurface is broken | `half_angle` is measured from the radial plane, not from the axis. See reference.md "Cone conventions". |
58+
59+
## Sibling skills
60+
61+
- **wasm-bindings**: binding module, `js_name`, input validation helpers, batch dispatch, contract tests.
62+
- **testing**: fixtures, proptest, golden data regeneration, test layout in depth.
63+
- **solid-verification**: the full verification bar in depth (measure, validate, watertight, classifiers, census).
64+
- **analytic-preservation**: keeping results as typed analytic surfaces instead of NURBS.
65+
- **layer-boundaries**: which crates your op may `use`; `./scripts/check-boundaries.sh` enforces it.
66+
67+
## Reference
68+
69+
Detailed APIs, checkpoints, and the periodic-edge treatment: [reference.md](reference.md).

0 commit comments

Comments
 (0)