{
  "schemaVersion": "1.0",
  "item": {
    "slug": "universal-command",
    "name": "Universal Command Pattern",
    "source": "tencent",
    "type": "skill",
    "category": "开发工具",
    "sourceUrl": "https://clawhub.ai/ianderrington/universal-command",
    "canonicalUrl": "https://clawhub.ai/ianderrington/universal-command",
    "targetPlatform": "OpenClaw"
  },
  "install": {
    "downloadMode": "redirect",
    "downloadUrl": "/downloads/universal-command",
    "sourceDownloadUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=universal-command",
    "sourcePlatform": "tencent",
    "targetPlatform": "OpenClaw",
    "installMethod": "Manual import",
    "extraction": "Extract archive",
    "prerequisites": [
      "OpenClaw"
    ],
    "packageFormat": "ZIP package",
    "includedAssets": [
      "SKILL.md"
    ],
    "primaryDoc": "SKILL.md",
    "quickSetup": [
      "Download the package from Yavira.",
      "Extract the archive and review SKILL.md first.",
      "Import or place the package into your OpenClaw setup."
    ],
    "agentAssist": {
      "summary": "Hand the extracted package to your coding agent with a concrete install brief instead of figuring it out manually.",
      "steps": [
        "Download the package from Yavira.",
        "Extract it into a folder your agent can access.",
        "Paste one of the prompts below and point your agent at the extracted folder."
      ],
      "prompts": [
        {
          "label": "New install",
          "body": "I downloaded a skill package from Yavira. Read SKILL.md from the extracted folder and install it by following the included instructions. Tell me what you changed and call out any manual steps you could not complete."
        },
        {
          "label": "Upgrade existing",
          "body": "I downloaded an updated skill package from Yavira. Read SKILL.md from the extracted folder, compare it with my current installation, and upgrade it while preserving any custom configuration unless the package docs explicitly say otherwise. Summarize what changed and any follow-up checks I should run."
        }
      ]
    },
    "sourceHealth": {
      "source": "tencent",
      "slug": "universal-command",
      "status": "healthy",
      "reason": "direct_download_ok",
      "recommendedAction": "download",
      "checkedAt": "2026-05-10T11:54:56.779Z",
      "expiresAt": "2026-05-17T11:54:56.779Z",
      "httpStatus": 200,
      "finalUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=universal-command",
      "contentType": "application/zip",
      "probeMethod": "head",
      "details": {
        "probeUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=universal-command",
        "contentDisposition": "attachment; filename=\"universal-command-1.0.0.zip\"",
        "redirectLocation": null,
        "bodySnippet": null,
        "slug": "universal-command"
      },
      "scope": "item",
      "summary": "Item download looks usable.",
      "detail": "Yavira can redirect you to the upstream package for this item.",
      "primaryActionLabel": "Download for OpenClaw",
      "primaryActionHref": "/downloads/universal-command"
    },
    "validation": {
      "installChecklist": [
        "Use the Yavira download entry.",
        "Review SKILL.md after the package is downloaded.",
        "Confirm the extracted package contains the expected setup assets."
      ],
      "postInstallChecks": [
        "Confirm the extracted package includes the expected docs or setup files.",
        "Validate the skill or prompts are available in your target agent workspace.",
        "Capture any manual follow-up steps the agent could not complete."
      ]
    },
    "downloadPageUrl": "https://openagent3.xyz/downloads/universal-command",
    "agentPageUrl": "https://openagent3.xyz/skills/universal-command/agent",
    "manifestUrl": "https://openagent3.xyz/skills/universal-command/agent.json",
    "briefUrl": "https://openagent3.xyz/skills/universal-command/agent.md"
  },
  "agentAssist": {
    "summary": "Hand the extracted package to your coding agent with a concrete install brief instead of figuring it out manually.",
    "steps": [
      "Download the package from Yavira.",
      "Extract it into a folder your agent can access.",
      "Paste one of the prompts below and point your agent at the extracted folder."
    ],
    "prompts": [
      {
        "label": "New install",
        "body": "I downloaded a skill package from Yavira. Read SKILL.md from the extracted folder and install it by following the included instructions. Tell me what you changed and call out any manual steps you could not complete."
      },
      {
        "label": "Upgrade existing",
        "body": "I downloaded an updated skill package from Yavira. Read SKILL.md from the extracted folder, compare it with my current installation, and upgrade it while preserving any custom configuration unless the package docs explicitly say otherwise. Summarize what changed and any follow-up checks I should run."
      }
    ]
  },
  "documentation": {
    "source": "clawhub",
    "primaryDoc": "SKILL.md",
    "sections": [
      {
        "title": "@supernal/universal-command",
        "body": "Define once, deploy everywhere. Single source of truth for CLI, API, and MCP interfaces."
      },
      {
        "title": "⚠️ CRITICAL: Use This, Don't Rebuild",
        "body": "If you're building commands for Supernal, use this package. Don't create separate CLI/API/MCP implementations."
      },
      {
        "title": "Installation",
        "body": "npm install @supernal/universal-command"
      },
      {
        "title": "Define a Command",
        "body": "import { UniversalCommand } from '@supernal/universal-command';\n\nexport const userCreate = new UniversalCommand({\n  name: 'user create',\n  description: 'Create a new user',\n  \n  input: {\n    parameters: [\n      { name: 'name', type: 'string', required: true },\n      { name: 'email', type: 'string', required: true },\n      { name: 'role', type: 'string', default: 'user', enum: ['user', 'admin'] },\n    ],\n  },\n  \n  output: { type: 'json' },\n  \n  handler: async (args, context) => {\n    return await createUser(args);\n  },\n});"
      },
      {
        "title": "Deploy Everywhere",
        "body": "// CLI\nprogram.addCommand(userCreate.toCLI());\n// → mycli user create --name \"Alice\" --email \"alice@example.com\"\n\n// Next.js API\nexport const POST = userCreate.toNextAPI();\n// → POST /api/users/create\n\n// MCP Tool\nconst mcpTool = userCreate.toMCP();\n// → user_create tool for AI agents"
      },
      {
        "title": "Single Handler",
        "body": "Write your logic once. The handler receives validated args and returns the result:\n\nhandler: async (args, context) => {\n  // This same code runs for CLI, API, and MCP\n  return await doThing(args);\n}"
      },
      {
        "title": "Input Schema",
        "body": "Define parameters once — validation, CLI options, API params, and MCP schema are auto-generated:\n\ninput: {\n  parameters: [\n    { name: 'id', type: 'string', required: true },\n    { name: 'status', type: 'string', enum: ['draft', 'active', 'done'] },\n    { name: 'limit', type: 'number', min: 1, max: 100, default: 10 },\n  ],\n}"
      },
      {
        "title": "Interface-Specific Options",
        "body": "Override behavior per interface when needed:\n\ncli: {\n  format: (data) => formatForTerminal(data),\n  streaming: true,\n},\n\napi: {\n  method: 'GET',\n  cacheControl: { maxAge: 300 },\n  auth: { required: true, roles: ['admin'] },\n},\n\nmcp: {\n  resourceLinks: ['export://results'],\n},"
      },
      {
        "title": "Registry Pattern",
        "body": "For multiple commands:\n\nimport { CommandRegistry } from '@supernal/universal-command';\n\nconst registry = new CommandRegistry();\nregistry.register(userCreate);\nregistry.register(userList);\nregistry.register(userDelete);\n\n// Generate all CLI commands\nfor (const cmd of registry.getAll()) {\n  program.addCommand(cmd.toCLI());\n}\n\n// Generate all API routes\nawait generateNextRoutes(registry, { outputDir: 'app/api' });\n\n// Generate MCP server\nconst server = createMCPServer(registry);"
      },
      {
        "title": "Runtime Server",
        "body": "For simple setups without code generation:\n\nimport { createRuntimeServer } from '@supernal/universal-command';\n\nconst server = createRuntimeServer();\nserver.register(userCreate);\nserver.register(userList);\n\n// Serve as Next.js\nexport const GET = server.getNextHandlers().GET;\nexport const POST = server.getNextHandlers().POST;\n\n// Or as Express\napp.use('/api', server.getExpressRouter());\n\n// Or as MCP\nawait server.startMCP({ name: 'my-server', transport: 'stdio' });"
      },
      {
        "title": "Execution Context",
        "body": "Know which interface is calling:\n\nhandler: async (args, context) => {\n  if (context.interface === 'cli') {\n    // CLI-specific logic\n  } else if (context.interface === 'api') {\n    const userId = context.request.headers.get('x-user-id');\n  }\n  return result;\n}"
      },
      {
        "title": "Testing",
        "body": "Test once, works everywhere:\n\nimport { userCreate } from './user-create';\n\ntest('creates user', async () => {\n  const result = await userCreate.execute(\n    { name: 'Alice', email: 'alice@example.com' },\n    { interface: 'test' }\n  );\n  expect(result.name).toBe('Alice');\n});"
      },
      {
        "title": "Architecture",
        "body": "┌─────────────────────────────────────────┐\n│      UniversalCommand Definition        │\n│  name, description, input, handler      │\n└────────────────┬────────────────────────┘\n                 │\n        ┌────────┼────────┐\n        ▼        ▼        ▼\n     ┌─────┐  ┌─────┐  ┌─────┐\n     │ CLI │  │ API │  │ MCP │\n     └─────┘  └─────┘  └─────┘"
      },
      {
        "title": "When to Use",
        "body": "✅ Building any new Supernal command/tool\n✅ Adding CLI interface to existing logic\n✅ Exposing functionality to AI agents (MCP)\n✅ Creating REST APIs with consistent patterns\n\n❌ Simple one-off scripts (overkill)\n❌ Third-party integrations with their own patterns"
      },
      {
        "title": "Integration with sc and si",
        "body": "Both sc (supernal-coding) and si (supernal-interface) use universal-command under the hood. When adding new commands to these tools, define them as UniversalCommands."
      },
      {
        "title": "API Reference",
        "body": "class UniversalCommand<TInput, TOutput> {\n  execute(args: TInput, context: ExecutionContext): Promise<TOutput>;\n  toCLI(): Command;           // Commander.js Command\n  toNextAPI(): NextAPIRoute;  // Next.js route handler\n  toExpressAPI(): ExpressRoute;\n  toMCP(): MCPToolDefinition;\n  validateArgs(args: unknown): ValidationResult<TInput>;\n}\n\nclass CommandRegistry {\n  register(command: UniversalCommand): void;\n  getAll(): UniversalCommand[];\n}\n\nfunction createRuntimeServer(): RuntimeServer;\nfunction generateNextRoutes(registry: CommandRegistry, options: CodegenOptions): Promise<void>;\nfunction createMCPServer(registry: CommandRegistry, options: MCPOptions): MCPServer;"
      },
      {
        "title": "Source",
        "body": "Package: @supernal/universal-command\nnpm: https://www.npmjs.com/package/@supernal/universal-command\n\nDO NOT rebuild this pattern. Use it!"
      }
    ],
    "body": "@supernal/universal-command\n\nDefine once, deploy everywhere. Single source of truth for CLI, API, and MCP interfaces.\n\n⚠️ CRITICAL: Use This, Don't Rebuild\n\nIf you're building commands for Supernal, use this package. Don't create separate CLI/API/MCP implementations.\n\nInstallation\nnpm install @supernal/universal-command\n\nQuick Start\nDefine a Command\nimport { UniversalCommand } from '@supernal/universal-command';\n\nexport const userCreate = new UniversalCommand({\n  name: 'user create',\n  description: 'Create a new user',\n  \n  input: {\n    parameters: [\n      { name: 'name', type: 'string', required: true },\n      { name: 'email', type: 'string', required: true },\n      { name: 'role', type: 'string', default: 'user', enum: ['user', 'admin'] },\n    ],\n  },\n  \n  output: { type: 'json' },\n  \n  handler: async (args, context) => {\n    return await createUser(args);\n  },\n});\n\nDeploy Everywhere\n// CLI\nprogram.addCommand(userCreate.toCLI());\n// → mycli user create --name \"Alice\" --email \"alice@example.com\"\n\n// Next.js API\nexport const POST = userCreate.toNextAPI();\n// → POST /api/users/create\n\n// MCP Tool\nconst mcpTool = userCreate.toMCP();\n// → user_create tool for AI agents\n\nCore Concepts\nSingle Handler\n\nWrite your logic once. The handler receives validated args and returns the result:\n\nhandler: async (args, context) => {\n  // This same code runs for CLI, API, and MCP\n  return await doThing(args);\n}\n\nInput Schema\n\nDefine parameters once — validation, CLI options, API params, and MCP schema are auto-generated:\n\ninput: {\n  parameters: [\n    { name: 'id', type: 'string', required: true },\n    { name: 'status', type: 'string', enum: ['draft', 'active', 'done'] },\n    { name: 'limit', type: 'number', min: 1, max: 100, default: 10 },\n  ],\n}\n\nInterface-Specific Options\n\nOverride behavior per interface when needed:\n\ncli: {\n  format: (data) => formatForTerminal(data),\n  streaming: true,\n},\n\napi: {\n  method: 'GET',\n  cacheControl: { maxAge: 300 },\n  auth: { required: true, roles: ['admin'] },\n},\n\nmcp: {\n  resourceLinks: ['export://results'],\n},\n\nRegistry Pattern\n\nFor multiple commands:\n\nimport { CommandRegistry } from '@supernal/universal-command';\n\nconst registry = new CommandRegistry();\nregistry.register(userCreate);\nregistry.register(userList);\nregistry.register(userDelete);\n\n// Generate all CLI commands\nfor (const cmd of registry.getAll()) {\n  program.addCommand(cmd.toCLI());\n}\n\n// Generate all API routes\nawait generateNextRoutes(registry, { outputDir: 'app/api' });\n\n// Generate MCP server\nconst server = createMCPServer(registry);\n\nRuntime Server\n\nFor simple setups without code generation:\n\nimport { createRuntimeServer } from '@supernal/universal-command';\n\nconst server = createRuntimeServer();\nserver.register(userCreate);\nserver.register(userList);\n\n// Serve as Next.js\nexport const GET = server.getNextHandlers().GET;\nexport const POST = server.getNextHandlers().POST;\n\n// Or as Express\napp.use('/api', server.getExpressRouter());\n\n// Or as MCP\nawait server.startMCP({ name: 'my-server', transport: 'stdio' });\n\nExecution Context\n\nKnow which interface is calling:\n\nhandler: async (args, context) => {\n  if (context.interface === 'cli') {\n    // CLI-specific logic\n  } else if (context.interface === 'api') {\n    const userId = context.request.headers.get('x-user-id');\n  }\n  return result;\n}\n\nTesting\n\nTest once, works everywhere:\n\nimport { userCreate } from './user-create';\n\ntest('creates user', async () => {\n  const result = await userCreate.execute(\n    { name: 'Alice', email: 'alice@example.com' },\n    { interface: 'test' }\n  );\n  expect(result.name).toBe('Alice');\n});\n\nArchitecture\n┌─────────────────────────────────────────┐\n│      UniversalCommand Definition        │\n│  name, description, input, handler      │\n└────────────────┬────────────────────────┘\n                 │\n        ┌────────┼────────┐\n        ▼        ▼        ▼\n     ┌─────┐  ┌─────┐  ┌─────┐\n     │ CLI │  │ API │  │ MCP │\n     └─────┘  └─────┘  └─────┘\n\nWhen to Use\n\n✅ Building any new Supernal command/tool\n✅ Adding CLI interface to existing logic\n✅ Exposing functionality to AI agents (MCP)\n✅ Creating REST APIs with consistent patterns\n\n❌ Simple one-off scripts (overkill)\n❌ Third-party integrations with their own patterns\n\nIntegration with sc and si\n\nBoth sc (supernal-coding) and si (supernal-interface) use universal-command under the hood. When adding new commands to these tools, define them as UniversalCommands.\n\nAPI Reference\nclass UniversalCommand<TInput, TOutput> {\n  execute(args: TInput, context: ExecutionContext): Promise<TOutput>;\n  toCLI(): Command;           // Commander.js Command\n  toNextAPI(): NextAPIRoute;  // Next.js route handler\n  toExpressAPI(): ExpressRoute;\n  toMCP(): MCPToolDefinition;\n  validateArgs(args: unknown): ValidationResult<TInput>;\n}\n\nclass CommandRegistry {\n  register(command: UniversalCommand): void;\n  getAll(): UniversalCommand[];\n}\n\nfunction createRuntimeServer(): RuntimeServer;\nfunction generateNextRoutes(registry: CommandRegistry, options: CodegenOptions): Promise<void>;\nfunction createMCPServer(registry: CommandRegistry, options: MCPOptions): MCPServer;\n\nSource\nPackage: @supernal/universal-command\nnpm: https://www.npmjs.com/package/@supernal/universal-command\n\nDO NOT rebuild this pattern. Use it!"
  },
  "trust": {
    "sourceLabel": "tencent",
    "provenanceUrl": "https://clawhub.ai/ianderrington/universal-command",
    "publisherUrl": "https://clawhub.ai/ianderrington/universal-command",
    "owner": "ianderrington",
    "version": "1.0.0",
    "license": null,
    "verificationStatus": "Indexed source record"
  },
  "links": {
    "detailUrl": "https://openagent3.xyz/skills/universal-command",
    "downloadUrl": "https://openagent3.xyz/downloads/universal-command",
    "agentUrl": "https://openagent3.xyz/skills/universal-command/agent",
    "manifestUrl": "https://openagent3.xyz/skills/universal-command/agent.json",
    "briefUrl": "https://openagent3.xyz/skills/universal-command/agent.md"
  }
}