Skip to content
Prompt

node-re2 — Windsurf Rules

by uhop

AI Summary

<!-- Canonical source: AGENTS.md — keep this file in sync --> node-re2 provides Node.js bindings for RE2: a fast, safe alternative to backtracking regular expression engines. The npm package name is . It is a C++ native addon built with and .

Install

Copy this and paste it into Claude Code, Cursor, or any AI assistant:

I want to add the "node-re2 — Windsurf Rules" prompt rules to my project.
Repository: https://github.com/uhop/node-re2

Please read the repo to find the rules/prompt file, then:
1. Download it to the correct location (.cursorrules, .windsurfrules, .github/prompts/, or project root — based on the file type)
2. If there's an existing rules file, merge the new rules in rather than overwriting
3. Confirm what was added

Description

node.js bindings for RE2: fast, safe alternative to backtracking regular expression engines.

Project identity

node-re2 provides Node.js bindings for RE2: a fast, safe alternative to backtracking regular expression engines. The npm package name is re2. It is a C++ native addon built with node-gyp and nan.

Critical rules

• CommonJS. The project is "type": "commonjs". Use require() in source, import in tests (.mjs). • No transpilation. JavaScript code runs directly. • Do not modify vendored code. Never edit files under vendor/. They are git submodules. • Do not modify or delete test expectations without understanding why they changed. • Do not add comments or remove comments unless explicitly asked. • Keep re2.js and re2.d.ts in sync. All public API exposed from re2.js must be typed in re2.d.ts. • The addon must build on all supported platforms: Linux (x64, arm64, Alpine), macOS (x64, arm64), Windows (x64, arm64). • RE2 is always Unicode-mode. The u flag is always added implicitly. • Buffer support is a first-class feature. All methods that accept strings must also accept Buffers, returning Buffers when given Buffer input.

Code style

• C++ code: tabs, 4-wide indentation. JavaScript: 2-space indentation. • Prettier: 80 char width, single quotes, no bracket spacing, no trailing commas, arrow parens "avoid" (see .prettierrc). • nan (Native Abstractions for Node.js) for the C++ addon API. • Semicolons are enforced by Prettier (default semi: true).

Architecture quick reference

• re2.js is the main entry point. Loads build/Release/re2.node, sets up Symbol aliases (Symbol.match, Symbol.search, Symbol.replace, Symbol.split, Symbol.matchAll). • C++ addon (lib/*.cc) wraps Google's RE2 via nan. Each RegExp method has its own .cc file. • lib/new.cc handles construction: parse pattern/flags, translate RegExp → RE2 syntax (via lib/pattern.cc). • lib/pattern.cc translates Unicode class names (\p{Letter} → \p{L}, \p{Script=Latin} → \p{Latin}). • lib/set.cc implements RE2.Set for multi-pattern matching. • lib/util.cc provides UTF-8 ↔ UTF-16 conversion and buffer helpers. • Prebuilt artifacts downloaded at install time via install-artifact-from-github.

Discussion

0/2000
Loading comments...

Health Signals

MaintenanceCommitted 4d ago
Active
Adoption100+ stars on GitHub
545 ★ · Growing
DocsREADME + description
Well-documented

GitHub Signals

Stars545
Forks59
Issues5
Updated4d ago
View on GitHub
No License

My Fox Den

Community Rating

Sign in to rate this booster

Works With

Any AI assistant that accepts custom rules or system prompts

Claude
ChatGPT
Cursor
Windsurf
Copilot
+ more