> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/wevm/incur/llms.txt
> Use this file to discover all available pages before exploring further.

# Skill

> Generate Markdown skill files from CLI commands for AI agent discovery

The `Skill` module generates Markdown skill files from CLI commands, enabling AI agents to discover and use your CLI tools.

## Functions

### generate

Generates a Markdown skill file from a CLI name and collected command data.

```typescript theme={null}
function generate(
  name: string,
  commands: CommandInfo[],
  groups?: Map<string, string>
): string
```

<ParamField path="name" type="string" required>
  The CLI name
</ParamField>

<ParamField path="commands" type="CommandInfo[]" required>
  Array of command information objects
</ParamField>

<ParamField path="groups" type="Map<string, string>">
  Optional map of group names to descriptions. Defaults to an empty Map.
</ParamField>

<ResponseField name="return" type="string">
  Generated Markdown content for the skill file
</ResponseField>

#### Example

```typescript theme={null}
import { Skill } from 'incur'

const commands: Skill.CommandInfo[] = [
  {
    name: 'deploy',
    description: 'Deploy your application',
    args: z.object({ target: z.string() }),
    options: z.object({ verbose: z.boolean().optional() })
  }
]

const markdown = Skill.generate('mycli', commands)
console.log(markdown)
```

### split

Splits commands into skill files grouped by depth.

```typescript theme={null}
function split(
  name: string,
  commands: CommandInfo[],
  depth: number,
  groups?: Map<string, string>
): File[]
```

<ParamField path="name" type="string" required>
  The CLI name
</ParamField>

<ParamField path="commands" type="CommandInfo[]" required>
  Array of command information objects
</ParamField>

<ParamField path="depth" type="number" required>
  Grouping depth for skill files. `0` creates a single file, `1` groups by first segment, `2` by first two segments, etc.
</ParamField>

<ParamField path="groups" type="Map<string, string>">
  Optional map of group names to descriptions. Defaults to an empty Map.
</ParamField>

<ResponseField name="return" type="File[]">
  Array of skill file entries with directory names and content
</ResponseField>

#### Example

```typescript theme={null}
import { Skill } from 'incur'

const commands: Skill.CommandInfo[] = [
  { name: 'db migrate', description: 'Run migrations' },
  { name: 'db seed', description: 'Seed database' },
  { name: 'server start', description: 'Start server' }
]

// Split by first segment (depth 1)
const files = Skill.split('mycli', commands, 1)
// Returns:
// [
//   { dir: 'db', content: '...' },
//   { dir: 'server', content: '...' }
// ]
```

### hash

Computes a deterministic hash of command structure for staleness detection.

```typescript theme={null}
function hash(commands: CommandInfo[]): string
```

<ParamField path="commands" type="CommandInfo[]" required>
  Array of command information objects
</ParamField>

<ResponseField name="return" type="string">
  16-character hex hash of the command structure
</ResponseField>

#### Example

```typescript theme={null}
import { Skill } from 'incur'

const commands: Skill.CommandInfo[] = [/* ... */]
const currentHash = Skill.hash(commands)

// Compare with stored hash to detect changes
if (currentHash !== storedHash) {
  console.log('Commands have changed, regenerating skills')
}
```

## Types

### CommandInfo

Information about a single command passed to `generate()` and `split()`.

```typescript theme={null}
type CommandInfo = {
  name: string
  description?: string | undefined
  args?: z.ZodObject<any> | undefined
  env?: z.ZodObject<any> | undefined
  hint?: string | undefined
  options?: z.ZodObject<any> | undefined
  output?: z.ZodType | undefined
  examples?: { command: string; description?: string }[] | undefined
}
```

<ResponseField name="name" type="string" required>
  Command name (e.g., `"deploy"` or `"db migrate"`)
</ResponseField>

<ResponseField name="description" type="string">
  Human-readable command description
</ResponseField>

<ResponseField name="args" type="z.ZodObject<any>">
  Zod schema for positional arguments
</ResponseField>

<ResponseField name="env" type="z.ZodObject<any>">
  Zod schema for environment variables
</ResponseField>

<ResponseField name="hint" type="string">
  Additional hint text displayed after examples
</ResponseField>

<ResponseField name="options" type="z.ZodObject<any>">
  Zod schema for command options/flags
</ResponseField>

<ResponseField name="output" type="z.ZodType">
  Zod schema for command output
</ResponseField>

<ResponseField name="examples" type="Array<{ command: string; description?: string }>">
  Array of usage examples with optional descriptions
</ResponseField>

### File

A skill file entry with its directory name and content.

```typescript theme={null}
type File = {
  /** Directory name relative to output root (empty string for depth 0) */
  dir: string
  /** Markdown content */
  content: string
}
```

<ResponseField name="dir" type="string" required>
  Directory name relative to output root. Empty string for depth 0.
</ResponseField>

<ResponseField name="content" type="string" required>
  Markdown content for the skill file
</ResponseField>

## Related

* [SyncSkills](/api/skill) - Sync skills to agent config directories
* [Agent Discovery](/features/agent-discovery) - Learn about AI agent discovery
