Your first plugin
Create a local project
From the repository root, create a scratch project for the tutorial:
What is a plugin?
In Harness, a plugin is a TypeScript module that exports an apply function. The framework calls apply when loading the plugin and passes a ctx context object through which the plugin registers capabilities:
That is the complete configuration.
Create the plugin file
Create scratch-plugin/src/my-plugin.ts:
Register it in cordis.yml
Run pwd from the repository root, then create scratch-plugin/cordis.yml as a Web overlay that inserts the local plugin. Replace /absolute/path/to/deepseek-harness below with the printed path:
The plugin path must be absolute. A patch file contributes configuration but does not change the profile directory from which the loader resolves module paths.
Start the Web UI with that overlay:
Open the launch URL printed in the terminal, including its authentication fragment. The terminal prints [hello-plugin] plugin loaded! during startup.
Edit and stop
Change the greeting in the plugin, stop the development command with Ctrl+C, and run the same command again. Verify the new greeting in the terminal. Use the newly printed launch URL after each restart; port 0 requests an available port from the OS. Stop the command when finished.
Automatic cleanup
Anything registered through ctx—event listeners, tools, or timers—is cleaned up when the plugin unloads. You do not need to call removeListener or clearInterval manually.
For a resource that needs explicit cleanup, such as a network connection, use ctx.effect() to provide its disposer:
Declare dependencies
If the plugin consumes another service such as tools or llm, declare it in inject:
The framework waits for every required service before loading the plugin.
Three plugin forms
In addition to a function module, a plugin can use object or class form.
Object form
Class form
Function form is sufficient in most cases. Use class form when the plugin provides a service to other plugins; see services and dependencies.
Next steps
- Build a tool — learn the tool definition DSL
- Plugin configuration — accept user configuration
- Cordis tutorial — the plugin framework underneath, built from a scratch directory with no API key