About regex-builder
A skill that guides repository work on building and validating regular expressions for a specified engine. It emphasizes sample-based testing, engine-specific behavior, and backtracking and input-size risks.
Key features
- 01Define engine and pattern requirements
- 02Build patterns from sample cases
- 03Test in the target runtime
- 04Check escaping and Unicode boundaries
- 05Assess backtracking and input risks
Use cases
- 01Create a regex for application validation
- 02Verify patterns against match and non-match cases
- 03Review regex safety for untrusted input
Install
Copy the command and run it in a terminal.
npx skills add https:/ / github.com/ jmerta/ codex-skills --skill regex-builderAfter installing, type/regex-builderin Claude Code to confirm it loaded.
Bundled filesagents/openai.yaml
Details
From the project READMERegex builder
Define the contract
Confirm the target engine and version, flags, multiline behavior, input boundary, capture or replacement needs, and representative matches and non-matches. Infer these from the consuming code when possible; ask only for information the repository cannot answer.
Do not present a pattern as portable across JavaScript, Python, Java, .NET, RE2, PCRE2, or a command-line tool unless the common subset was verified.
Build and test
- Start with the smallest literal structure that distinguishes the samples.
- Add anchors, boundaries, separators, Unicode handling, and capture groups only when required by the contract.
- Test with the actual target engine. Use
rgonly for ripgrep's default engine orrg -Pfor its PCRE2 mode; use the application runtime for other flavors. - Verify every supplied match and non-match. Add boundary cases for empty input, adjacent matches, newlines, and Unicode. For untrusted input, include a long adversarial near-miss or non-match, measure its runtime, and require an application input bound when the engine has no timeout.
- Check shell and string-literal escaping separately from regex syntax.
- Avoid nested ambiguous quantifiers and unbounded backtracking on untrusted input. Prefer a simpler parser when the grammar or safety requirements exceed a readable regex.
Deliver
Provide:
- the regex and flags;
- its target engine and required version or features;
- a capture-group or replacement map when used;
- one runnable verification in the target runtime with expected results;
- known limitations and any backtracking or input-size risk.