error-pattern-safety

Installation
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:

  1. JavaScript's regex.exec() with the g flag uses lastIndex to track position
  2. When a pattern matches zero-width, lastIndex doesn't advance
  3. The same position is matched repeatedly, causing an infinite loop

Dangerous Pattern Examples

❌ NEVER USE THESE PATTERNS:

// Pure .* - matches everything including empty string at end
Related skills
Installs
27
Repository
github/gh-aw
GitHub Stars
4.4K
First Seen
Mar 18, 2026