> For the complete documentation index, see [llms.txt](https://www.openclawbook.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.openclawbook.xyz/en/ch29-skill-system/29.3-skill-installation-and-management.md). Agents can also search and read this documentation through its [MCP server](https://www.openclawbook.xyz/~gitbook/mcp).

# 29.3 Skill Installation and Management

> **Generated by**: Claude Opus 4.6 (initial draft) / Claude Opus 5 (`v2026.3.9` revision) **Token usage**: Input \~420k tokens, Output \~6k tokens (this section) **Source baseline**: `v2026.3.9` (`v2026.3.8-170-g665f67726`)

***

Skills declare external dependencies (like the `gh` CLI or `curl`), but these dependencies may not be installed on the user's machine. OpenClaw's skill installation system lets users (or Agents) install missing dependencies with a single command, while also providing skill status auditing capabilities.

***

## 29.3.1 Skill Installation Flow

### Installation Entry Point

`skills-install.ts` implements the complete skill dependency installation flow. The entry point is `installSkillDependency` (called by CLI or Agent), with core logic as follows:

```typescript
// src/agents/skills-install.ts (simplified conceptual flow)

async function installSkillDependency(request: SkillInstallRequest): Promise<SkillInstallResult> {
  // 1. Load skill entries
  const entries = loadWorkspaceSkillEntries(request.workspaceDir, { config: request.config });
  const entry = entries.find(e => e.skill.name === request.skillName);

  // 2. Find the specified installation spec
  const spec = findInstallSpec(entry, request.installId);

  // 3. Security scan (check skill code before installation)
  const warnings = await collectSkillInstallScanWarnings(entry);

  // 4. Execute based on installation type
  if (spec.kind === "download") {
    return await installDownloadSpec({ entry, spec, timeoutMs });
  }

  // 5. Build and execute installation command
  const { argv, error } = buildInstallCommand(spec, prefs);
  const result = await runCommandWithTimeout(argv, { timeoutMs });

  return { ok: result.code === 0, message, stdout, stderr, warnings };
}
```

### Installation Command Building

`buildInstallCommand` generates the concrete command based on installation type and user preferences:

```typescript
// src/agents/skills-install.ts (simplified)

function buildInstallCommand(spec: SkillInstallSpec, prefs: SkillsInstallPreferences) {
  switch (spec.kind) {
    case "brew":
      return { argv: ["brew", "install", spec.formula] };
    case "node":
      return { argv: buildNodeInstallCommand(spec.package, prefs) };
    case "go":
      return { argv: ["go", "install", spec.module] };
    case "uv":
      return { argv: ["uv", "tool", "install", spec.package] };
    case "download":
      return { argv: null, error: "download handled separately" };
  }
}

function buildNodeInstallCommand(packageName: string, prefs): string[] {
  switch (prefs.nodeManager) {
    case "pnpm":  return ["pnpm", "add", "-g", packageName];
    case "yarn":  return ["yarn", "global", "add", packageName];
    case "bun":   return ["bun", "add", "-g", packageName];
    default:      return ["npm", "install", "-g", packageName];
  }
}
```

The choice of Node.js package manager is determined by configuration:

```typescript
// src/agents/skills.ts

export function resolveSkillsInstallPreferences(config?): SkillsInstallPreferences {
  const raw = config?.skills?.install;
  return {
    preferBrew: raw?.preferBrew ?? true,    // Default: prefer Homebrew
    nodeManager: raw?.nodeManager ?? "npm", // Default: use npm
  };
}
```

### Download Installer

The `download` installer type handles scenarios where you directly download binary files or archive packages:

```typescript
// src/agents/skills-install.ts (simplified)

async function installDownloadSpec(params): Promise<SkillInstallResult> {
  const { spec, entry, timeoutMs } = params;
  const targetDir = resolveDownloadTargetDir(entry, spec);

  // 1. Download file
  await downloadFile(spec.url, archivePath, timeoutMs);

  // 2. If archive, extract it
  const archiveType = resolveArchiveType(spec, filename);
  if (archiveType && spec.extract !== false) {
    await extractArchive({
      archivePath, archiveType, targetDir,
      stripComponents: spec.stripComponents,
      timeoutMs,
    });
  }

  // 3. Set executable permissions
  if (spec.bins?.length) {
    for (const bin of spec.bins) {
      const binPath = path.join(targetDir, bin);
      await fs.promises.chmod(binPath, 0o755);
    }
  }
}
```

Supported archive formats: `tar.gz`, `tar.bz2`, `zip`. The `stripComponents` parameter removes top-level directories from the archive (similar to `tar --strip-components`).

### Security Scanning

Before installation, the system performs a security scan on the skill directory:

```typescript
// src/agents/skills-install.ts (simplified)

async function collectSkillInstallScanWarnings(entry: SkillEntry): Promise<string[]> {
  const summary = await scanDirectoryWithSummary(entry.skill.baseDir);
  if (summary.critical > 0) {
    warnings.push(`WARNING: Skill "${name}" contains dangerous code patterns: ${details}`);
  } else if (summary.warn > 0) {
    warnings.push(`Skill "${name}" has ${summary.warn} suspicious code pattern(s).`);
  }
  return warnings;
}
```

> **Sidebar**: Security scanning checks whether the skill directory contains suspicious code patterns—for example, downloading and executing files from unknown sources, or accessing sensitive system paths. This is especially important for third-party skills installed from ClawHub, since skill content ultimately gets injected into the Agent's prompt, and malicious skills could attempt to manipulate Agent behavior.

***

## 29.3.2 Skill Status Management

### Status Reporting

`skills-status.ts` provides comprehensive skill status auditing. `buildSkillStatusReport` generates a detailed status report for each skill:

```typescript
// src/agents/skills-status.ts (simplified)

export type SkillStatusEntry = {
  name: string;
  description: string;
  source: string;              // "openclaw-bundled" | "openclaw-managed" etc.
  bundled: boolean;
  eligible: boolean;           // Whether it passes eligibility checks
  disabled: boolean;           // Whether disabled by configuration
  blockedByAllowlist: boolean; // Whether blocked by allowlist
  requirements: {              // Declared dependencies
    bins: string[];
    anyBins: string[];
    env: string[];
    config: string[];
    os: string[];
  };
  missing: {                   // Missing dependencies
    bins: string[];
    anyBins: string[];
    env: string[];
    config: string[];
    os: string[];
  };
  install: SkillInstallOption[];  // Available installation options
};
```

The `missing` field is key—it precisely lists the missing dependencies preventing skill activation, helping users decide whether to install them.

### Installation Option Selection

When a skill offers multiple installation methods, `selectPreferredInstallSpec` ranks them by user preference:

```typescript
// src/agents/skills-status.ts (simplified)

function selectPreferredInstallSpec(install: SkillInstallSpec[], prefs) {
  // 1. If user prefers Homebrew and brew is installed → select brew
  if (prefs.preferBrew && hasBinary("brew") && brewSpec) return brewSpec;
  // 2. uv (Python) → node → go → brew (non-preferred) → download
  if (uvSpec) return uvSpec;
  if (nodeSpec) return nodeSpec;
  if (goSpec) return goSpec;
  if (brewSpec) return brewSpec;
  return downloadSpec ?? install[0];
}
```

***

## 29.3.3 Skill CLI Commands

OpenClaw CLI provides a complete set of skill management commands. While the specific CLI implementation (`src/cli/skills-cli.ts`) involves terminal UI rendering details, core functionality includes:

### Common Commands

```bash
# List all skills and their status
openclaw skills list

# View details of a specific skill (dependencies, installation options)
openclaw skills info weather

# Install skill dependencies
openclaw skills install github brew

# Refresh skill list
openclaw skills refresh
```

### Skill Synchronization

For sandbox environments, skills need to be copied from the main workspace to the sandbox directory. `syncSkillsToWorkspace` handles this scenario:

```typescript
// src/agents/skills/workspace.ts (simplified)

export async function syncSkillsToWorkspace(params: {
  sourceWorkspaceDir: string;
  targetWorkspaceDir: string;
  config?: OpenClawConfig;
}) {
  // 1. Load all skills from source directory
  const entries = loadSkillEntries(sourceWorkspaceDir, { config });

  // 2. Clear target skills/ directory
  await fs.promises.rm(targetSkillsDir, { recursive: true, force: true });
  await fs.promises.mkdir(targetSkillsDir, { recursive: true });

  // 3. Copy skill directories one by one
  for (const entry of entries) {
    await fs.promises.cp(entry.skill.baseDir, destDir, { recursive: true });
  }
}
```

Synchronization is serialized via `serializeByKey`, ensuring concurrent writes to the same target directory don't occur.

### Environment Variable Overrides

Skills can declare environment variable overrides via configuration, injected when the Agent executes tools:

```typescript
// src/agents/skills/env-overrides.ts

export function applySkillEnvOverrides(params: {
  config: OpenClawConfig;
  skills: Array<{ name: string; primaryEnv?: string }>;
}): Record<string, string> {
  const overrides: Record<string, string> = {};
  for (const skill of params.skills) {
    const skillConfig = resolveSkillConfig(params.config, skill.name);
    // Extract env overrides from skill configuration
    if (skillConfig?.env) {
      Object.assign(overrides, skillConfig.env);
    }
    // apiKey → primaryEnv mapping
    if (skillConfig?.apiKey && skill.primaryEnv) {
      overrides[skill.primaryEnv] = skillConfig.apiKey;
    }
  }
  return overrides;
}
```

This allows users to configure skill API Keys in `settings.json` without setting global environment variables:

```json
{
  "skills": {
    "entries": {
      "discord": {
        "apiKey": "your-discord-token",
        "env": {
          "DISCORD_GUILD_ID": "123456789"
        }
      }
    }
  }
}
```

The configured `apiKey` automatically maps to the skill's declared `primaryEnv` (for Discord, this is `DISCORD_TOKEN`), allowing the skill to pass environment variable checks.

***

## Section Summary

1. **Installation flow** supports five installer types (brew/node/go/uv/download), automatically selecting the most appropriate package manager based on user preference, with security scanning before installation.
2. **Status reporting** precisely lists each skill's dependencies, missing items, and available installation options, helping users understand why certain skills aren't activated.
3. **CLI commands** provide `list`, `info`, `install`, `refresh` operations covering various stages of the skill lifecycle.
4. **Sandbox synchronization** copies skills from the main workspace to the sandbox environment, ensuring skills remain available during isolated execution.
5. **Environment variable overrides** let users manage skill API Keys and environment variables via configuration files, without modifying system environment.
