-
-
Notifications
You must be signed in to change notification settings - Fork 3
Plugin Best Practices
CortexPrism edited this page Jun 17, 2026
·
1 revision
Full guide at: docs/plugins/best-practices.md
- Single responsibility — one plugin, one job
-
Fail gracefully — return failure results, never throw from
execute - Validate inputs — check params at the top of every tool
-
Respect timeouts — track
durationMsaccurately - Declare minimal permissions — only request what you use
-
Handle cleanup — always clean up in
onUnload
- Use TypeScript for type safety
- Avoid global state — use
PluginContext.stateor lazy init - Handle cleanup in
onUnload(clear intervals, close connections)
- Handle process lifecycle (SIGTERM/SIGINT)
- Minimize startup time — defer expensive setup
- Stream large results where possible
- Optimize for size (opt-level=s, lto=true, strip=true)
- Use simple types — JSON for complex data
- Test outside CortexPrism first (
wasmtime run plugin.wasm)
cortex plugins install ./my-plugin
cortex plugins enable my-plugin
cortex plugins list
cortex chat # test in a chat session- Hardcoded secrets — use
ctx.configor env vars - Synchronous blocking — all
executefunctions must be async - Overly broad permissions — request minimum required
- Crashing the host — never throw from tool execution
- Silent failures — log errors and return meaningful messages
- Undocumented config keys — declare all settings in
ui.settings
- Developing Plugins — Full development guide
- Publishing Plugins — Submit to marketplace
CortexPrism — Open-source agentic AI harness · MIT License · Built with Deno 2.x + TypeScript