code-foundry-plugin
Build, debug and publish a Code Foundry plugin: a Go executable with a plugin.json manifest that adds commands, surfaces (tabs), thread flags, event subscriptions, session environment or its own Claude threads and terminals. Use for anything touching a plugin, plugin.json, pluginsdk, pluginsdk/ui or plugintest, for the code-foundry plugin dev, logs, surface or act commands, or for a plugin registry.
- License 许可
- Apache-2.0
- 最近更新
- 2026-11-15
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- code-foundry-plugin
- description
- Build, debug and publish a Code Foundry plugin: a Go executable with a plugin.json manifest that adds commands, surfaces (tabs), thread flags, event subscriptions, session environment or its own Claude threads and terminals. Use for anything touching a plugin, plugin.json, pluginsdk, pluginsdk/ui or plugintest, for the code-foundry plugin dev, logs, surface or act commands, or for a plugin registry.
02 资源文件 13
- 参考文档reference/events.md8.4 KB
- 参考文档reference/forms.md8.7 KB
- 参考文档reference/host-api.md15.6 KB
- 参考文档reference/icons.md137 B
- 参考文档reference/manifest.md15.0 KB
- 参考文档reference/nodes.md16.5 KB
- 参考文档reference/owned.md6.3 KB
- 参考文档reference/primitives.md16.1 KB
- 参考文档reference/protocol.md12.6 KB
- 参考文档reference/publishing.md11.2 KB
- 参考文档reference/testing.md16.0 KB
- 参考文档reference/ui-layout.md17.5 KB
- 参考文档reference/wakes.md5.5 KB
03 SKILL.md 正文
Building a Code Foundry plugin
{{cf.provenance}}
A plugin is an executable the daemon starts and talks to over stdin and stdout
(newline-delimited JSON-RPC 2.0). Its plugin.json declares everything up front: commands,
surfaces (tabs drawn from a JSON view model; no HTML), wake sources, and the
permissions the user consents to. Write it in Go with github.com/alexwaumann/code-foundry/pluginsdk
(/ui builds views, /plugintest is a fake host). This Code Foundry is {{cf.version}}.
Read only what the task needs
Files are split into ## sections: grep -n "^## " <file>, then read the one you need.
| To | Read (in reference/) |
|---|---|
Declare commands, surfaces, permissions, when clauses |
manifest.md |
| Find an icon name (search it, do not read it) | icons.md |
| Draw a view: model, value types, limits, acts, design rules, which node to use | primitives.md |
| Use a display node (list, chips, log, notice, section…) or a menu | nodes.md |
| Take input (fields, pickers that search, drafts, secrets in forms) | forms.md |
| Lay out: columns, pane, grid, group, master-detail; a toolbar or footer (search, filters) | ui-layout.md |
Call the host: h.Log, h.DataDir, Invoke, flags, context facts, session env, secrets, toasts |
host-api.md |
| React to daemon events | events.md |
| Let agents wait on the plugin instead of polling | wakes.md |
| Run its own Claude threads or terminals | owned.md |
| Debug the wire: lifecycle, process, errors, timeouts, crashes | protocol.md |
| Write tests, drive it against the daemon | testing.md |
| Release, runners, the registry | publishing.md |
| Look up a CLI flag, or a host command it may run | cli.md, host-commands.md (threads, views: host-commands-thread-view.md) |
example/ is the plugin to copy. go doc github.com/alexwaumann/code-foundry/pluginsdk
(/ui, /plugintest) has every type. For a working use of any component, code-foundry plugin install alexwaumann/code-foundry-plugin-showcase and read its tab_*.go; larger
plugins: alexwaumann/code-foundry-plugin-gh-actions, -test-watcher.
The loop
- Scaffold under the home directory (ask where the user keeps code), with Go 1.24+:
code-foundry plugin new <name> <dir> --owner <github owner>makes<dir>/code-foundry-plugin-<name>from the example, named, with the module (up to 5 minutes). Fill in the README; ask which Actions runner to use (publishing.md, "Runners"). - Manifest: edit
plugin.json, with the fewest permissions that work. - SDK:
plugin newpins this build's; an existing plugin takes it withgo get github.com/alexwaumann/code-foundry/pluginsdk@{{cf.sdkPin}}. - Serve: in
main.go,pluginsdk.Serve(pluginsdk.Plugin{...})with a handler for every manifest command (Commands, by name) and surface (Surfaces, by id), plusInit,OnEventandShutdownas needed. - Run:
code-foundry plugin dev "$PWD" --watch --follow=falsebuilds (make build) and restarts it now and after each edit (a failed build exits 1; the old one runs on). The first time, and when permissions grow, it prints the consent text and exits 2. A plugin you wrote here that asks for no permissions: re-run with--yes. One that asks for any: show the user that text and re-run only after they say yes.plugin listmust sayrunning (dev, watching). - Check:
code-foundry plugin logs <name> --lines 50shows its stderr,h.Log()and refused calls or views (never--followfrom Bash: it does not return). Drive it withplugin <name> <command>,plugin surface(--shot s.pngto see it) andplugin act(testing.md); after an edit they wait for the build. - Test:
go test ./...with plugintest: every command, every act, and every view throughui.View.Validate. - Publish (
publishing.md): only after asking the user, since it goes out under their name. List it only in a registry they configured, never a default.
Rules Validate does not catch
- Commands first. Whatever a user can do is a manifest command (palette, CLI, agents) that a button runs. Events are for what only makes sense in the view: tabs, form submits, selecting a row.
- Confirm remote or side-effecting commands (cancel CI, deploy, delete, sign out) with
confirmtext. Local work that is cheap to redo needs none. - Secrets never go in a view, log line, command arg or argv: a form's secret input with
storekeeps one,h.Secrets().Getreads it. - Handlers: requests run concurrently, so guard state with a mutex; notifications run in
order on one goroutine, so
OnEventreturns quickly; none run beforeInithas returned. - Tools: the plugin's environment is minimal, so run the user's own tools through
$SHELL -lc "<cmd>". stdout is the protocol;h.DataDir()is its state folder.
04 同仓库更多 Skills
pr-review
Review a pull request against the team's checklist.
inner
Inside another skill, so never listed.
sql-helper
Write SQL for the warehouse.
foo
Out of scope (enterprise/plugins).
query-warehouse
Run read-only SQL against the warehouse.
catalog
Look up tables in the data catalog.