regex-architect
Skill12 starsChanged 5 months agoMITView on GitHub
Designs, explains, hardens, and tests regular expressions for parsing and validation tasks (emails, URLs, dates, IPs, log lines, CSV fields, identifiers, etc.) while actively defending against catastrophic backtracking (ReDoS). Use this skill when the user asks to "write a regex", "build/fix a regular expression", "match/extract/validate X with regex", "explain this regex", "why is my regex slow/hanging", check for "ReDoS"/"catastrophic backtracking", or convert a pattern between flavors (PCRE, Python re, JavaScript, Java, Go RE2, .NET). Covers capturing/named groups, anchors, lookarounds, Unicode, and flavor portability.
We split this skill into the rules it gives an agent
9 rules. About 0 are common, 5 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 21
Use this skill whenever a task involves matching, extracting, replacing, splitting, or validating text with a pattern — or …
- Distinctive: line 29
Search/extract usually must NOT be anchored.
- Distinctive: line 35
Readability is a feature: Use named groups, verbose/extended mode, and comments for anything non-trivial.
- Distinctive: line 37
Validate with structured logic when regex is the wrong tool: Do not regex HTML, nested brackets, or full email RFC 5322.
- Very specific: line 56
Test it: Run scripts/regex_test.py with positive and negative cases.
- Very specific: line 58
Note portability: If the user may switch flavors, flag flavor-specific constructs (lookbehind, named-group syntax, \d Unicode semantics, …
- Distinctive: line 85
Always provide both the raw pattern and a one-line explanation of anchoring intent.
- Very specific: line 86
Use non-capturing groups (?:...) unless you need the capture.
- Very specific: line 92
Prefer [0-9] over \d when you must exclude non-ASCII digits (\d matches Unicode digits in many flavors).
≈ “Common” is an estimate: at least 1 in 5 of the 308,232 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
Regex Architect
Overview
Build correct, readable, and safe regular expressions, then prove they work. Keywords: regex, regular expression, pattern matching, ReDoS, catastrophic backtracking, validation, extraction, capture group, named group, lookahead, lookbehind, anchor, Unicode, PCRE, RE2, flavor portability.
This skill exists because regex is easy to write and hard to write well. Naive patterns silently accept bad input, reject good input, or hang a server when fed an adversarial string. The job is not just "produce a pattern" — it is to produce a pattern that is anchored correctly, scoped to the right flavor, free of exponential backtracking, and accompanied by a test plan.
Use this skill whenever a task involves matching, extracting, replacing, splitting, or validating text with a pattern — or explaining/debugging an existing one.
Core Principles
- Clarify before constructing. Know the flavor, the input source, whether you are validating (whole string) or searching (substring), and what counts as valid. Ambiguity here produces wrong regexes.
- Anchor on purpose. Validation almost always needs
^...$(or\A...\z). Search/extract usually must NOT be anchored. Mismatched anchoring is the #1 correctness bug. - Prefer explicit character classes over
..is greedy, matches almost anything, and is a backtracking magnet. Use[^"],[^\n],\d, etc. - Make quantified subpatterns mutually exclusive. Overlapping alternations or
nested quantifiers (
(a+)+,(a|a)*,(.*)*) cause catastrophic backtracking. - Readability is a feature. Use named groups, verbose/extended mode, and comments for anything non-trivial. A regex nobody can edit is a liability.
- Validate with structured logic when regex is the wrong tool. Do not regex HTML, nested brackets, or full email RFC 5322. Say so and offer a parser.
Workflow
- Gather requirements (see
references/clarifying-questions.md):- Target flavor / language runtime.
- Validation vs. search vs. replace vs. split.
- Exact set of valid and invalid examples (ask for at least 2 of each).
- Multiline? Unicode? Case sensitivity? Performance constraints / untrusted input?
- Choose a strategy. Pick character classes, anchoring, and grouping. Consult
references/patterns-cookbook.mdfor vetted building blocks rather than inventing from scratch. - Draft the pattern in the requested flavor. Use named capture groups and, for non-trivial patterns, provide a verbose/commented version too.
- Audit for ReDoS using the checklist in
references/redos-guide.md. Rewrite nested/overlapping quantifiers; prefer atomic groups, possessive quantifiers, or bounded{0,n}quantifiers. If the runtime is RE2/Go/Rust, note it is already linear-time and lookarounds/backrefs are unsupported. - Explain it. Provide a token-by-token breakdown so the user can maintain it.
- Test it. Run
scripts/regex_test.pywith positive and negative cases. It also runs a lightweight ReDoS timing probe. Report pass/fail per case. - Note portability. If the user may switch flavors, flag flavor-specific
constructs (lookbehind, named-group syntax,
\dUnicode semantics, inline flags) perreferences/flavor-portability.md.
Quick Decision Framework
- "Is this string entirely valid?" → anchor with
^$(or\A\z); usere.fullmatchin Python. - "Find all occurrences." → no anchors; use global/
findall; mind overlapping matches. - "Untrusted/large input?" → prioritize linear-time design; consider RE2-family engine; cap input length before matching.
- "Nested or recursive structure (HTML, JSON, code)?" → do NOT use regex; use a parser.
- "Just needs a yes/no on a simple format?" → small anchored class-based pattern.
Worked Example (short)
Validate a US ZIP (5 digits, optional -####), JavaScript:
/^\d{5}(?:-\d{4})?$/^/$anchor the whole string.\d{5}exactly five digits.(?:-\d{4})?optional non-capturing group: hyphen + four digits.
Why it is ReDoS-safe: fixed-count quantifiers, no nested/overlapping repetition.
See examples/worked-example.md for a full email-validation walkthrough including
a naive-vs-safe comparison and test output.
Best Practices
- Always provide both the raw pattern and a one-line explanation of anchoring intent.
- Use non-capturing groups
(?:...)unless you need the capture; name the ones you keep. - For validation, return whole-string semantics explicitly (
fullmatch,\A...\z, or^...$with the right flags). - Escape user-provided literals; never interpolate raw user input into a pattern.
- Cap input length and/or set engine timeouts when matching untrusted data.
- Offer a verbose/
x-mode version for any pattern longer than ~40 chars. - Prefer
[0-9]over\dwhen you must exclude non-ASCII digits (\dmatches Unicode digits in many flavors).
Common Pitfalls
- Unanchored validation —
/\d{5}/matches insideabc12345xyz. Anchor it. - Greedy
.*across delimiters —<.*>over<a><b>grabs everything; use<[^>]*>or lazy<.*?>with care. - Nested quantifiers —
(\d+)+,(a*)*,(.*,)*→ catastrophic backtracking. - Unescaped dot/metachars in literals —
3.14matches3x14; escape to3\.14. ^/$with multiline — they match line boundaries underm; use\A/\z(or\Z) for true string ends.- Backreferences/lookbehind in RE2/Go/Rust — unsupported; redesign.
- Trying to regex HTML/recursive grammars — wrong tool; use a parser.
\bword-boundary surprises — depends on\wdefinition and Unicode mode.
Bundled Files
references/patterns-cookbook.md— vetted, safe patterns for common formats with notes and traps.references/redos-guide.md— how catastrophic backtracking happens and how to fix it.references/flavor-portability.md— cross-flavor syntax differences and a mapping table.references/clarifying-questions.md— the question set to ask before writing a pattern.scripts/regex_test.py— runnable Python tester for positive/negative cases plus a ReDoS timing probe.examples/worked-example.md— end-to-end email-validation example with test output.
Other versions2 projects use a version of this.
Word for word · 2
- jaskirat1616/grok-skills★ 22100% same
- JayRHa/AgentSkills★ 12100% same
Edited · 0
None found.
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository75 other files it gives its agents.
- 0-templateSkill
- ab-test-analyzerSkill
- adr-authorSkill
- api-designerSkill
- api-docs-writerSkill
- aws-cost-optimizerSkill
- bash-script-hardeningSkill
- blog-post-writerSkill
- book-summarizerSkill
- changelog-keeperSkill
- chart-chooserSkill
- code-reviewerSkill
- competitive-analysisSkill
- concept-explainerSkill
- cover-letter-writerSkill
- cron-schedulerSkill
- data-pipeline-architectSkill
- debug-detectiveSkill
- decision-matrixSkill
- dependency-upgraderSkill
- dockerfile-proSkill
- email-composerSkill
- error-handling-patternsSkill
- event-plannerSkill
- flashcard-generatorSkill
- gdpr-data-mapperSkill
- gift-advisorSkill
- github-actions-builderSkill
- git-workflowSkill
- habit-builderSkill
- incident-postmortemSkill
- interview-prepSkill
- job-description-writerSkill
- json-schema-authorSkill
- kubernetes-manifest-authorSkill
- language-tutorSkill
- meal-plan-builderSkill
- meeting-summarizerSkill
- mermaid-diagram-builderSkill
- nginx-config-proSkill
- observability-setupSkill
- okr-writerSkill
- pandas-data-cleaningSkill
- people-dataSkill
- performance-profilerSkill
- personal-budget-plannerSkill
- presentation-builderSkill
- project-plannerSkill
- prompt-engineerSkill
- proofreaderSkill
- public-speaking-coachSkill
- rag-pipeline-designerSkill
- readme-generatorSkill
- refactoring-guideSkill
- release-notes-writerSkill
- resume-writerSkill
- salary-negotiatorSkill
- secrets-managerSkill
- secure-code-reviewSkill
- secure-password-policySkill
- The first 60 shown.
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.

