CLI usage
Three commands. All are idempotent — running them twice in a row is a no-op the second time.
agent-kit init
Scaffold a starter AGENTS.md (only if it does not exist), derive the per-tool files from it, and seed agentKit.targets in package.json.
npx @mongez/agent-kit@latest init # no install — runs the latest published versionnpx @mongez/agent-kit@latest init --target claude,cursorScoped name with
npx. Usenpx @mongez/agent-kit …(scoped) when running without a local install —npx agent-kit …(unscoped) resolves a different package. The bareagent-kitbinary only works once it’s installed locally.
Flags:
--cwd <path>— start from a different working directory (defaults toprocess.cwd()).--target <names>— comma-separated skill targets to write intopackage.json’sagentKit.targets(claude,copilot,cursor,codex,opencode,amp,goose,kiro,antigravity). Defaults toclaude. Passing this overwrites an existingagentKit.targets; without it, an already-set value is left alone. Unknown names error out before anything is written.
init vs sync — different delivery
initis a one-time scaffold →npx @mongez/agent-kit@latest initis ideal (zero install, always latest).syncruns on every install and in CI → install agent-kit as a pinned dev dependency and call it frompostinstall. Don’t route the recurring sync through always-latestnpx— a new agent-kit version could silently change generated output, breaking build reproducibility. Ad-hoc manualnpx @mongez/agent-kit@latest syncis fine.
Behavior:
- If
AGENTS.mdexists → leave it alone. - If
AGENTS.mdis missing → write a starter template. - Always derives
CLAUDE.md,.gemini/GEMINI.md,.github/copilot-instructions.md,CONVENTIONS.md. - Seeds
agentKit.targetsintopackage.json: writes["claude"](the built-in default, made explicit so it’s discoverable and editable) when noagentKit.targetsexists; writes--target’s value when that flag is passed, overwriting any existing list. An existingagentKitblock’s other fields (pick,omit, …) and the file’s indentation are preserved. Notetargetsonly gates the skills export —inititself doesn’t sync skills, so the seeded value first takes effect on the nextagent-kit sync. - Wires
"postinstall": "agent-kit sync"intopackage.json— but only when it’s safe: (1)@mongez/agent-kitis already a declareddependency/devDependency(so the bareagent-kitbinary resolves at install time — thenpx @mongez/agent-kit@latest initbootstrap installs nothing, so wiring a postinstall there would break the next install), and (2) nopostinstallalready exists (an existing one is never clobbered). When either gate blocks,initprints a hint instead of writing.
agent-kit sync
Re-derive the per-tool files from AGENTS.md and export skills from installed packages.
npx agent-kit syncnpx agent-kit sync --target claude,cursornpx agent-kit sync --derive-onlynpx agent-kit sync --skills-onlynpx agent-kit sync --path @warlock.jsnpx agent-kit sync --projects backend,frontendnpx agent-kit sync --overrideFlags:
--cwd <path>— working directory override.--target <names>— comma-separated skill targets. Valid:claude,copilot,cursor,codex,opencode,amp,goose,kiro,antigravity. Defaults toclaude.--derive-only— skip skills export.--skills-only— skip derivation.--path <dirs>/-p— comma-separated extra dirs to scan, each treated like anode_modules/(its children are packages). Use for folders of linked packages (--path @warlock.js). Packages found in scan paths override same-named entries innode_modules/.--projects <dirs>— comma-separated monorepo project dirs (or one-level globs likeapps/*) to aggregate. Each is treated as one project: its ownskills/(prefixed with the project dir name) plus itsnode_modules/deps (filtered by that project’sagentKitconfig). Distinct from--path; defaults toagentKit.monorepo.projects. See the Monorepos page.--override— replace user-authored destination folders (those without our.agent-kit-managedsentinel). Skipped with a warning by default.
This is the command to wire into your project’s postinstall:
{ "scripts": { "postinstall": "agent-kit sync" }}agent-kit watch
Watch AGENTS.md and your editable skill source directories; re-derive and re-sync on change. Intended for the active dev loop when editing skills locally and for monorepo / path-linked setups where postinstall does not re-fire.
npx agent-kit watchnpx agent-kit watch --path @warlock.jsnpx agent-kit watch --projects backend,frontendFlags:
--cwd <path>— working directory override.--path <dirs>/-p— extra package dirs (each treated like anode_modules/) whoseskills/should also be watched.--projects <dirs>— monorepo project dirs (or one-level globs) to aggregate + watch. Defaults toagentKit.monorepo.projects.--override— replace user-authored destination folders on each re-sync.
Behavior:
- Performs a full sync on startup so the working tree is consistent.
- Resolves the real skill-source directories and watches those:
AGENTS.md, the rootskills/, each--pathpackage’sskills/, and each--projectsproject’sskills/+package.json(sopick/omitedits re-sync too). Watching concrete dirs is deliberate — chokidar v4+ dropped glob support, so glob patterns would silently match nothing. - Dependency skills under
node_modules/are not watched — they change only on (re)install, which firespostinstall→sync. - Listens for
add/change/unlinkand debounces re-syncs by 150ms. - New top-level skill folders created mid-session are picked up on the next
watchrestart.
Programmatic API
import { deriveAll, syncSkills, findProjectRoot, scanForSkillPackages, deriveSlugForSkill,} from "@mongez/agent-kit";
const root = await findProjectRoot();if (!root) throw new Error("No package.json found");
const derived = await deriveAll({ root, targets: ["claude"] });const skills = await syncSkills({ root, targets: ["claude", "cursor"], scanPaths: ["@warlock.js"], // optional: extra scan roots (children = packages) projects: ["backend", "frontend"], // optional: monorepo projects to aggregate override: false, // optional: replace user-authored dest folders});
// skills.exported, skills.pruned, skills.skipped, skills.targets,// skills.packages, skills.scannedPaths, skills.projectsExit behavior
- All commands exit 0 on success.
syncexits non-zero ifAGENTS.mdis missing (the derive pass throws).--skills-onlybypasses that pass and succeeds without it.initnever errors on a missing source — it creates one.watchruns until the process is killed.