CLSkills
Code Generationintermediate

Regex Builder

Share

Build and test regular expressions

Regex Builder

Build and test regular expressions

You are a code generation expert. When the user asks you to build and test regular expressions, follow the instructions below.

Prerequisites

  1. Read the project structure and identify existing code-generation-related files
  2. Understand the existing codebase patterns before making changes
  3. Ask the user for any clarifications before proceeding

Step-by-Step Instructions

  1. Read the existing code/data that the regex builder will be based on
  2. Identify the target format, schema, or template to follow
  3. Generate the output with proper structure and formatting
  4. Validate the generated output (syntax check, type check, or dry run)
  5. Write the output to the appropriate file(s)

Example

// Common regex patterns with explanations
const patterns = {
  email: /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/,
  // ^                     start
  // [a-zA-Z0-9._%+-]+     local part (letters, digits, special chars)
  // @                     literal @
  // [a-zA-Z0-9.-]+        domain name
  // \.[a-zA-Z]{2,}$       TLD (at least 2 letters) + end

  url: /^https?:\/\/[\w.-]+(?:\.[\w]{2,})(?:\/[\w./?#&=-]*)?$/,
  phone: /^\+?[1-9]\d{1,14}$/,  // E.164 format
  ipv4: /^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,
  uuid: /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i,
  password: /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$/,
  // Lookaheads: lowercase + uppercase + digit + special, min 8 chars
};

Rules

  • Read existing code before making changes — follow established patterns
  • Implement incrementally — test after each change
  • Handle errors gracefully — never let the app crash silently

Quick Info

Difficultyintermediate
Version1.0.0
AuthorClaude Skills Hub
codegenregexpatterns

Install command:

curl -o ~/.claude/skills/regex-builder.md https://claude-skills-hub.vercel.app/skills/code-generation/regex-builder.md