Skip to content
cccskills
FreePublished on GitHub

argument-validator-generator

Generate CLI argument validation code with type coercion, constraints, custom checks, aliases, and clear error messages. It can create schemas and normalize values for languages such as TypeScript, Python, Go, and Rust.

OriginalShow the original description

Generate argument validation logic with type coercion, constraints, custom validators, and helpful error messages for CLI applications.

a5c-ai/babysitter1,872 stars(GitHub 1,872 + cccskills 0)

Run score Not tested

See how to install

Good for

  • Validating CLI argument types and ranges
  • Adding custom checks for command inputs
  • Normalizing aliases and input values
  • Creating clear validation errors

Files included (2)

  • SKILL.md7.5 KB
  • README.md1.8 KB

SKILL.md (original)

Review the instructions the agent will receive before you install.

Argument Validator Generator

Generate comprehensive argument validation logic for CLI applications with type coercion and constraint checking.

Capabilities

  • Generate type coercion functions for arguments
  • Create custom validators with constraint checking
  • Set up validation error messages
  • Implement value normalization
  • Configure mutually exclusive validation
  • Generate validation schemas

Usage

Invoke this skill when you need to:

  • Add type validation to CLI arguments
  • Create custom argument validators
  • Implement complex constraint checking
  • Generate helpful validation error messages

Inputs

ParameterTypeRequiredDescription
languagestringYesTarget language (typescript, python, go, rust)
validatorsarrayYesList of validators to generate
outputPathstringNoOutput path for generated files

Validator Structure

{
  "validators": [
    {
      "name": "port",
      "type": "number",
      "constraints": {
        "min": 1,
        "max": 65535
      },
      "errorMessage": "Port must be between 1 and 65535"
    },
    {
      "name": "email",
      "type": "string",
      "pattern": "^[\\w.-]+@[\\w.-]+\\.\\w+$",
      "errorMessage": "Invalid email format"
    },
    {
      "name": "environment",
      "type": "enum",
      "values": ["development", "staging", "production"],
      "aliases": { "dev": "development", "prod": "production" }
    }
  ]
}

Generated Code Patterns

TypeScript Validators

import { z } from 'zod';

// Port validator
export const portSchema = z
  .number()
  .int()
  .min(1, 'Port must be at least 1')
  .max(65535, 'Port must be at most 65535');

export function validatePort(value: unknown): number {
  const parsed = typeof value === 'string' ? parseInt(value, 10) : value;
  return portSchema.parse(parsed);
}

// Email validator
export const emailSchema = z
  .string()
  .email('Invalid email format')
  .toLowerCase();

export function validateEmail(value: unknown): string {
  return emailSchema.parse(value);
}

// Environment enum with aliases
const envAliases: Record<string, string> = {
  dev: 'development',
  prod: 'production',
};

export const environmentSchema = z
  .string()
  .transform((val) => envAliases[val] || val)
  .pipe(z.enum(['development', 'staging', 'production']));

export function validateEnvironment(value: unknown): string {
  return environmentSchema.parse(value);
}

Python Validators

from typing import Any, List, Optional, Union
import re

class ValidationError(Exception):
    """Raised when validation fails."""
    pass

def validate_port(value: Any) -> int:
    """Validate port number."""
    try:
        port = int(value)
    except (TypeError, ValueError):
        raise ValidationError(f"Invalid port number: {value}")

    if not 1 <= port <= 65535:
        raise ValidationError("Port must be between 1 and 65535")

    return port

def validate_email(value: Any) -> str:
    """Validate email address."""
    if not isinstance(value, str):
        raise ValidationError(f"Email must be a string, got {type(value).__name__}")

    pattern = r'^[\w.-]+@[\w.-]+\.\w+$'
    if not re.match(pattern, value):
        raise ValidationError("Invalid email format")

    return value.lower()

ENV_ALIASES = {'dev': 'development', 'prod': 'production'}
VALID_ENVIRONMENTS = ['development', 'staging', 'production']

def validate_environment(value: Any) -> str:
    """Validate environment name."""
    if not isinstance(value, str):
        raise ValidationError(f"Environment must be a string")

    normalized = ENV_ALIASES.get(value, value)
    if normalized not in VALID_ENVIRONMENTS:
        raise ValidationError(
            f"Invalid environment: {value}. "
            f"Must be one of: {', '.join(VALID_ENVIRONMENTS)}"
        )

    return normalized

Go Validators

package validators

import (
    "fmt"
    "regexp"
    "strconv"
    "strings"
)

// ValidationError represents a validation failure
type ValidationError struct {
    Field   string
    Message string
}

func (e *ValidationError) Error() string {
    return fmt.Sprintf("%s: %s", e.Field, e.Message)
}

// ValidatePort validates a port number
func ValidatePort(value string) (int, error) {
    port, err := strconv.Atoi(value)
    if err != nil {
        return 0, &ValidationError{
            Field:   "port",
            Message: fmt.Sprintf("invalid port number: %s", value),
        }
    }

    if port < 1 || port > 65535 {
        return 0, &ValidationError{
            Field:   "port",
            Message: "port must be between 1 and 65535",
        }
    }

    return port, nil
}

