Skip to content

chkit plugin

Lists registered plugins, lists a plugin’s commands, or runs a specific plugin command.

chkit plugin # list all plugins
chkit plugin <plugin-name> # list commands for a plugin
chkit plugin <plugin-name> <command> [args...] # run a plugin command

No command-specific flags. See global flags.

With no arguments, lists every plugin registered in your config (and the ObsessionDB plugin a login adds), in config order, with its name, version, and available commands. chkit’s built-in commands are not plugins and are not listed. With no plugin registered, it fails with exit code 1.

Configured plugins:
- codegen (v1.0.0)
- codegen: Generate TypeScript types

With a plugin name, lists the commands available for that plugin with their descriptions.

Plugin commands for "backfill":
- plan: Create a backfill plan
- run: Execute a backfill plan

With both a plugin name and command name, executes the command. The remaining arguments are forwarded to it: the flags the command declares are parsed into its flags, and the other arguments are its positional args. An undeclared flag is an error. Everything after -- is a positional, even when it starts with -:

Terminal window
chkit plugin my-plugin echo --name ada -- --not-a-flag

A command that takes no positional arguments declares it with takesArgs: false (Python: takes_args=False). chkit then rejects any argument given to it, before or after --, as it does for its own commands: Got unexpected extra argument(s) (<args>) on stderr, exit code 1, and with --json the error envelope with code usage on stdout. The command does not run, and neither do the onInit and onComplete hooks. A command that leaves it unset gets its arguments in args. The built-in plugins declare it on every command that reads no arguments, such as chkit obsessiondb login, so chkit obsessiondb login -- -h fails instead of logging in.

commands: [
{ name: 'sync', description: 'Sync now', takesArgs: false, run: runSync },
]

An unknown plugin fails with exit code 1 and Unknown plugin "<name>". Available: <plugins>. on stderr; with --json, stdout holds the error envelope with code error. An unknown command of a configured plugin prints Unknown <plugin> command "<command>". Available: <commands>. on stderr and exits 1; with --json, stdout holds {"command": "plugin", "schemaVersion": 1, "ok": false, "error": "<message>"} instead. The TypeScript list of plugins also names its built-in plugins (core, @chkit/internal-skill-hint).

Some plugins have top-level CLI shortcuts:

  • chkit codegen is equivalent to chkit plugin codegen codegen
  • chkit pull is equivalent to chkit plugin pull schema. Both run the installed pull plugin with its defaults when config.plugins does not register it (in Python pull is a built-in command with no plugin behind it)
  • chkit obsessiondb <command> is equivalent to chkit plugin obsessiondb <command>

In the TypeScript CLI, a plugin’s commands can also be called as chkit <plugin-name> <command> [args...]. A shortcut gives the command the same args as its chkit plugin form: the positionals after the command name, without the name itself.

Plugins are registered inline in the plugins array of your config. Python support is in beta; see the Python overview.

import { codegen } from '@chkit/plugin-codegen'
plugins: [codegen({ outFile: './types.ts' })]

Plugins can register hooks that run at various points in the CLI lifecycle:

  • onConfigLoaded — after config is parsed
  • onSchemaLoaded — after schema definitions are loaded (can modify definitions); runs for generate and snapshot rebuild, so both write the same snapshot
  • onSnapshotLoaded — in generate, on the previous snapshot’s definitions before they are compared with the schema (can modify definitions). A plugin that rewrites the schema in onSchemaLoaded applies the same rewrite here, so a snapshot written before the rewrite existed plans no change
  • onPlanCreated — after migration plan is computed (can modify the plan)
  • onBeforeApply — before migration SQL is executed (can transform statements)
  • onAfterApply — after migration SQL is executed
  • onCheck — during chkit check evaluation
  • onCheckReport — for custom check result formatting

onConfigLoaded and onSchemaLoaded receive the running command as context.command. During chkit snapshot rebuild it is snapshot; a hook that rewrites definitions only when the command is generate makes the rebuilt snapshot differ from the one generate writes.

List all plugins:

Terminal window
chkit plugin

List commands for a specific plugin:

Terminal window
chkit plugin backfill

Run a plugin command:

Terminal window
chkit plugin backfill plan --target analytics.events --from 2025-01-01 --to 2025-02-01
CodeMeaning
0Success
1No plugins configured, plugin/command not found, or an argument given to a command that takes none
{
"command": "plugin",
"schemaVersion": 1,
"plugins": [
{
"name": "codegen",
"version": "1.0.0",
"commands": [
{ "name": "codegen", "description": "Generate TypeScript types" }
]
}
]
}
{
"command": "plugin",
"schemaVersion": 1,
"plugin": "backfill",
"commands": [
{ "name": "plan", "description": "Create a backfill plan" },
{ "name": "run", "description": "Execute a backfill plan" }
]
}

Exit code 1. Text mode prints No plugins configured. Add entries to config.plugins first. on stderr; --json prints:

{
"command": "plugin",
"schemaVersion": 1,
"error": "No plugins configured. Add entries to config.plugins first.",
"plugins": []
}