Regex Backtracking Guard
by Prateek
Explains a regular expression, tests it against samples, and flags catastrophic backtracking before it freezes a server.
Free
What it does
- Explains what a pattern accepts in plain words
- Tests the pattern against sample strings
- Flags nested quantifiers and overlapping alternation
- Gives a safer rewrite for risky patterns
Who it's for
Software developers and engineers
Catch dangerous patterns that could crash your server before you push code to production.
Try asking: “Check this regex for ReDoS risks: ^(a+)+$ with sample aaaa!”
Technical leads and code reviewers
Quickly understand what a complex pattern does and ensure it is safe for your team to use.
Try asking: “Explain what this regex does and tell me if it is slow: ^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$”
Security researchers and testers
Identify weak input validation patterns that could be used in a denial of service attack.
Try asking: “Test this pattern for catastrophic backtracking: (a|aa)+$ with sample aaaaaaaaaaaaaab”
Regex Backtracking Guard
Example session with this skill installed
Check if this regex is safe: ^(a+)+$ and test it with the string aaaa!
- Read your context and instructions
- Compiled the regex backtracking guard
I have analyzed your regular expression pattern to check for safety and performance risks. Here is what I found:
Verdict: HIGH RISK
In plain words
This pattern looks for a string that starts with one or more of the letter "a", and it allows that group to repeat multiple times until the end of the string.
Test results
- Sample:
aaaa! - Result: No match (The pattern expects only "a" characters until the end, but found an exclamation mark).
Warnings table
| Feature | Why it backtracks | Safer form |
|---|---|---|
Nested Quantifier (a+)+ | The engine tries every possible way to group the "a"s, which grows exponentially on failure. | ^a+$ |
Rewrite
To achieve a similar result safely, you should use:
^a+$
This version removes the nested repetition. It still matches a sequence of "a" characters but does so in a straight line without getting stuck in a loop if the match fails at the end.
Would you like me to test this rewrite against any other sample strings?
Connects securely to your tools. The creator never sees your data.
About this skill
If you have ever seen a server freeze or a website hang because of a complex search pattern, you know how tricky regular expressions can be. This skill helps you find those hidden "bombs" in your code known as ReDoS risks. It looks at your pattern, explains exactly what it is looking for in plain English, and warns you if it could cause a crash.
How it works
- You provide a regular expression pattern and some sample text you want to test against it.
- Your AI agent runs a check to see if the pattern has dangerous parts that could lead to "catastrophic backtracking."
- You get a clear report showing if the pattern is safe, what it matches, and any specific warnings.
- If the pattern is risky, the skill provides a rewritten version that does the same job but more safely.
Frameworks & tools
This skill uses a Python script to analyze patterns and check for known dangerous structures like nested quantifiers or overlapping branches.
Why this beats prompting it yourself
Most AI agents can explain a regex, but they often miss the deep technical reasons why a pattern might hang under heavy load. This skill uses specific rules to hunt for "catastrophic backtracking" that a general chat might overlook, giving you a formal safety verdict.
Use cases
- Reviewing a new search pattern before adding it to your app
- Fixing a specific piece of code that makes your server run slow
- Understanding a complex pattern left behind by another developer
- Testing if a pattern correctly matches or rejects specific examples
Known limitations
This uses static checks and rules of thumb, not a mathematical proof. It cannot see every possible way a specific server might optimize or fail.
This skill utilizes a Python script (check_regex.py) to perform static analysis on regular expressions. It identifies ReDoS (Regular Expression Denial of Service) vulnerabilities by detecting nested quantifiers, overlapping branches in alternations, and unbounded backreferences. It works with standard regex flags and provides heuristic-based risk scores (HIGH, REVIEW, OK) based on the presence of catastrophic backtracking patterns.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before buying a skill.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Free to use
No account required to browse
Trust & safety
Security scan
Security scan passed 1 day ago
- Free with an Agensi account
- Software
Python 3.9+
Permissions
Static analysis only. No files read and no network calls.
What's inside
Frequently Asked Questions
New in Security
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for Security.