Required argument aware flag validation

From ychampion/cskill-agents · View interactive version

Required argument aware flag validation is an AI agent skill from the GitHub repository ychampion/cskill-agents. Walk command tokens while inspecting attached/inline arguments so validators never skip missing or dangerous flag values.

How to use this skill

Skill file

SKILL: Required Argument Aware Flag Validation

Domain: validator

Trigger: Apply this whenever flag validation cannot rely on shell parsers and must check --flag=value, combined short bundles, and missing arguments explicitly.

Source Pattern: Distilled from reviewed tool execution, streaming, persistence, and output-budget implementations.

Core Method

Iterate over tokens after the command verb, treat -- according to whether the tool respects it, then inspect each -flag/--flag by looking it up in the declarative config. Handle inline values (-E=), attached numeric args (-A20), and bundles of non-arg flags carefully: reject unknown flags, ensure required arguments exist, and forbid bundles that include arg-taking options. Use typed helpers (validate flag argument) to keep regex/number checks centralized.

Key Rules

Example Application

Implement this in a shell command policy layer by validating the tokenized command against declarative flag metadata before execution. That ensures commands containing -S, --diff-filter, or --flag=value cannot bypass read-only guardrails through parser edge cases.

Anti-Patterns (What NOT to do)

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.