add-protocol-operation
Skill2 starsChanged 2 days agoMITView on GitHub
Adds an operation to the engine protocol, or a field or error code to one, from the spec row to the zod schemas, the compatibility snapshot and the engine's handler. Use when a client, the CLI, Telegram or an MCP tool needs the engine to answer something new.
In this repository26 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- add-chainSkill
- add-mcp-toolSkill
- add-migrationSkill
- add-venueSkill
- clean-diffSkill
- debug-failureSkill
- handle-security-reportSkill
- releaseSkill
- review-diffSkill
- review-money-pathSkill
- review-testsSkill
- run-testsSkill
- shape-commitSkill
- speed-up-testsSkill
- test-telegramSkill
- tune-ciSkill
- vet-releaseSkill
- write-adrSkill
- binference-toolsSkill
- copy-tradingSkill
- dca-planSkill
- meme-huntingSkill
- safe-swapSkill
- token-due-diligenceSkill
The file
We split this skill into the rules it gives an agent
5 rules. About 0 are common, 0 are distinctive, and 5 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.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 14
Add the row to the operations table in docs/specs/protocol.md: the name, its one scope, and args → result in one line.
- Very specific: line 36
Add the example call in src/examples/<domain>-examples.ts.
- Very specific: line 38
Add the row to specTable in src/operations/operations.test.ts and raise its count.
- Very specific: line 67
Add it to EngineHandlers in src/operations/create-engine.ts through the area's create<Area>Handlers.
- Very specific: line 69
Test it beside it with the test engine (src/operations/test-engine.ts): every answer, every refusal with its code, and the caller without …
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 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 a protocol operation
The protocol is the only way into the engine. Every surface (CLI, console, Telegram, MCP) calls
the same operations, so one is designed once, in the spec, and every client reads it from
@binference/protocol.
1. The spec first
- Add the row to the operations table in
docs/specs/protocol.md: the name, its one scope, andargs → resultin one line. Write what the engine answers, refuses and stores below the table. - The name is
domain/action, with the action in camelCase (asset/search,portfolio/resetPaper). Its words come fromdocs/GLOSSARY.md; add a new one there first. - The scope is exactly one of
scopesinpackages/protocol/src/auth/scopes.ts(read,propose,chat,agent,confirm,loosen,admin). Pick the narrowest that lets the caller do the job. Something that moves funds isconfirmor wider, and loosening a limit isloosen; neither is everreadorpropose. A call that needs a wider scope in some cases names it inscopeCase. - A choice the spec and the rules leave open is an ADR (
write-adr) before the code.
2. The schemas
In packages/protocol/src/operations/<domain>-operations.schema.ts:
- Declare the args and result interfaces, then the row in the table:
name,scope, the flags of its kind (readFlags,writeFlagsfor a write that takes an idempotency key,localWriteFlagsfor one over IPC alone,subscribeFlags),argsandresult. - Args are
z.strictObject; results arez.object, so an older client drops a field it does not know. Optional fields use.exactOptional(), nevernull. - Money is never a number:
amountSchema,decimalStringSchemaorsignedUsdMicrosSchema. - A shared view goes into
src/views/<name>-view.schema.ts, its interface declared and its schema annotated with it (decision 0098). - Add the example call in
src/examples/<domain>-examples.ts; the table type makes a missing one a compile error. - Add the row to
specTableinsrc/operations/operations.test.tsand raise its count.
3. Error codes
- A new code is dotted (
telegram.unreachable) and goes intoprotocolErrorCodesinsrc/errors/protocol-error-codes.ts, with its test. - Its message goes into
packages/i18n/messages/en/error.jsonandzh/error.jsonin the same change. - A code a later call may pass goes into
retryableCodesinpackages/server/src/call-failure.ts.
4. Compatibility
Inside a protocol version, changes are additive: new operations, optional fields, push kinds and error codes. A row the engine leaves unserved as not built may also narrow its scope, since no client can rely on it. Then:
pnpm check:protocol-compat --writeand commit packages/protocol/snapshots/v<version>.generated.json. A removed field, a narrowed
type or a changed meaning raises protocolVersion instead, and the engine serves the previous
version for one stable release.
5. The engine's handler
- The handler lives in
packages/engine/src/operations/<area>-handlers.ts, or in the feature's own folder, typedEngineHandler<"<name>">. It calls the use case and maps its outcomes to error codes; it holds no rule of its own. - Add it to
EngineHandlersinsrc/operations/create-engine.tsthrough the area'screate<Area>Handlers. - Test it beside it with the test engine (
src/operations/test-engine.ts): every answer, every refusal with its code, and the caller without the scope. - A Telegram fast command may call it only when its scope is
readorconfirm(ownerChatOperations). - The self-hosted engine serves every operation of the table but those named, each with why, in
packages/cli/src/compose/unserved-operations.ts;packages/cli/src/e2e/served-operations.test.tsprobes the enginebinference startruns against it. A new operation is served in the same change, or named there, andpnpm docs:genthen shows it on the operations reference; no surface may call a named one. A surface's fake that answers it proves nothing about the engine.
6. Surfaces
- A CLI command reads its words from i18n (
command.*) in both languages. - A
readorproposeoperation that an outside AI client should reach becomes an MCP tool (add-mcp-tool).
7. Check
pnpm vitest run packages/protocol packages/engine/src/operations --maxWorkers=2
pnpm vitest run packages/cli/src/e2e/served-operations.test.ts --maxWorkers=2
pnpm check:protocol-compat
pnpm check:i18nprotocol and engine are money-path packages: run review-money-path and paste its checklist.
8. Report
The operation, its scope and kind, the spec section, the error codes added, the snapshot change and the tests.
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.

