rolecraft exposes a programmatic API for use in your own Node.js scripts, tools, and CI pipelines. All API functions return plain objects with no side-effects.
import { install, list, search, doctor, searchRegistry } from 'rolecraft'
// install a skill
const result = await install('./my-skill', { global: true })
// list installed skills
const skills = await list()
// search GitHub for skills
const results = await search('code-review')
// search the registry for skills
const registryResults = await searchRegistry('react')
// run health check
const health = await doctor()Install a skill with security scan.
| Option | Type | Default | Description |
|---|---|---|---|
global |
boolean |
false |
Install to ~/.agents/skills/ |
project |
boolean |
true |
Install to ./.agents/skills/ |
yes |
boolean |
false |
Bypass security prompts |
dryRun |
boolean |
false |
Preview only |
symlink |
boolean |
false |
Symlink instead of copy |
frozenLockfile |
boolean |
false |
Fail if already installed |
noMcp |
boolean |
false |
Skip MCP server installation |
skill |
string|string[] |
— | Specific skill slug(s) |
Returns { results: [{ name, slug, owner, security, install }], mcpResults?: [...] }.
Restore a skill to its previous version from backup history. History is created automatically on update or re-install.
| Option | Type | Default | Description |
|---|---|---|---|
list |
boolean |
false |
Show history without restoring |
dryRun |
boolean |
false |
Preview without restoring |
Returns { slug, files, targets, prevContentSha }.
Or with list: true: { slug, currentVersion, history: [{ version, contentSha, installedAt }] }.
List installed skills.
| Option | Type | Default | Description |
|---|---|---|---|
json |
boolean |
false |
Return structured data |
agent |
string |
— | Filter skills by agent name (case-insensitive) |
Returns { skills: { [slug]: { name, slug, owner, description, source, sourceType, scope, installedAt, contentSha, ... } }, total: number, globals: number, projects: number, agent?: string }.
Uninstall a skill.
| Option | Type | Default | Description |
|---|---|---|---|
dryRun |
boolean |
false |
Preview only |
Returns { removed: [...], targets: [...] }.
Re-install a skill from its original source.
| Option | Type | Default | Description |
|---|---|---|---|
dryRun |
boolean |
false |
Preview only |
Returns { slug, source, updated: boolean }.
Check installed skills for available updates.
Returns { updates: [{ slug, hasUpdate }], current: [...] }.
Verify SHA256 content hashes of installed skills.
Returns { verified: [...], failed: [...] }.
Re-install all skills and MCP servers from lockfile.
| Option | Type | Default | Description |
|---|---|---|---|
yes |
boolean |
false |
Non-interactive mode |
dryRun |
boolean |
false |
Preview only |
frozenLockfile |
boolean |
false |
Fail if lockfile changes |
Returns { installed: [{ slug, name, scope }], failed: [{ slug, reason }], skillCount, mcpCount, total, allPassed, mcpInstalled: [{ name, agents }], mcpFailed: [{ name, reason }] }.
Search for skills on GitHub or skills.sh.
| Option | Type | Default | Description |
|---|---|---|---|
skillsSh |
boolean |
false |
Search skills.sh instead of GitHub |
interactive |
boolean |
false |
Enable TUI picker |
Returns { results: [{ full_name, description, stargazers_count, language }], source: 'github'|'skills.sh' }.
Run system health check.
| Option | Type | Default | Description |
|---|---|---|---|
json |
boolean |
false |
Return structured data |
network |
boolean |
false |
Include GitHub connectivity test |
deep |
boolean |
false |
Run conflict detection across all installed skills |
Returns { status, checks: [...], summary: { passed, warnings, errors, total }, agents, mcp, skills, conflicts }.
When deep: true, the conflicts array contains objects shaped as { a, b, sections: [{ heading, a, b }] } where a and b are conflicting skill slugs and each section lists up to 3 differing lines from each skill.
Preview a skill's files without installing.
Returns { name, slug, files: [...], targets: [...] }.
Resolve a source string to its metadata. Returns { slug, name, files, contentSha, ... }.
Resolve a source string and discover all skills within it (including multi-skill repos). Used internally by install, use, and setup.
Returns [{ slug, name, description, owner, files, sourcePath, sourceType, content }].
Section-aware comparison of two SKILL.md files.
| Option | Type | Default | Description |
|---|---|---|---|
json |
boolean |
false |
Return structured JSON |
brief |
boolean |
false |
Show only summary of changes |
noColor |
boolean |
false |
Disable colored output |
Returns { a, b, frontmatter, sections: [{ heading, status, added, removed }], stats }.
Merge or chain multiple SKILL.md files into one.
| Option | Type | Default | Description |
|---|---|---|---|
mode |
string |
'merge' |
'merge' (dedup lines) or 'chain' (override) |
name |
string |
— | Output skill name |
json |
boolean |
false |
Return structured JSON |
noColor |
boolean |
false |
Disable colored output |
Returns { content, stats: { sources, totalInputSections, totalOutputSections, mergedSections, frontmatterFields } }.
Run quality assertions against a SKILL.md file.
| Option | Type | Default | Description |
|---|---|---|---|
all |
boolean |
false |
Test all installed skills |
json |
boolean |
false |
Return structured JSON |
verbose |
boolean |
false |
Show detailed results |
noColor |
boolean |
false |
Disable colored output |
noEmoji |
boolean |
false |
Use ASCII fallback for emojis |
minScore |
number |
0 |
Fail if score is below threshold |
only |
string|string[] |
— | Run specific checks by name |
Returns { skill, score, grade, label, assertions: [...], suggestions: [...] }. With --all, returns { results: [...], summary: { total, passed, failed, skipped } }.
Install an MCP server.
| Option | Type | Default | Description |
|---|---|---|---|
name |
string |
— | Override the server name |
yes |
boolean |
false |
Skip confirmation and security blocks |
dryRun |
boolean |
false |
Preview without making changes |
Returns { server: { name, command, args }, agent, configPath }.
List all installed MCP servers.
Returns { servers: [{ name, command, args, agent }] }.
Update an MCP server.
| Option | Type | Default | Description |
|---|---|---|---|
name |
string |
— | Server name override |
yes |
boolean |
false |
Skip confirmation |
dryRun |
boolean |
false |
Preview without making changes |
Returns { server: { name, command, args } }.
Remove an MCP server.
| Option | Type | Default | Description |
|---|---|---|---|
dryRun |
boolean |
false |
Preview only |
Returns { removed: true }.
Check MCP server health.
Returns { servers: [{ name, currentVersion, latestVersion, hasUpdate }], updatesAvailable: number }.
Search for MCP servers on npm or GitHub.
| Option | Type | Default | Description |
|---|---|---|---|
npm |
boolean |
false |
Search npm registry instead of GitHub |
interactive |
boolean |
false |
Enable TUI picker |
Returns { results: [{ name, description, source, stars }] }.
Save current agent configuration as a profile. Returns { agents: number }.
Apply a saved profile.
| Option | Type | Default | Description |
|---|---|---|---|
dryRun |
boolean |
false |
Preview only |
skipMcp |
boolean |
false |
Skip MCP configuration |
skipSkills |
boolean |
false |
Skip skill installation |
yes |
boolean |
false |
Non-interactive mode |
Returns { agents: [...], mcp: [...], skills: [...] }.
Compare current config against a saved profile. Returns { added: [...], removed: [...], changed: [...] }.
List all saved profiles. Returns { profiles: [...] }.
Show profile details. Returns { name, agents: {...}, createdAt, updatedAt }.
Delete a saved profile. Returns { deleted: true }.
Import a profile from file or URL. Returns { name, agents: number }.
Search the registry index by slug, name, or description.
| Param | Type | Description |
|---|---|---|
query |
string |
Search term |
Returns [{ slug, name, description, repo, author, versions, latest }].
Resolve a registry slug to its full skill metadata.
| Param | Type | Description |
|---|---|---|
slug |
string |
Registry slug (e.g. "react-rules") |
Returns { slug, name, description, repo, author, versions, latest }. Throws if not found.
Fork the registry repo, update index.json, and open a PR.
| Param | Type | Default | Description |
|---|---|---|---|
entry |
object |
— | { slug, name, repo, description?, version? } |
token |
string |
GITHUB_TOKEN env |
GitHub personal access token |
Returns { url, number } (PR URL and number).
Compare installed skills against registry and detect newer versions.
| Param | Type | Description |
|---|---|---|
skills |
array |
[{ slug, name, version }] |
Returns [{ slug, name, current, latest }].
Get detailed info about a single registry skill.
| Param | Type | Description |
|---|---|---|
slug |
string |
Registry slug |
Returns the full skill entry. Throws if not found.
List all skills in the registry. Returns [{ slug, name, description, repo, author, versions, latest }].
Clear the in-memory registry index cache. Next registry call will re-fetch from GitHub.
Detect agents and optionally install a skill to all detected agents.
| Option | Type | Default | Description |
|---|---|---|---|
yes |
boolean |
false |
Install all skills without prompt |
dryRun |
boolean |
false |
Preview only |
list |
boolean |
false |
List available skills without installing |
skill |
string|string[] |
— | Install specific skills by name |
Returns { agents: [{ flag, label }], installed?: [{ name, slug, results }] }. With list: true, returns { agents, skills: [{ name, slug, owner, description, files }] }.
Install multiple skills from inline sources or a bundle file.
| Option | Type | Default | Description |
|---|---|---|---|
dryRun |
boolean |
false |
Preview only |
noMcp |
boolean |
false |
Skip MCP server installation |
Returns { installed: number, failed: number, results: [{ source, status, error? }] }.
Watch installed local skills for file changes and auto-sync.
| Option | Type | Default | Description |
|---|---|---|---|
dryRun |
boolean |
false |
Preview only |
Returns { watchers: FSWatcher[], skills: string[] }. The caller is responsible for managing the watcher lifecycle.
Convert skills between SKILL.md and .mdc formats.
| Option | Type | Default | Description |
|---|---|---|---|
dryRun |
boolean |
false |
Preview only |
output |
string |
process.cwd() |
Output directory |
Returns [{ from: string, to: string, format?: 'skill-to-mdc'\|'mdc-to-skill' }].
Scaffold a new SKILL.md file.
| Param | Type | Description |
|---|---|---|
name |
string |
Skill name or owner/name (default: my-skill) |
Returns { path: string, slug: string, name: string, owner: string }.
Check for rolecraft updates and upgrade.
| Option | Type | Default | Description |
|---|---|---|---|
dryRun |
boolean |
false |
Check without upgrading |
Returns { current: string, latest: string|null, isUpToDate: boolean|null, upgraded?: boolean, version?: string }.
Generate shell completion script.
| Param | Type | Description |
|---|---|---|
shell |
string |
'bash', 'zsh', or 'fish' |
Returns the completion script as a string.
Generate a <skills_system> XML block listing installed skills.
| Param | Type | Default | Description |
|---|---|---|---|
writeToFile |
boolean |
false |
Write or replace XML section in ./AGENTS.md |
Returns { xml: string, written: boolean, path?: string }.
Compare two semver version strings. Returns negative, zero, or positive number.