add-ipc-channel
Skill874 starsChanged 7 days agoMITView on GitHub
Add or change a renderer-to-main IPC channel (a new window.studio call) end to end - main handler, preload, typed API, fixture classification and tests. Use when the renderer needs a new capability from the main process or core.
In this repository33 other files it gives its agents.
- AGENTS.mdAGENTS.md
- src/AGENTS.mdAGENTS.md
- tests/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- src/CLAUDE.mdCLAUDE.md
- tests/CLAUDE.mdCLAUDE.md
- add-event-typeSkill
- add-ipc-channelSkill
- add-plugin-toolSkill
- better-colorsSkill
- better-layoutSkill
- better-typographySkill
- better-uiSkill
- better-writingSkill
- breakSkill
- harness-incident-fixSkill
- run-area-testsSkill
- variantSkill
- verify-ui-via-dev-controlSkill
- wire-artSkill
- add-event-typeSkill
- add-plugin-toolSkill
- better-colorsSkill
- better-layoutSkill
- better-typographySkill
- better-uiSkill
- better-writingSkill
- breakSkill
- harness-incident-fixSkill
- run-area-testsSkill
- variantSkill
- verify-ui-via-dev-controlSkill
- wire-artSkill
The file
We split this skill into the rules it gives an agent
4 rules. About 0 are common, 0 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 36
Put the logic in StudioCore (src/main/studio-core.ts) or the service under src/main/core/ it delegates to, not in the handler, so it is …
- Very specific: line 42
Renderer: - call window.studio.myThing(...) from the owning panel/hook.
- Very specific: line 43
Docs: - if users can see the behaviour, update the owning docs/product/*.md page.
- Very specific: line 66
Do not add assertions that read index.ts or the preload as text.
≈ “Common” is an estimate: at least 1 in 5 of the 372,429 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Add an IPC channel
The renderer reaches main only through the fixed preload API. There is no generic invoke, no eval and no filesystem access from the page; every capability is one named call.
Files, in order
- Contract -
src/shared/studio-api.ts: add the method toStudioApiwith exact parameter and result types. Put shared payload types in asrc/shared/*.tsmodule (browser-safe: nonode:, noelectron, no imports fromsrc/main|preload|substrate). - Channel map -
src/shared/ipc-channels.ts:"studio:my.thing": "myThing"inSTUDIO_INVOKE_CHANNELSand"studio:my.thing": { id: string }inStudioInvokePayloads(the payload the preload sends; the result is derived fromStudioApi). A push stream from main is aSTUDIO_PUSH_CHANNELSentry naming itson*call; a new UI event rides the existingstudio:eventpush and is aUiEventMapkey instead, and a new durable record is aCustomEventMapentry read throughstudio:events(theadd-event-typeskill). A method the harness calls is no channel either: it is aHarnessHostApikey insrc/shared/harness-api.ts(docs/agent/recipes.md, Harness RPC method). - Preload -
src/preload/studio-bridge.ts: one line in the returned object,myThing: id => invoke("studio:my.thing", { id }). Keep it a named call; a push stream usessubscribe(channel, listener)likeonTerminal. - Main - the domain's registrar,
src/main/ipc/<domain>.ts(composed bysrc/main/index.ts; a new domain gets its ownregister<Domain>Ipc(handle, deps)there):handle("studio:my.thing", payload => core.myThing(payload.id));with no payload annotation:handletakes the payload and result types from the map, wraps the result as{ok,value}/{ok,error}and runs the fixture guard. A registrar owns no state: it takes the core and anything else it needs as explicitdeps. Push withpushToRenderer. Validate the payload at this boundary (types are not checked at runtime); resolve paths by realpath inside an owned root; never accept a PID, URL to open or absolute path from the page unless the channel exists for exactly that and isnative. Put the logic inStudioCore(src/main/studio-core.ts) or the service undersrc/main/core/it delegates to, not in the handler, so it is testable in Node. - Classify -
src/main/dev/native-policy.ts: add the channel to the fixture-safe list (no account, dialog, download, external app or network) or to the native list. Both lists are checked against the channel map, so an unclassified channel failsnpm run typecheck; at runtime fixture profiles refuse it too. - Renderer - call
window.studio.myThing(...)from the owning panel/hook. - Docs - if users can see the behaviour, update the owning
docs/product/*.mdpage.
Tests (red first)
- Behaviour: test the core method or module directly.
tests/helpers/core-lite.ts(coreLite()) gives a realStudioCorewithout a harness; usetests/helpers/studio-rig.tsonly when the harness loop must run. - Handler wiring, when the handler does more than call the core (pushes, keep-awake, several
calls): drive the registrar through the real typed
handle()fromcreateIpcHandlewith recorders for its deps, astests/conformance/main-ipc.test.tsdoes. - Hostile input: a table of bad payloads (missing fields, traversal
../, symlink escape, wrong types) asserting the call fails and nothing was written. - Policy:
node --test tests/conformance/native-policy.test.ts tests/conformance/dev-policy.test.ts. - Contract:
npm run typecheck(the map types both sides) andtests/conformance/ipc-contract.test.ts(the preload, main and the policy use exactly the map's channels). - Rendered check when UI changed: the
verify-ui-via-dev-controlskill.
npm test -- tests/conformance/native-policy.test.ts tests/conformance/<your-area>.test.ts
npm run verify:architecture # browser boundaryDo not add assertions that read index.ts or the preload as text; test behaviour.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

