DSH Quality
Beginner
3 min read

The ctx API: Your Plugin's First Steps

The ctx API: Your Plugin's First Steps — Learn how to build beginner dsh plugins.

Last updated: 2026-09-01

ctx: the plugin's toolkit

The ctx object is everything your plugin needs to register capabilities. It's the single interface between your code and the dsh runtime.

Available registration methods

  • ctx.commands.register(name, spec) — user-triggered commands
  • ctx.tools.register(spec) — model-called tools
  • ctx.ui.registerPanel(id, spec) — UI panels
  • ctx.ui.registerSkin(name) — theme registration
  • ctx.log(msg) — structured logging

The ctx object is isolated

Each profile gets its own ctx instance. This means plugins don't leak state between profiles — a critical security property.

Best practices

  1. Register everything in apply(), not lazily
  2. Use descriptive names that match user expectations
  3. Provide clear descriptions — the model reads them to decide whether to call your tool
  4. Return structured results, not prose