Feature Request: Enhanced Parameter System for Slash Commands

Resolved 💬 7 comments Opened Aug 25, 2025 by dkmaker Closed Jan 4, 2026

Feature Request: Enhanced Parameter System for Slash Commands

Summary

Replace the current $ARGUMENTS system with a YAML-based parameter declaration that includes validation, conditional inclusion, and named parameters. This change would dramatically reduce AI token consumption while improving user experience and command reliability.

Current Problem: Massive Token Waste

The existing slash command system processes all template text regardless of parameter usage:

/create-pr "Fix bug" feature/auth
# Current: AI processes entire template with unused placeholders
# Tokens: ~150-200 per command execution

Every command sends the full template to the AI, including text for parameters that weren't provided, resulting in 60-80% token waste on typical usage.

Proposed Solution: Conditional Parameter Inclusion

YAML Parameter Declaration

---
description: Create a new TypeScript component with validation
arguments:
  component_name:
    required: true
    hint: "Component name in PascalCase"
    validation_regex: "^[A-Z][a-zA-Z0-9]+$"
    validation_error: "Component name must be PascalCase (e.g., UserProfile)"
  
  author_email:
    required: true
    hint: "Author email for component header"
    validation_regex: "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$"
    validation_error: "Must be a valid email address"
  
  template_file:
    required: false
    hint: "Template file to base component on"
    validation_file: "exists"
    validation_regex: "\.tsx?$"
    validation_error: "Template must be a TypeScript file (.ts or .tsx)"
  
  styles_file:
    required: false
    hint: "CSS/SCSS file for component styles"
    validation_file: "exists"
    validation_regex: "\.(css|scss|sass)$"
    validation_error: "Styles file must be CSS, SCSS, or Sass"
  
  with_tests:
    type: flag
    hint: "Generate test file alongside component"
  
  export_default:
    type: flag
    hint: "Use default export instead of named export"
---

Create TypeScript component $component_name by $author_email.

${template_file:+Base on template: $template_file}

${styles_file:+Include styles from: $styles_file}

${with_tests:+Generate corresponding test file.}

${export_default:+Use default export.}

Create the component following our TypeScript standards with proper typing and documentation.

Key Features

1. Conditional Inclusion (${param:+text})

  • Only includes text blocks when parameters exist
  • Eliminates token waste on unused parameters

2. Multi-Type Client-Side Validation

  • Regex validation for formats (PascalCase names, email addresses, file extensions, etc.)
  • File system validation (template files exist, output directories writable, etc.)
  • Prevents invalid commands from reaching AI (0 tokens spent on errors)

3. Named Parameters

  • Replace $ARGUMENTS with $title, $branch, etc.
  • AI receives precise, pre-parsed parameters

4. Flag Parameters

  • Boolean switches like --draft, --verbose
  • Only processed when actually used

Token Savings Impact

| Usage Pattern | Current Tokens | Enhanced Tokens | Savings |
|--------------|---------------|-----------------|---------|
| Minimal (2 params) | 150 | 35 | 77% |
| Average (3 params) | 150 | 55 | 63% |
| Full (5 params) | 150 | 95 | 37% |
| Invalid input | 150 | 0 | 100% |

Real-world impact: User running 50 commands/day saves 3,000-6,000 tokens daily.

Example Usage

# Minimal command
/create-component UserProfile dev@company.com
# AI receives: "Create TypeScript component UserProfile by dev@company.com. Create the component following our TypeScript standards with proper typing and documentation." (30 tokens)

# With optional template file
/create-component UserProfile dev@company.com ./templates/BaseComponent.tsx
# AI receives: "Create TypeScript component UserProfile by dev@company.com. Base on template: ./templates/BaseComponent.tsx. Create the component following our TypeScript standards with proper typing and documentation." (45 tokens)

# With styles and flags
/create-component UserProfile dev@company.com --styles_file ./styles/profile.scss --with_tests --export_default
# AI receives: "Create TypeScript component UserProfile by dev@company.com. Include styles from: ./styles/profile.scss. Generate corresponding test file. Use default export. Create the component following our TypeScript standards with proper typing and documentation." (55 tokens)

# Validation errors (client-side, 0 AI tokens)
/create-component userProfile dev@company.com
# Error: "Component name must be PascalCase (e.g., UserProfile)"

/create-component UserProfile invalid-email
# Error: "Must be a valid email address"

/create-component UserProfile dev@company.com ./missing-template.tsx
# Error: "Template must be a TypeScript file (.ts or .tsx)"

Benefits

Token Efficiency

  • 60-80% reduction in AI token consumption for typical usage
  • 100% elimination of tokens spent on validation errors
  • Only relevant command parts sent to AI

User Experience

  • Parameter hints and validation feedback
  • Clear error messages before AI processing
  • Support for both positional and named parameters

Command Reliability

  • Client-side validation prevents malformed requests
  • Structured parameter handling reduces parsing errors
  • Self-documenting command definitions

Implementation

The system would:

  1. Parse YAML parameter definitions from command headers
  2. Validate user input using multiple validation types:
  • validation_regex: Pattern matching for component names, emails, file extensions, etc.
  • validation_file: File system checks (template files exist, output directories writable, etc.)
  • Combined validation: Parameters can use multiple validation types
  1. Build conditional command strings using ${param:+text} syntax
  2. Send only relevant text to AI for processing

This maintains backward compatibility while enabling significant token savings and improved user experience.

Priority

This feature would provide immediate, measurable value to all Claude Code users through:

  • Dramatically reduced AI token costs
  • Improved command reliability and user experience
  • More precise AI interactions with better outcomes

The token savings alone make this a high-impact enhancement for the platform's efficiency and user satisfaction.

View original on GitHub ↗

This issue has 7 comments on GitHub. Read the full discussion on GitHub ↗