opencv-js
CLAUDE.md786 starsChanged 4 months agoApache-2.0View on GitHub
TypeScript NPM package wrapping the pre-built OpenCV.js (WASM) binary with type definitions. Supports Node.js and browser environments. NEVER cancel builds or tests. Always run the full sequence after any change: Always call .delete() on OpenCV objects — WASM memory does not GC: Current API (v4.11+): Legacy API (v4.10-): See doc/updating-opencv-version.md for the full checklist. Quick summary: 1. Build new dist/opencv.js via GitHub Actions (build-opencv-js.yml) 2. Replace dist/opencv.js with the artifact 3. Update version strings: package.json, README.md, CLAUDE.md, .github/copilot-instructions.md, build-opencv-js.yml 4.…
- Installs packages
We split this CLAUDE.md into the rules it gives an agent
4 rules. About 0 are common, 1 is distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 21
NEVER cancel builds or tests.
- Very specific: line 42
Always call .delete() on OpenCV objects — WASM memory does not GC:
- Very specific: line 80
Update version strings: package.json, README.md, CLAUDE.md, .github/copilot-instructions.md, build-opencv-js.yml
- Very specific: line 101
Run npm audit fix before committing
≈ “Common” is an estimate: at least 1 in 5 of the 25,680 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
opencv-js — Claude Development Guide
Project Overview
TypeScript NPM package wrapping the pre-built OpenCV.js (WASM) binary with type definitions. Supports Node.js and browser environments.
- Package:
@techstark/opencv-js - Version:
5.0.0-release.1 - OpenCV Version: 5.0.0 (WASM binary in
dist/opencv.js) - Binary source: Built via GitHub Actions (
build-opencv-js.yml) — officialdocs.opencv.orgdoes not yet publish 5.x
Essential Commands
npm install # ~15s — regenerates package-lock.json
npm run build # ~2s — TypeScript compile (tsc)
npm test # ~8s — Jest test suite (38 tests)
npm run format # ~1s — PrettierNEVER cancel builds or tests. Always run the full sequence after any change:
npm install && npm run build && npm testFile Structure
dist/opencv.js — pre-built WASM binary (~10MB), never edit
src/index.ts — re-exports from types/
src/types/opencv/ — 100+ TypeScript definition files
test/ — Jest tests (Mat, Tracker, rect, cvKeys, QRCode, etc.)
doc/cvKeys.json — runtime API surface snapshot (buildInformation + keys)
.github/workflows/
build-opencv-js.yml — builds opencv.js from source via Emscripten
npm-publish.yml — publishes to NPM on release
unit-test.yml — CI tests on PR/pushMemory Management (Critical)
Always call .delete() on OpenCV objects — WASM memory does not GC:
const mat = new cv.Mat(3, 3, cv.CV_8UC1);
try {
// use mat
} finally {
mat.delete();
}Import Patterns
Current API (v4.11+):
import cvReadyPromise from "@techstark/opencv-js";
const cv = await cvReadyPromise;Legacy API (v4.10-):
import cv from "@techstark/opencv-js";
cv.onRuntimeInitialized = () => { /* use cv */ };Browser webpack polyfills
resolve: { fallback: { fs: false, path: false, crypto: false } }Updating the OpenCV Version
See doc/updating-opencv-version.md for the full checklist.
Quick summary:
- Build new
dist/opencv.jsvia GitHub Actions (build-opencv-js.yml) - Replace
dist/opencv.jswith the artifact - Update version strings:
package.json,README.md,CLAUDE.md,.github/copilot-instructions.md,build-opencv-js.yml - Run
npm install && npm run build && npm test - Regenerate
doc/cvKeys.json(runnpm test— the cvKeys test validates the binary)
Build parameters for 5.0.0:
- Emscripten:
4.0.20 - CMake option:
-DCMAKE_CXX_STANDARD=17(required for Emscripten 4.0.20+) - Build flags: default (no custom flags needed)
Common Issues
| Error | Cause | Fix |
cv.Mat is not a constructor | OpenCV not initialized | use await cvReadyPromise |
| Memory leak / browser crash | Missing .delete() | add .delete() in finally |
webpack fs not found | Missing polyfills | add fallback config |
Test failures on setupOpenCv() | Async init not awaited | check test helper |
Security
dist/opencv.jscomes from our own CI build (OpenCV source + Emscripten) — verify origin before accepting external files- Run
npm audit fixbefore committing
In this repositoryOne other file it gives its agents.
- .github/copilot-instructions.mdCopilot instructions
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

