error-pattern-safety
SKILL.md
Error Pattern Safety Guidelines
This document outlines the safety guidelines for error pattern regex in agentic engines to prevent infinite loops in JavaScript.
The Problem
When using regex patterns with the JavaScript global flag (/pattern/g), patterns that can match zero-width (empty strings) can cause infinite loops. This happens because:
- JavaScript's
regex.exec()with thegflag useslastIndexto track position - When a pattern matches zero-width,
lastIndexdoesn't advance - The same position is matched repeatedly, causing an infinite loop
Dangerous Pattern Examples
❌ NEVER USE THESE PATTERNS: