error-pattern-safety

Detect zero-width regex matches to prevent infinite loops in JavaScript and Go error patterns.

4.9k|489|Updated Aug 12, 2025
One-click install
npx skills add https://github.com/githubnext/gh-aw --skill error-pattern-safety
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: error-pattern-safety
Source: https://github.com/githubnext/gh-aw/tree/main/skills/error-pattern-safety
Command: npx skills add https://github.com/githubnext/gh-aw --skill error-pattern-safety

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill provides critical guidelines to prevent infinite loop bugs in AI agent regex patterns, ensuring stable and reliable automation. It helps developers write robust error pattern matching, avoiding system hangs and ensuring continuous operation.

Core Features & Use Cases

  • Safe Regex Guidelines: Learn to construct regex patterns that avoid zero-width matches, a common cause of infinite loops in JavaScript.
  • Dangerous & Safe Examples: See clear examples of regex patterns to avoid and recommended safe alternatives.
  • Validation Tests & Mechanisms: Understand built-in safety checks and testing procedures to verify pattern safety.
  • Use Case: Developers building or extending AI agent engines can use this guide to write robust error pattern matching, avoiding system hangs and ensuring continuous operation.

Quick Start

Consult the error-pattern-safety skill to understand how to write regex that avoids zero-width matches and infinite loops in JavaScript.

Frequently Asked Questions about error-pattern-safety

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I prevent infinite loops in JavaScript regex patterns?

Infinite loops in regex occur when zero-width matches advance without consuming input. Prevent them by ensuring your patterns consume at least one character per match, using possessive quantifiers, or adding iteration caps. This Skill provides validation tests and safe pattern guidelines for error matching in AI agents.

What are zero-width matches and why do they cause problems?

Zero-width matches are regex patterns that succeed without advancing the input position, like lookaheads or anchors. In loops, they repeat infinitely because the engine retries the same position. This Skill teaches detection and safety rules to identify and eliminate zero-width hazards in JavaScript and Go regex.

Can I use this approach for error pattern validation in AI agent engines?

Yes. This Skill is designed specifically for developers building or extending AI agent engines. It provides error pattern matching guidelines that prevent system hangs, ensuring agents remain stable and operational without freezing on malformed input patterns.

How do I test regex patterns to ensure they won't hang?

Use built-in validation tests and safety checks to verify pattern safety. This Skill documents mechanisms in validate_errors.cjs and related unit tests that implement zero-width progression checks and iteration caps to catch dangerous patterns before deployment.

What's the difference between safe and dangerous regex examples for error handling?

Dangerous patterns use unanchored quantifiers on zero-width assertions like `(?=.*)*` which repeat infinitely. Safe alternatives constrain matches to consume input or use bounded repetition. This Skill contrasts both types with examples specific to error pattern matching in agent systems.

Does this apply to both JavaScript and Go regex?

Yes. This Skill covers zero-width match safety and validation for both JavaScript and Go regex implementations used in error pattern testing, with language-specific safety rules and guidelines for each.