// ValidateEmail validates an email address
func ValidateEmail(value string) (string, error) {
    pattern := `^[\w.-]+@[\w.-]+\.\w+$`
    matched, _ := regexp.MatchString(pattern, value)

    if !matched {
        return "", &ValidationError{
            Field:   "email",
            Message: "invalid email format",
        }
    }

    return strings.ToLower(value), nil
}

var envAliases = map[string]string{
    "dev":  "development",
    "prod": "production",
}

var validEnvironments = []string{"development", "staging", "production"}

// ValidateEnvironment validates environment name
func ValidateEnvironment(value string) (string, error) {
    if alias, ok := envAliases[value]; ok {
        value = alias
    }

    for _, env := range validEnvironments {
        if env == value {
            return value, nil
        }
    }

    return "", &ValidationError{
        Field:   "environment",
        Message: fmt.Sprintf("invalid environment: %s", value),
    }
}

Validation Patterns

Composite Validators

// URL with specific protocol
export const apiUrlSchema = z
  .string()
  .url()
  .refine(
    (url) => url.startsWith('https://'),
    'API URL must use HTTPS'
  );

// File path that must exist
export const existingFileSchema = z
  .string()
  .refine(
    (path) => fs.existsSync(path),
    (path) => ({ message: `File not found: ${path}` })
  );

Dependent Validation

// Validate that end date is after start date
export const dateRangeSchema = z.object({
  startDate: z.coerce.date(),
  endDate: z.coerce.date(),
}).refine(
  (data) => data.endDate > data.startDate,
  'End date must be after start date'
);

Workflow

  1. Analyze requirements - Review validation needs
  2. Generate base validators - Type coercion and basic checks
  3. Add constraints - Min/max, patterns, enums
  4. Create error messages - Helpful, actionable messages
  5. Add aliases/transforms - Normalize input values
  6. Generate tests - Validation test cases

Best Practices Applied

  • Type coercion before validation
  • Descriptive error messages
  • Input normalization (lowercase, trim)
  • Alias support for common values
  • Composable validation schemas
  • Consistent error types

Target Processes

  • argument-parser-setup
  • error-handling-user-feedback
  • cli-command-structure-design

Reviews

No reviews yet. Tell others what you thought.

Comments

No login needed. Share how it worked for you, ask a question, or note where it did not run.

No comments yet. Be the first to write one.

Comments are published right away. Do not include personal information such as email addresses or phone numbers. Up to 2 URLs.

0 / 1,000 characters

This form is protected by reCAPTCHA, and the Google Privacy Policy and Terms of Service apply.

More skills from this repository

Get implementations and guidance for advanced data structures used in competitive programming and complex algorithm problems. The skill covers balanced trees, persistent structures, tree decompositions, and range-query tools, with usage notes and complexity information.

  • Implementing a treap or splay tree
  • Answering range queries with a wavelet tree
  • Handling dynamic tree operations
a5c-ai/babysitter1.9KUpdated Sep 17, 2026

Use this skill for an independent, evidence-based code review focused on whether an implementation meets its specification. It returns a clear PASS or FAIL verdict with file and line references, using a fresh reviewer for each re-review.

  • Checking whether code meets a specification
  • Running a final cross-unit code review
  • Re-reviewing a change after it failed
a5c-ai/babysitter1.9KUpdated Sep 17, 2026

agent-booster

FreeSummary

Apply supported repetitive code edits with WebAssembly (WASM), a portable runtime, when a code pattern matches. Transforms include modernizing variable declarations, adding types or error handling, and converting Promise chains; unmatched patterns go to a coder fallback.

  • Modernizing repeated variable declarations
  • Adding TypeScript annotations to matching functions
  • Wrapping simple calls in error handling
a5c-ai/babysitter1.9KUpdated Sep 17, 2026

Coordinates long-lived Crew agents and transient Polecat workers by assigning work through hooks, handing tasks between agents, and nudging stalled sessions. It also explains a three-level hook hierarchy and provides commands for listing, feeding, and reviving agents.

  • Assign work to persistent and short-lived agents
  • Hand off tasks between agents and prompt stalled workers
  • Set up shared, role-specific, and rig-specific hooks
a5c-ai/babysitter1.9KUpdated Sep 17, 2026

Turn algorithm execution into visual steps, showing how arrays, trees, graphs, and dynamic programming tables change. Generate formats such as ASCII, SVG, GIF, or HTML to explain concepts, inspect behavior, or support debugging.

  • Explaining sorting or search step by step
  • Showing graph traversal or shortest-path execution
  • Visualizing dynamic programming table changes
a5c-ai/babysitter1.9KUpdated Sep 17, 2026

anti-drift

FreeSummary

Coordinate multi-agent work with short task cycles and regular checkpoints. The skill checks whether agents share consistent state and stay within assigned roles, then scores drift and guides corrections or human escalation when needed.

  • Coordinating agents on related subtasks
  • Keeping high-risk work aligned with its scope
  • Checking shared memory consistency
a5c-ai/babysitter1.9KUpdated Sep 17, 2026

See all skills by a5c-ai

Report a problem with this skill