Node.js API

July 31, 2026 · View on GitHub

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.

Usage

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()

Available Functions

install(source, options?)

Install a skill with security scan.

OptionTypeDefaultDescription
globalbooleanfalseInstall to ~/.agents/skills/
projectbooleantrueInstall to ./.agents/skills/
yesbooleanfalseBypass security prompts
dryRunbooleanfalsePreview only
symlinkbooleanfalseSymlink instead of copy
frozenLockfilebooleanfalseFail if already installed
noMcpbooleanfalseSkip MCP server installation
skillstring|string[]Specific skill slug(s)

Returns { results: [{ name, slug, owner, security, install }], mcpResults?: [...] }.

rollback(slug, options?)

Restore a skill to its previous version from backup history. History is created automatically on update or re-install.

OptionTypeDefaultDescription
listbooleanfalseShow history without restoring
dryRunbooleanfalsePreview without restoring

Returns { slug, files, targets, prevContentSha }.

Or with list: true: { slug, currentVersion, history: [{ version, contentSha, installedAt }] }.

list(cwd?, options?)

List installed skills.

OptionTypeDefaultDescription
jsonbooleanfalseReturn structured data
agentstringFilter 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 }.

remove(slug, options?)

Uninstall a skill.

OptionTypeDefaultDescription
dryRunbooleanfalsePreview only

Returns { removed: [...], targets: [...] }.

update(slug, options?)

Re-install a skill from its original source.

OptionTypeDefaultDescription
dryRunbooleanfalsePreview only

Returns { slug, source, updated: boolean }.

check(options?)

Check installed skills for available updates.

Returns { updates: [{ slug, hasUpdate }], current: [...] }.

verify(options?)

Verify SHA256 content hashes of installed skills.

Returns { verified: [...], failed: [...] }.

ci(options?)

Re-install all skills and MCP servers from lockfile.

OptionTypeDefaultDescription
yesbooleanfalseNon-interactive mode
dryRunbooleanfalsePreview only
frozenLockfilebooleanfalseFail if lockfile changes

Returns { installed: [{ slug, name, scope }], failed: [{ slug, reason }], skillCount, mcpCount, total, allPassed, mcpInstalled: [{ name, agents }], mcpFailed: [{ name, reason }] }.

search(query, options?)

Search for skills on GitHub or skills.sh.

OptionTypeDefaultDescription
skillsShbooleanfalseSearch skills.sh instead of GitHub
interactivebooleanfalseEnable TUI picker

Returns { results: [{ full_name, description, stargazers_count, language }], source: 'github'|'skills.sh' }.

doctor(options?)

Run system health check.

OptionTypeDefaultDescription
jsonbooleanfalseReturn structured data
networkbooleanfalseInclude GitHub connectivity test
deepbooleanfalseRun 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.

use(source, options?)

Preview a skill's files without installing.

Returns { name, slug, files: [...], targets: [...] }.

resolve(source)

Resolve a source string to its metadata. Returns { slug, name, files, contentSha, ... }.

resolveSkills(source)

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 }].

diff(skillA, skillB, options?)

Section-aware comparison of two SKILL.md files.

OptionTypeDefaultDescription
jsonbooleanfalseReturn structured JSON
briefbooleanfalseShow only summary of changes
noColorbooleanfalseDisable colored output

Returns { a, b, frontmatter, sections: [{ heading, status, added, removed }], stats }.

compose(sources, options?)

Merge or chain multiple SKILL.md files into one.

OptionTypeDefaultDescription
modestring'merge''merge' (dedup lines) or 'chain' (override)
namestringOutput skill name
jsonbooleanfalseReturn structured JSON
noColorbooleanfalseDisable colored output

Returns { content, stats: { sources, totalInputSections, totalOutputSections, mergedSections, frontmatterFields } }.

test(skillPath, options?)

Run quality assertions against a SKILL.md file.

OptionTypeDefaultDescription
allbooleanfalseTest all installed skills
jsonbooleanfalseReturn structured JSON
verbosebooleanfalseShow detailed results
noColorbooleanfalseDisable colored output
noEmojibooleanfalseUse ASCII fallback for emojis
minScorenumber0Fail if score is below threshold
onlystring|string[]Run specific checks by name

Returns { skill, score, grade, label, assertions: [...], suggestions: [...] }. With --all, returns { results: [...], summary: { total, passed, failed, skipped } }.

mcpInstall(source, options?)

Install an MCP server.

OptionTypeDefaultDescription
namestringOverride the server name
yesbooleanfalseSkip confirmation and security blocks
dryRunbooleanfalsePreview without making changes

Returns { server: { name, command, args }, agent, configPath }.

mcpList(options?)

List all installed MCP servers.

Returns { servers: [{ name, command, args, agent }] }.

mcpUpdate(name, options?)

Update an MCP server.

OptionTypeDefaultDescription
namestringServer name override
yesbooleanfalseSkip confirmation
dryRunbooleanfalsePreview without making changes

