error-pattern-safety
Skill5.3k starsChanged 6 months agoMITView on GitHub
Apply safe error-pattern matching rules for agentic engines.
Trending
Quiet since March.thin dataabout the whole repository
Who's talking about github/gh-aw
- A Hacker News story“GitHub Agentic Workflows”Hacker News · Feb 11, 2026 · 2 points
- @kcieslak.io“We see that a lot in our OSSed AW repository which uses fully agentic development - github.com/github/gh-aw …”Bluesky · Mar 24, 2026 · 1 likes
- @github-trending.bsky.social“🚀 Skyrocketing! 🚀 (200+ new stars) 📦 github / gh-aw ⭐ 2,482 (+213) 🗒 Go GitHub Agentic Workflows”Bluesky · Feb 15, 2026
The biggest 3 of 3 mentions linking to the repository that our crawl found. Each line is their own headline.
In this repository108 other files it gives its agents.
- AGENTS.mdAGENTS.md
- docs/src/content/docs/engines/claude.mdCLAUDE.md
- pkg/workflow/data/engines/claude.mdCLAUDE.md
- .squad/templates/copilot-instructions.mdCopilot instructions
- playwright-cliSkill
- agentic-workflowsSkill
- awf-release-integratorSkill
- checkout-credential-reviewSkill
- console-renderingSkill
- copilot-reviewSkill
- create-canvasSkill
- custom-agentsSkill
- custom-engine-implementationSkill
- debugging-workflowsSkill
- developer-code-organizationSkill
- developer-internalsSkill
- developer-releaseSkill
- developer-securitySkill
- developerSkill
- documentationSkill
- error-messagesSkill
- error-recovery-patternsSkill
- gh-agent-sessionSkill
- gh-agent-taskSkill
- github-copilot-agent-tips-and-tricksSkill
- github-discussion-querySkill
- github-issue-querySkill
- github-labels-querySkill
- github-mcp-serverSkill
- github-pr-querySkill
- github-scriptSkill
- github-workflows-querySkill
- go-codemodSkill
- go-lintersSkill
- http-mcp-headersSkill
- javascript-refactoringSkill
- jqschemaSkill
- messagesSkill
- npmSkill
- open-pull-requestSkill
- operational-value-designerSkill
- optimize-agentic-workflowSkill
- otel-queriesSkill
- pr-finisherSkill
- prompt-token-efficiencySkill
- pr-to-go-linterSkill
- reportingSkill
- resolve-merge-conflictsSkill
- restricted-tool-triageSkill
- review-agentic-workflowsSkill
- security-advisory-compat-enforcerSkill
- sergo-examplesSkill
- skillz-integrationSkill
- ssl-skill-normalizerSkill
- temporary-id-safe-outputSkill
- workflow-step-summariesSkill
- GitHub Agentic WorkflowsSkill
- {skill-name}Skill
- agent-collaborationSkill
- agent-conductSkill
- The first 60 shown.
The file
Show its rules and text
We split this skill into the rules it gives an agent
14 rules. About 0 are common, 8 are distinctive, and 6 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈8
Distinctive · estimate
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 9
Use these regex safety rules in agentic engines to prevent JavaScript infinite loops.
- Very specific: line 16
When a pattern matches zero-width, lastIndex doesn't advance
- Very specific: line 53
Use .+ instead of .* when you need "something"
- Distinctive: line 54
Ensure pattern has required prefix/suffix
- Very specific: line 57
Always combine with required text: error.*
- Very specific: line 58
Never just .* or .*?
- Distinctive: line 75
All error patterns must pass the same safety checks used by the repo’s unit suite:
- Very specific: line 91
Run the relevant package tests with make test-unit.
- Very specific: line 102
Use the relevant *.test.cjs suite under actions/setup/js/ or pkg/workflow/js/ for the area you changed, or run the repo’s JavaScript checks …
- Distinctive: line 121
When adding new error patterns to engines:
- Distinctive: line 138
Ensure it matches real errors
- Distinctive: line 139
Ensure it doesn't match informational text
- Distinctive: line 176
If you find a pattern that matches empty string:
- Distinctive: line 194
Before committing pattern changes:
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Error Pattern Safety Guidelines
Use these regex safety rules in agentic engines to prevent JavaScript infinite loops.
The Problem
With the JavaScript global flag (/pattern/g), zero-width matches can cause infinite loops 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:
// Pure .* - matches everything including empty string at end
/.*/g
// Single character with * - matches zero or more (including zero)
/a*/g
// Patterns that can match empty string
/(x|y)*/gSafe Pattern Examples
✅ ALWAYS USE PATTERNS LIKE THESE:
// 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/giPattern Safety Rules
- Always require at least one character match
- Use
.+instead of.*when you need "something" - Ensure pattern has required prefix/suffix
- Use
- Never use bare
.*as the entire pattern- Always combine with required text:
error.* - Never just
.*or.*?
- Always combine with required text:
- Test patterns against empty string
const regex = /your-pattern/g; if (regex.test("")) { throw new Error("Pattern matches empty string - DANGEROUS!"); } - Use specific anchors when possible
- Start:
^error.* - End:
.*error$ - Word boundaries:
\berror\b
- Start:
Validation Tests
All error patterns must pass the same safety checks used by the repo’s unit suite:
Go tests
// Test that pattern doesn't match empty string
func TestPatternSafety(t *testing.T) {
pattern := "your-pattern"
regex := regexp.MustCompile(pattern)
if regex.MatchString("") {
t.Error("Pattern matches empty string!")
}
}Run the relevant package tests with make test-unit.
JavaScript tests
test("should not match empty string", () => {
const regex = new RegExp("your-pattern", "g");
expect(regex.test("")).toBe(false);
});Use the relevant *.test.cjs suite under actions/setup/js/ or pkg/workflow/js/ for the area you changed, or run the repo’s JavaScript checks via make test-js.
Safety Mechanisms in the validation layer
The repo’s validation helpers include built-in protections for dangerous regex patterns:
- Zero-width detection: Checks whether a regex stops advancing across iterations
- Iteration warning: Warns when repeated runs approach a hang threshold
- Hard limit: Stops execution before runaway loops can lock the process
if (regex.lastIndex === lastIndex) {
core.error(`Infinite loop detected! Pattern: ${pattern.pattern}`);
break;
}Adding New Error Patterns
When adding new error patterns to engines:
- Write the pattern with required content
{ Pattern: `(?i)error.*permission.*denied`, LevelGroup: 0, MessageGroup: 0, Description: "Permission denied error", } - Test against empty string
- Run:
make test-unit - Checks:
TestAllEnginePatternsSafe
- Run:
- Test with actual log samples
- Ensure it matches real errors
- Ensure it doesn't match informational text
- Document the pattern
- Add clear description
- Note what it's designed to catch
Pattern Conversion: Go to JavaScript
Patterns are converted from Go to JavaScript:
// Go pattern (case-insensitive flag)
Pattern: `(?i)error.*permission.*denied`
// Converted to JavaScript
new RegExp("error.*permission.*denied", "gi")The (?i) prefix is removed because JavaScript uses the i flag instead.
Examples from Current Codebase
✅ Safe Patterns
// Requires "error" prefix
Pattern: `(?i)error.*permission.*denied`
// Requires specific timestamp format
Pattern: `(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z)\s+\[(ERROR)\]\s+(.+)`
// Requires "access denied" prefix
Pattern: `(?i)access denied.*user.*not authorized`How to Fix Unsafe Patterns
If you find a pattern that matches empty string:
Before (unsafe):
Pattern: `.*error.*` // Can match empty at start/endAfter (safe):
Pattern: `error.*` // Requires "error" at start
// OR
Pattern: `.*error.+` // Requires "error" and at least one char after
// OR
Pattern: `\berror\b.*` // Requires word "error"Testing Checklist
Before committing pattern changes:
- Run
make test-unit - Verify the relevant engine error-pattern tests still pass
- Run the JavaScript checks for the changed area with
make test-jsor the targeted Vitest suite - Verify the pattern matches intended error messages
- Verify the pattern does not match informational text or empty-string edge cases
References
- Go regex syntax: https://pkg.go.dev/regexp/syntax
- JavaScript regex: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
- Current repo validation:
make test-unitandmake test-js
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

