agentleFS
kakarot-oncloudkakarot-oncloud/claude-dev-skills/skills/regex-builder/SKILL.md

regex-builder

Skill0 starsChanged 7 months agoMITView on GitHub

Builds, debugs, and explains regular expressions for any flavor (PCRE, JavaScript, Python, Go RE2, POSIX). Provides test cases that cover matches, non-matches, and edge cases. Use this skill when the user asks for a regex, says "what's the pattern for X", needs to validate/parse/extract text, or asks to debug or explain an existing regex.

5 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

2 rules. 0 are common, 2 are distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 3 edited versions we read keep these.

  • 2

    Distinctive

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Clarify the flavor: Ask if unspecified; default to PCRE / JavaScript (similar enough for most cases).

    line 12
  2. Distinctive:

    If the user asks for one of these, use the well-tested standard rather than re-deriving:

    line 54

“Common” is measured: kept by at least 6 in 10 of the 3 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Regex Builder

You write correct, readable regex with test coverage.

Process

  1. Clarify the flavor. Ask if unspecified; default to PCRE / JavaScript (similar enough for most cases).
  2. Clarify the goal. Match-only, extract groups, validate-and-reject, search-and-replace?
  3. Get sample inputs — at least 2 should-match and 2 should-not-match examples. Ask if the user didn't provide them.
  4. Write the regex with anchors as appropriate.
  5. Show it commented (/x mode style or inline comments) for non-trivial patterns.
  6. Provide test cases — a small table showing input → match (and captured groups).

Output template

Pattern (JavaScript flavor):
/^[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,}$/i

Explanation:
- ^                start of string
- [a-z0-9._%+-]+   local part: letters, digits, dot, common symbols
- @                literal @
- [a-z0-9.-]+      domain: letters, digits, dot, hyphen
- \.[a-z]{2,}      TLD: dot + 2+ letters
- $                end of string
- i flag           case-insensitive

Tests:
✓ alice@example.com
✓ bob.smith+filter@sub.example.co
✗ no-at-symbol.com
✗ trailing@dot.
✗ @missing-local.com

Rules

  1. Anchor when validating (^...$); don't anchor when searching/extracting.
  2. Prefer character classes over alternation ([abc] not a|b|c).
  3. Escape literals — dots, parens, brackets, backslashes — even when "probably safe".
  4. Use non-capturing groups (?:...) when you don't need the capture.
  5. Warn about catastrophic backtracking — flag patterns with nested quantifiers like (a+)+.
  6. Flavor differences matter: lookbehind isn't in older JS engines or Go RE2; named groups syntax varies; Unicode handling varies. Call this out when the user's target flavor lacks a feature.
  7. Don't use regex to parse HTML, JSON, or other recursive grammars. Recommend a real parser.

Common patterns to recognize

If the user asks for one of these, use the well-tested standard rather than re-deriving:

  • Email — RFC 5322 is impractical; use the pragmatic pattern above and validate by sending mail.
  • URL — use URL constructor in JS / urllib.parse in Python instead of regex.
  • UUID v4 — ^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i
  • IPv4 — recommend ipaddress module / library over regex for correctness.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.