npx skills add ...
npx skills add github/gh-aw --skill error-pattern-safety
npx skills add github/gh-aw --skill error-pattern-safety
Apply safe error-pattern matching rules for agentic engines.
Use these regex safety rules in agentic engines to prevent JavaScript infinite loops.
With the JavaScript global flag (/pattern/g), zero-width matches can cause infinite loops because:
regex.exec() with the g flag uses lastIndex to track positionlastIndex doesn't advance❌ NEVER USE THESE PATTERNS:
✅ ALWAYS USE PATTERNS LIKE THESE:
Always require at least one character match
.+ instead of .* when you need "something"Never use bare .* as the entire pattern
error.*.* or .*?Test patterns against empty string
Use specific anchors when possible
^error.*.*error$\berror\bAll error patterns must pass these tests:
The validate_errors.cjs script has built-in protections:
regex.lastIndex stops advancingWhen adding new error patterns to engines:
Write the pattern with required content
Test against empty string
make test-unitTestAllEnginePatternsSafeTest with actual log samples
Document the pattern
Patterns are converted from Go to JavaScript:
The (?i) prefix is removed because JavaScript uses the i flag instead.
If you find a pattern that matches empty string:
Before (unsafe):
After (safe):
Before committing pattern changes:
make test-unitTestAllEnginePatternsSafe passesTestErrorPatternsNoInfiniteLoopPotential passescd pkg/workflow/js && npm testpkg/workflow/engine_error_patterns_infinite_loop_test.gopkg/workflow/js/validate_errors.test.cjspkg/workflow/error_pattern_tuning_test.go// Required prefix before .*
/error.*/gi
/error.*permission.*denied/gi
// Specific structure with required content
/\[(\d{4}-\d{2}-\d{2})\]\s+(ERROR):\s+(.+)/g
// Required characters throughout
/access denied.*user.*not authorized/gi