skills/arg-parser/SKILL.md
Type-safe CLI argument parser with MCP integration Zod validation auto-generated tools and interactive prompts
npx skillsauth add alcyone-labs/agent-skills arg-parserInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Use this skill when user needs to:
zodFlagSchema for flag definitions with Zod v4 syntax#/core/types for interfaces IFlag IHandlerContext TParsedArgs#/* alias e.g. #/mcp/mcp-integration./ e.g. ./FlagManagerstring if not specifiedmandatory property not required^[a-zA-Z0-9_-]{1,64}$createMcpLogger for data-safe logging in MCP contextprompt property to flags for interactive mode supportpromptSequence for explicit ordering (1 = first, 2 = second)promptSequence not specified--interactive or -i flag to trigger interactive mode (default promptWhen)text, password, confirm, select, multiselectIHandlerContext with promptAnswers from previous promptstrue for valid or string for error messageonCancel callback or exits gracefully--interactive on BOTH root AND sub-parserdefaultValue automatically used as prompt initial when not explicitly setskip: true or skip: condition to skip prompts based on previous answersallowSelectAll: true on multiselect prompts for quick select/deselect allimport { ArgParser } from "@alcyone-labs/arg-parser";
const parser = new ArgParser({
appName: "My CLI",
appCommandName: "my-cli",
handler: async (ctx) => {
console.log("Running with:", ctx.args);
},
}).addFlags([
{
name: "input",
options: ["--input", "-i"],
type: String,
description: "Input file",
},
{
name: "verbose",
options: ["--verbose", "-v"],
type: Boolean,
defaultValue: false,
},
]);
parser.parse(process.argv);
const parser = new ArgParser({...})
.addFlags([...])
.withMcp({
serverInfo: { name: "my-cli-mcp", version: "1.0.0" },
defaultTransport: { type: "stdio" }
})
await parser.parse(process.argv)
.addFlag({
name: "config",
options: ["--config", "-c"],
type: z.object({
host: z.string(),
port: z.number()
}),
description: "Configuration object"
})
parser.addTool({
name: "process",
description: "Process data",
flags: [
{ name: "input", options: ["--input"], type: String, mandatory: true },
{ name: "output", options: ["--output"], type: String },
],
handler: async (ctx) => ({ processed: true, input: ctx.args.input }),
outputSchema: "successWithData",
});
const subParser = new ArgParser({
appName: "My CLI",
handler: async (ctx) => {
/* subcommand logic */
},
}).addFlags([
/* subcommand flags */
]);
parser.addSubCommand({
name: "sub",
description: "Subcommand description",
parser: subParser,
});
new ArgParser({...}, undefined, FlagInheritance.AllParents)
const parser = new ArgParser({
appName: "deploy-tool",
promptWhen: "interactive-flag",
handler: async (ctx) => {
if (ctx.isInteractive) {
console.log("Interactive answers:", ctx.promptAnswers);
}
const env = ctx.args.environment || ctx.promptAnswers?.environment;
console.log(`Deploying to ${env}...`);
},
});
// Add --interactive flag
parser.addFlag({
name: "interactive",
options: ["--interactive", "-i"],
type: "boolean",
flagOnly: true,
description: "Run in interactive mode",
});
// Add promptable flag
parser.addFlag({
name: "environment",
options: ["--env", "-e"],
type: "string",
prompt: async () => ({
type: "select",
message: "Select environment:",
options: ["staging", "production"],
}),
} as IPromptableFlag);
await parser.parse();
parser.addFlag({
name: "environment",
options: ["--env"],
type: "string",
promptSequence: 1,
prompt: async () => ({
type: "select",
message: "Select environment:",
options: ["staging", "production"],
}),
} as IPromptableFlag);
parser.addFlag({
name: "version",
options: ["--version"],
type: "string",
promptSequence: 2,
prompt: async (ctx) => {
// Access previous answer
const env = ctx.promptAnswers?.environment;
const versions = await fetchVersions(env);
return {
type: "select",
message: `Select version for ${env}:`,
options: versions,
};
},
} as IPromptableFlag);
parser.addSubCommand({
name: "init",
description: "Initialize repository",
promptWhen: "missing", // Prompt if required flags missing
parser: initParser,
onCancel: () => console.log("Init cancelled"),
});
Input: my-cli --input ./data.json --verbose
// src/cli.ts
import { ArgParser } from "@alcyone-labs/arg-parser";
const parser = new ArgParser({
appName: "Data Processor",
appCommandName: "data-proc",
handler: async (ctx) => {
const { input, verbose } = ctx.args;
console.log(`Processing: ${input}, verbose: ${verbose}`);
},
}).addFlags([
{ name: "input", options: ["--input", "-i"], type: String, mandatory: true },
{
name: "verbose",
options: ["--verbose", "-v"],
type: Boolean,
defaultValue: false,
},
]);
parser.parse(process.argv);
Input: my-cli --s-mcp-serve
import { ArgParser, ArgParserError } from "@alcyone-labs/arg-parser";
const parser = new ArgParser({
appName: "Search CLI",
appCommandName: "search",
handler: async (ctx) => ({ query: ctx.args.query }),
})
.addFlags([
{
name: "query",
options: ["--query", "-q"],
type: String,
mandatory: true,
},
])
.addTool({
name: "search",
description: "Search for items",
flags: [
{ name: "term", options: ["--term"], type: String, mandatory: true },
{ name: "limit", options: ["--limit"], type: Number, defaultValue: 10 },
],
handler: async (ctx) => ({ results: [`result for ${ctx.args.term}`] }),
outputSchema: "successWithData",
})
.withMcp({
serverInfo: { name: "search-cli", version: "1.0.0" },
defaultTransport: { type: "stdio" },
});
await parser.parse(process.argv);
import { ArgParser } from "@alcyone-labs/arg-parser";
import { YamlConfigPlugin, globalConfigPluginRegistry } from "@alcyone-labs/arg-parser/config";
globalConfigPluginRegistry.register(new YamlConfigPlugin());
const parser = new ArgParser({
appName: "Config App",
appCommandName: "config-app",
})
.addFlags([
{
name: "config",
options: ["--config"],
type: "string",
env: "APP_CONFIG",
},
])
.withMcp({
serverInfo: { name: "config-app", version: "1.0.0" },
dxt: { include: ["config/", "assets/"] },
});
await parser.parse(process.argv);
Input: my-cli --interactive
import { ArgParser, type IPromptableFlag } from "@alcyone-labs/arg-parser";
const parser = new ArgParser({
appName: "Deploy Tool",
promptWhen: "interactive-flag",
handler: async (ctx) => {
if (ctx.isInteractive) {
console.log("Deploying with:", ctx.promptAnswers);
}
const env = ctx.args.environment || ctx.promptAnswers?.environment;
console.log(`Deploying to ${env}...`);
},
});
parser.addFlag({
name: "interactive",
options: ["--interactive", "-i"],
type: "boolean",
flagOnly: true,
});
parser.addFlag({
name: "environment",
options: ["--env", "-e"],
type: "string",
prompt: async () => ({
type: "select",
message: "Select environment:",
options: [
{ label: "Staging", value: "staging", hint: "Safe for testing" },
{ label: "Production", value: "production", hint: "Careful!" },
],
}),
} as IPromptableFlag);
parser.addFlag({
name: "version",
options: ["--version", "-v"],
type: "string",
prompt: async (ctx) => {
const env = ctx.promptAnswers?.environment;
return {
type: "select",
message: `Select version for ${env}:`,
options: ["1.0.0", "1.1.0", "2.0.0"],
};
},
} as IPromptableFlag);
await parser.parse();
parser.addFlag({
name: "password",
options: ["--password", "-p"],
type: "string",
prompt: async () => ({
type: "password",
message: "Enter password:",
}),
} as IPromptableFlag);
parser.addFlag({
name: "email",
options: ["--email"],
type: "string",
prompt: async () => ({
type: "text",
message: "Enter email:",
validate: (val) => {
if (!val.includes("@")) return "Invalid email address";
return true;
},
}),
} as IPromptableFlag);
parser.addFlag({
name: "timeout",
options: ["--timeout", "-t"],
type: "number",
defaultValue: 30, // Automatically used as initial in prompt
prompt: async () => ({
type: "text",
message: "Enter timeout (seconds):",
// No initial needed - uses defaultValue automatically
}),
} as IPromptableFlag);
parser.addFlag({
name: "configureAdvanced",
options: ["--configure-advanced"],
type: "boolean",
promptSequence: 1,
prompt: async () => ({
type: "confirm",
message: "Configure advanced options?",
initial: false,
}),
} as IPromptableFlag);
parser.addFlag({
name: "advancedOptions",
options: ["--advanced-options"],
type: "string",
promptSequence: 2,
prompt: async (ctx) => ({
type: "text",
message: "Enter advanced options:",
skip: !ctx.promptAnswers?.configureAdvanced, // Skip if false
}),
} as IPromptableFlag);
parser.addFlag({
name: "modules",
options: ["--modules", "-m"],
type: "array",
prompt: async () => ({
type: "multiselect",
message: "Select modules to install:",
options: [
{ value: "auth", label: "Authentication", hint: "User login" },
{ value: "database", label: "Database", hint: "Data persistence" },
{ value: "api", label: "API", hint: "REST endpoints" },
{ value: "ui", label: "UI", hint: "User interface" },
],
allowSelectAll: true, // Enable select all/none toggle
}),
} as IPromptableFlag);
Use CLI flags to pre-configure interactive prompts:
parser.addFlag({
name: "global",
options: ["--global", "-g"],
type: "boolean",
prompt: async (ctx) => ({
type: "confirm",
message: "Install globally?",
initial: false,
skip: ctx.args.global || ctx.args.local, // Skip if already specified
}),
} as IPromptableFlag);
parser.addFlag({
name: "packageManager",
options: ["--package-manager", "-p"],
type: "string",
prompt: async (ctx) => {
// Refine options based on pre-configured scope
const isGlobal = ctx.args.global || ctx.promptAnswers?.global;
const options = isGlobal ? ["npm", "yarn", "pnpm"] : ["npm", "yarn", "pnpm", "bun"];
return {
type: "select",
message: "Package manager:",
options,
initial: ctx.args.packageManager, // Use CLI flag as default
};
},
} as IPromptableFlag);
development
Builds precise production-ready custom Agent Skills following AgentSkills.io guidelines. Use when user requests to create, refine or package Skills
development
Best practices for using simple-logger in TypeScript applications
tools
Implement Sauve-specific Jazz extension behavior on top of worker-authority architecture and typed popup-worker protocol
tools
Test Chrome extensions (Manifest V3) headlessly with Playwright — load unpacked extensions, extract the extension ID, test popups/content scripts/background, run reliably in CI, and use the correct headless mode that actually supports extensions.