Create a module
This is the shortest path from nothing to a module a host can install. Each step links to the reference page that goes deeper. A coding agent opened in a new module repo gets the same walkthrough as the knetik-create-module skill.
1. Create it
Section titled “1. Create it”npx knetik init weekly-reportcd weekly-reportnpm installnpm run check && npm testknetik init <id> writes a small complete module that already passes check and test: an agent stage that drafts two options, a pick gate, and a code stage that writes a Markdown file. It also writes the tests, scripted-model fixtures, AGENTS.md, the module skills and CI and release workflows.
| Option | Meaning |
|---|---|
--title "Weekly report" |
The display name (default: the id, capitalised) |
--dir <path> |
Where to create it (default: ./<id>) |
--link <path to a knetik clone> |
Link that clone’s packages (file:) instead of taking them from npm. Use it while the packages are not published, or when you work on the host too |
The id is lowercase letters, digits and single dashes, starting with a letter. The command refuses a folder that is not empty.
2. Decide the process
Section titled “2. Decide the process”Write one sentence for each before you change the code:
- Input: what a person gives it to start. Each field becomes a form field.
- Stages, in order: which use a model (agent stages), which are plain work (code stages), and where a person must decide (gates).
- Outputs: the files a run produces.
- Connectors: Slack, Google or an MCP server, with the scopes you need, and whether the module works without them.
- Configuration or input: choices made per run are input; values an admin sets once (config) are configuration.
3. Build in small steps
Section titled “3. Build in small steps”npm run check # manifest, stage graph, agents, schemas, connectors, fixturesnpm test # headless: real executor, scripted model, mock connectorsnpm run dev # the whole host with mocks and hot reload (needs a knetik clone next to the module)Change one stage, then check and test. Tests drive the whole process with runModule (see Testing): script what the model says, answer each gate by option id, mock connectors, and assert on the artifacts and the recorded events.
Three rules catch most mistakes: a code stage runs at least once, so it must be safe to run twice; a run’s outputs are stored in one database row (about 1.5 MB), so put large content in an artifact; and module code must not use Node-only APIs, because it also runs on Cloudflare Workers.
4. Release it
Section titled “4. Release it”- Raise
versioninknetik.module.ts. - Run
npm run check && npm test, then merge tomain. git tag v0.2.0 && git push --tags. The tag must equal the manifest version; the Release workflow checks that and creates the GitHub release.
5. Get a host to install it
Section titled “5. Get a host to install it”A host never loads a module while it runs. It vendors a reviewed copy pinned to a commit. The owner runs npx knetik add github:<org>/<repo>@<sha>, which shows what the module asks for and waits for approval, or the host’s bump workflow opens a pull request when it sees a new release tag.
Licensing
Section titled “Licensing”The @knetikdotdev packages a module imports (sdk, testing, cli, core) are Apache-2.0, which puts no condition on the license of your module. A new module starts with "license": "UNLICENSED" in package.json, which grants nobody else any rights; set a real license and add a LICENSE file before you share it. Apache-2.0 suits a module well: it is compatible with the AGPL-3.0 host that vendors modules, and with the packages. Put the copyright holder in a NOTICE file. The host itself is AGPL-3.0, which matters only to someone who modifies the host and runs it for other people.
Which parts need the host repository
Section titled “Which parts need the host repository”| Command | Needs |
|---|---|
npx knetik init, check, test |
The Knetik packages only (from npm, or linked with --link) |
npm run dev |
A clone of the knetik repo next to the module, installed, as the host it runs in |