chain-hub
v0.2.0
Published
Chain Hub CLI — manage AI agent skills across IDEs
Downloads
541
Readme
Chain Hub CLI
Site: chainhub.one · Repository: github.com/martijnbokma/chain-hub
Manage AI agent skills and IDE symlinks from one place with Chain Hub. Published as chain-hub on npm; the executable name is chain.
Requirements
- Bun (for development and tests)
- Node 20+ when running the built
dist/chain.jsafterbun run build
Installation (from this repo)
Replace <REPO_ROOT> with wherever you cloned the repository (for example ~/Code/side-projects/chain-hub).
cd <REPO_ROOT>/cli
bun installRun without a global install — add to ~/.zshrc or ~/.bashrc (set CHAIN_HUB_REPO once so moving the clone only updates one line):
export CHAIN_HUB_REPO="$HOME/Code/side-projects/chain-hub"
alias chain="bun run $CHAIN_HUB_REPO/cli/chain.ts"Or build a single file and put it on your PATH:
cd <REPO_ROOT>/cli
bun build --target=node --outfile dist/chain.js chain.ts
# Executable: node dist/chain.js — or use `bun build --compile` if you prefer a native binaryFrom npm (when published):
npm install -g chain-hub
chain --helpKeeping the CLI up to date (npm)
The chain binary comes from the chain-hub package. Re-run the global install whenever you want a newer CLI (npm installs the latest version unless you pinned one):
npm install -g chain-hub
chain --versionAfter upgrading the CLI, run chain init so CHAIN_HOME/core/ matches the bundled core shipped with that version. Run chain setup again if release notes say IDE symlink layouts changed.
Skills you installed from the registry or from configured GitHub bundles are updated separately with chain update.
Environment
| Variable | Default | Description |
|---------------|-------------|-------------|
| CHAIN_HOME | ~/chain-hub | Canonical user hub: skills, agents, workflows, rules, skills-registry.yaml, and (after chain init) the core/ subtree. |
Resolution priority for hub location:
--chain-home <path>flag (per command)CHAIN_HOMEenvironment variablechain config set chain_home <path>(persisted user config)- default
~/chain-hub
Hub layout (recommended model)
- One root: All user data for Chain Hub lives under
CHAIN_HOME. The npm package (or a local source checkout for development) only delivers thechainbinary and bundledcore/source packaged into the CLI; it is not your personal library location unless you deliberately setCHAIN_HOMEinside a checkout. - Core vs user:
CHAIN_HOME/core/is the protected copy installed bychain init. Your skills, agents, workflows, and custom rules belong inCHAIN_HOME/skills/,agents/,workflows/,rules/(plus registry files at the hub root). This matches common “flat top-level folders +skills/<slug>/SKILL.md” patterns used by agent tooling ecosystems. skills-registry.yamlbuckets:corelists bundled/protected skills mirrored underskills/(optional; keeps them distinct frompersonal).chain_hublists skills installed viachain addfrom the Chain Hub registry index.personalis for your own scaffolds / ad-hoc GitHub installs / manual entries.packsis for curated multi-skill bundles (for example a premium pack): install withchain add github:org/repo --packso skills stay out ofcore, appear under the pack label inchain list, and refresh together viagithub_sourcesonchain update. Addcreditsin YAML for attribution.~/.agents: Some adapters symlink hubskills/andagents/into~/.agents/for tools that expect that layout. Treat~/.agentsas an IDE-facing mirror, not a separate primary library — edit and back upCHAIN_HOME.- Sandboxes: For contributors or experiments, point
CHAIN_HOMEat a throwaway directory sochain init/chain addnever touch another hub or a git working tree you care about.
export CHAIN_HOME="$HOME/chain-hub"
# Optional XDG-style example (create the directory first):
# export CHAIN_HOME="${XDG_DATA_HOME:-$HOME/.local/share}/chain-hub"First-time setup
chain init— copies packagedcore/intoCHAIN_HOMEand ensuresskills-registry.yaml.chain setup— symlinksskills,agents,workflows, and supported paths into detected IDEs.chain list/chain validate— inspect and verify the tree.
chain init
chain setup
chain list
chain validateIf chain validate reports a missing skills-registry.yaml, run chain init first.
When CHAIN_HOME is a Chain Hub source checkout (the git clone that contains cli/chain.ts and core/registry.yaml), chain setup installs a .git/hooks/pre-commit script that runs chain validate with CHAIN_HOME set to the repository root. The hook calls the chain binary on your PATH (for example from npm install -g chain-hub); if chain is not installed, the hook skips validation. Hubs that are not that source tree do not receive this hook.
Usage in projects
You typically do not install the CLI per project. After chain setup, IDEs read skills from CHAIN_HOME via symlinks.
Commands (overview)
| Command | Purpose |
|--------|---------|
| chain setup | Create or refresh IDE symlinks (--ide <name> for one IDE) |
| chain status | Show symlink health per IDE |
| chain list | List skills with registry labels and optional GitHub bundle info |
| chain search <query> / chain find <query> | Search the Chain Hub registry and the skills.sh open directory (GET /api/search, same backend as npx skills find). find is an alias of search. Use --hub-only to skip the directory. Override directory host with SKILLS_API_URL. Live hub index: registry/index.yaml on GitHub main; if that fetch fails, the CLI uses a bundled copy from the last package build. |
| chain add <slug> | Install from registry or github:owner/repo (use --pack for curated GitHub bundles / premium packs) |
| chain update | Refresh registry and GitHub-bundle skills from their sources |
| chain remove <slug> | Remove a registry-installed skill |
| chain new <slug> | Scaffold a skill under CHAIN_HOME/skills/ and register it under personal in skills-registry.yaml |
| chain validate | Validate skills and workflows (built-in checks; use --fix where supported) |
| chain capture | Append one learning event to learnings/queue/inbox.jsonl (--event, --skill, --summary; optional --repo) |
| chain reflect | Turn the inbox into learnings/drafts/distill-*.md and archive the queue (--dry-run to preview only) |
| chain fix | Auto-fix some frontmatter/section issues |
| chain init | Install/update protected core assets into CHAIN_HOME |
| chain config get chain_home | Show active CHAIN_HOME and source |
| chain config set chain_home <path> | Persist default hub path in user config |
| chain config unset chain_home | Remove persisted hub path (falls back to env/default) |
Supported IDEs include Cursor, Windsurf, Claude Code, Antigravity (antigravity.google), Gemini CLI, Trae, Kiro, Mistral Vibe (~/.vibe/skills), and a Universal .agents/ fallback — see chain setup --help. chain status and chain setup print that link when Antigravity is configured.
Examples
chain setup
chain setup --ide cursor
chain --chain-home ~/.chain-sandbox init
chain config set chain_home ~/my-chain-home
chain add github:owner/repo
chain add github:your-org/chain-hub-pro --pack
chain find typescript
chain validate
chain validate --fixTypical workflow on a new machine
npm install -g chain-hub
# Optional: point CHAIN_HOME at a dedicated directory
export CHAIN_HOME="$HOME/chain-hub"
echo 'export CHAIN_HOME="$HOME/chain-hub"' >> ~/.zshrc
chain init
chain setup
chain statusTo upgrade an existing install: npm install -g chain-hub, then chain init (and chain setup if needed). Use chain update for registry/GitHub skills.
Development
cd cli
bun test # full test suite
bun run dev -- --help # run CLI via Bun
bun run build # emit dist/chain.js
bun run pack:check # sync core/ (incl. core/templates) into cli/, build, verify package filesBefore npm publish
bun testandbun run pack:check— same gates as CI (prepackruns these steps when you publish).bun run smoke:package— runsnpm pack, installs the tarball in a temp directory withnpm install, thennode …/dist/chain.js initandvalidatewith an isolatedCHAIN_HOME. Requires Node 20+ and npm on your PATH.npm publish --dry-run(fromcli/) — exercises publish lifecycle without uploading.
Optional: after npm pack, install the .tgz globally in a throwaway environment and run chain init / chain validate.