Returns { server: { name, command, args } }.

mcpRemove(name, options?)

Remove an MCP server.

OptionTypeDefaultDescription
dryRunbooleanfalsePreview only

Returns { removed: true }.

mcpCheck(options?)

Check MCP server health.

Returns { servers: [{ name, currentVersion, latestVersion, hasUpdate }], updatesAvailable: number }.

mcpSearch(query, options?)

Search for MCP servers on npm or GitHub.

OptionTypeDefaultDescription
npmbooleanfalseSearch npm registry instead of GitHub
interactivebooleanfalseEnable TUI picker

Returns { results: [{ name, description, source, stars }] }.

profileSave(name, options?)

Save current agent configuration as a profile. Returns { agents: number }.

profileApply(name, options?)

Apply a saved profile.

OptionTypeDefaultDescription
dryRunbooleanfalsePreview only
skipMcpbooleanfalseSkip MCP configuration
skipSkillsbooleanfalseSkip skill installation
yesbooleanfalseNon-interactive mode

Returns { agents: [...], mcp: [...], skills: [...] }.

profileDiff(name)

Compare current config against a saved profile. Returns { added: [...], removed: [...], changed: [...] }.

profileList()

List all saved profiles. Returns { profiles: [...] }.

profileShow(name)

Show profile details. Returns { name, agents: {...}, createdAt, updatedAt }.

profileDelete(name)

Delete a saved profile. Returns { deleted: true }.

profileImport(source)

Import a profile from file or URL. Returns { name, agents: number }.

searchRegistry(query)

Search the registry index by slug, name, or description.

ParamTypeDescription
querystringSearch term

Returns [{ slug, name, description, repo, author, versions, latest }].

registryResolve(slug)

Resolve a registry slug to its full skill metadata.

ParamTypeDescription
slugstringRegistry slug (e.g. "react-rules")

Returns { slug, name, description, repo, author, versions, latest }. Throws if not found.

registryPublish(entry, token?)

Fork the registry repo, update index.json, and open a PR.

ParamTypeDefaultDescription
entryobject{ slug, name, repo, description?, version? }
tokenstringGITHUB_TOKEN envGitHub personal access token

Returns { url, number } (PR URL and number).

registryCheckUpdates(skills)

Compare installed skills against registry and detect newer versions.

ParamTypeDescription
skillsarray[{ slug, name, version }]

Returns [{ slug, name, current, latest }].

registryInfo(slug)

Get detailed info about a single registry skill.

ParamTypeDescription
slugstringRegistry slug

Returns the full skill entry. Throws if not found.

registryList()

List all skills in the registry. Returns [{ slug, name, description, repo, author, versions, latest }].

registryClearCache()

Clear the in-memory registry index cache. Next registry call will re-fetch from GitHub.

setup(source, options?)

Detect agents and optionally install a skill to all detected agents.

OptionTypeDefaultDescription
yesbooleanfalseInstall all skills without prompt
dryRunbooleanfalsePreview only
listbooleanfalseList available skills without installing
skillstring|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 }] }.

bundle(sources, options?)

Install multiple skills from inline sources or a bundle file.

OptionTypeDefaultDescription
dryRunbooleanfalsePreview only
noMcpbooleanfalseSkip MCP server installation

Returns { installed: number, failed: number, results: [{ source, status, error? }] }.

watch(slug?, cwd?, options?)

Watch installed local skills for file changes and auto-sync.

OptionTypeDefaultDescription
dryRunbooleanfalsePreview only

Returns { watchers: FSWatcher[], skills: string[] }. The caller is responsible for managing the watcher lifecycle.

convert(source, options?)

Convert skills between SKILL.md and .mdc formats.

OptionTypeDefaultDescription
dryRunbooleanfalsePreview only
outputstringprocess.cwd()Output directory

Returns [{ from: string, to: string, format?: 'skill-to-mdc'\|'mdc-to-skill' }].

init(name?)

Scaffold a new SKILL.md file.

ParamTypeDescription
namestringSkill name or owner/name (default: my-skill)

Returns { path: string, slug: string, name: string, owner: string }.

upgrade(options?)

Check for rolecraft updates and upgrade.

OptionTypeDefaultDescription
dryRunbooleanfalseCheck without upgrading

Returns { current: string, latest: string|null, isUpToDate: boolean|null, upgraded?: boolean, version?: string }.

completions(shell)

Generate shell completion script.

ParamTypeDescription
shellstring'bash', 'zsh', or 'fish'

Returns the completion script as a string.

agentsXml(writeToFile?)

Generate a <skills_system> XML block listing installed skills.

ParamTypeDefaultDescription
writeToFilebooleanfalseWrite or replace XML section in ./AGENTS.md

Returns { xml: string, written: boolean, path?: string }.

compareVersions(a, b)

Compare two semver version strings. Returns negative, zero, or positive number.