# Send Universal Command Pattern to your agent
Hand the extracted package to your coding agent with a concrete install brief instead of figuring it out manually.
## Fast path
- 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.
## Suggested prompts
### New install

```text
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.
```
### Upgrade existing

```text
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.
```
## Machine-readable fields
```json
{
  "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": {
    "downloadUrl": "/downloads/universal-command",
    "sourceDownloadUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=universal-command",
    "sourcePlatform": "tencent",
    "targetPlatform": "OpenClaw",
    "packageFormat": "ZIP package",
    "primaryDoc": "SKILL.md",
    "includedAssets": [
      "SKILL.md"
    ],
    "downloadMode": "redirect",
    "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."
      ]
    }
  },
  "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"
  }
}
```
## Documentation

### @supernal/universal-command

Define once, deploy everywhere. Single source of truth for CLI, API, and MCP interfaces.

### ⚠️ CRITICAL: Use This, Don't Rebuild

If you're building commands for Supernal, use this package. Don't create separate CLI/API/MCP implementations.

### Installation

npm install @supernal/universal-command

### Define a Command

import { UniversalCommand } from '@supernal/universal-command';

export const userCreate = new UniversalCommand({
  name: 'user create',
  description: 'Create a new user',
  
  input: {
    parameters: [
      { name: 'name', type: 'string', required: true },
      { name: 'email', type: 'string', required: true },
      { name: 'role', type: 'string', default: 'user', enum: ['user', 'admin'] },
    ],
  },
  
  output: { type: 'json' },
  
  handler: async (args, context) => {
    return await createUser(args);
  },
});

### Deploy Everywhere

// CLI
program.addCommand(userCreate.toCLI());
// → mycli user create --name "Alice" --email "alice@example.com"

// Next.js API
export const POST = userCreate.toNextAPI();
// → POST /api/users/create

// MCP Tool
const mcpTool = userCreate.toMCP();
// → user_create tool for AI agents

### Single Handler

Write your logic once. The handler receives validated args and returns the result:

handler: async (args, context) => {
  // This same code runs for CLI, API, and MCP
  return await doThing(args);
}

### Input Schema

Define parameters once — validation, CLI options, API params, and MCP schema are auto-generated:

input: {
  parameters: [
    { name: 'id', type: 'string', required: true },
    { name: 'status', type: 'string', enum: ['draft', 'active', 'done'] },
    { name: 'limit', type: 'number', min: 1, max: 100, default: 10 },
  ],
}

### Interface-Specific Options

Override behavior per interface when needed:

cli: {
  format: (data) => formatForTerminal(data),
  streaming: true,
},

api: {
  method: 'GET',
  cacheControl: { maxAge: 300 },
  auth: { required: true, roles: ['admin'] },
},

mcp: {
  resourceLinks: ['export://results'],
},

### Registry Pattern

For multiple commands:

import { CommandRegistry } from '@supernal/universal-command';

const registry = new CommandRegistry();
registry.register(userCreate);
registry.register(userList);
registry.register(userDelete);

// Generate all CLI commands
for (const cmd of registry.getAll()) {
  program.addCommand(cmd.toCLI());
}

// Generate all API routes
await generateNextRoutes(registry, { outputDir: 'app/api' });

// Generate MCP server
const server = createMCPServer(registry);

### Runtime Server

For simple setups without code generation:

import { createRuntimeServer } from '@supernal/universal-command';

const server = createRuntimeServer();
server.register(userCreate);
server.register(userList);

// Serve as Next.js
export const GET = server.getNextHandlers().GET;
export const POST = server.getNextHandlers().POST;

// Or as Express
app.use('/api', server.getExpressRouter());

// Or as MCP
await server.startMCP({ name: 'my-server', transport: 'stdio' });

### Execution Context

Know which interface is calling:

handler: async (args, context) => {
  if (context.interface === 'cli') {
    // CLI-specific logic
  } else if (context.interface === 'api') {
    const userId = context.request.headers.get('x-user-id');
  }
  return result;
}

### Testing

Test once, works everywhere:

import { userCreate } from './user-create';

test('creates user', async () => {
  const result = await userCreate.execute(
    { name: 'Alice', email: 'alice@example.com' },
    { interface: 'test' }
  );
  expect(result.name).toBe('Alice');
});

### Architecture

┌─────────────────────────────────────────┐
│      UniversalCommand Definition        │
│  name, description, input, handler      │
└────────────────┬────────────────────────┘
                 │
        ┌────────┼────────┐
        ▼        ▼        ▼
     ┌─────┐  ┌─────┐  ┌─────┐
     │ CLI │  │ API │  │ MCP │
     └─────┘  └─────┘  └─────┘

### When to Use

✅ Building any new Supernal command/tool
✅ Adding CLI interface to existing logic
✅ Exposing functionality to AI agents (MCP)
✅ Creating REST APIs with consistent patterns

❌ Simple one-off scripts (overkill)
❌ Third-party integrations with their own patterns

### Integration with sc and si

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.

### API Reference

class UniversalCommand<TInput, TOutput> {
  execute(args: TInput, context: ExecutionContext): Promise<TOutput>;
  toCLI(): Command;           // Commander.js Command
  toNextAPI(): NextAPIRoute;  // Next.js route handler
  toExpressAPI(): ExpressRoute;
  toMCP(): MCPToolDefinition;
  validateArgs(args: unknown): ValidationResult<TInput>;
}

class CommandRegistry {
  register(command: UniversalCommand): void;
  getAll(): UniversalCommand[];
}

function createRuntimeServer(): RuntimeServer;
function generateNextRoutes(registry: CommandRegistry, options: CodegenOptions): Promise<void>;
function createMCPServer(registry: CommandRegistry, options: MCPOptions): MCPServer;

### Source

Package: @supernal/universal-command
npm: https://www.npmjs.com/package/@supernal/universal-command

DO NOT rebuild this pattern. Use it!
## Trust
- Source: tencent
- Verification: Indexed source record
- Publisher: ianderrington
- Version: 1.0.0
## Source health
- Status: healthy
- Item download looks usable.
- Yavira can redirect you to the upstream package for this item.
- Health scope: item
- Reason: direct_download_ok
- Checked at: 2026-05-10T11:54:56.779Z
- Expires at: 2026-05-17T11:54:56.779Z
- Recommended action: Download for OpenClaw
## Links
- [Detail page](https://openagent3.xyz/skills/universal-command)
- [Send to Agent page](https://openagent3.xyz/skills/universal-command/agent)
- [JSON manifest](https://openagent3.xyz/skills/universal-command/agent.json)
- [Markdown brief](https://openagent3.xyz/skills/universal-command/agent.md)
- [Download page](https://openagent3.xyz/downloads/universal-command)