/corezoid:corezoid-process-optimizerfrom corezoid
Optimizes Corezoid processes by reducing tacts, merging nodes, improving data flow, and adding resilience. Detects mode (auto/plan) and scope from user intent.
Ships in corezoid. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Determine mode and scope from the user's phrasing before doing anything else.
| User intent | Mode |
|---|---|
| "optimize", "apply", "fix", "improve" — action verb | AUTO — analyze, plan, execute |
| "show", "what can", "suggest", "check" — analysis verb | PLAN — analyze, report, wait |
In PLAN mode, after presenting the report ask:
"Apply all? Apply by group? (1 — tacts, 2 — data, 3 — naming, 4 — resilience, 5 — code nodes)"
The user may request a specific optimization group. Detect from keywords:
| Keyword(s) in request | Scope — run only |
|---|---|
| "tacts", "tact", "state changes", "nodes", "merge" | Group 1 |
| "data", "payload", "cleanup", "garbage", "fields" | Group 2 |
| "names", "naming", "titles", "readability", "descriptions" | Group 3 |
| "resilience", "semaphors", "timeouts", "stability" | Group 4 |
| "code node", "api_code", "replace code", "simplify code" | Group 5 |
| No group keyword — general request | All groups |
If scope is a single group — run Phase 1 analysis only for that group. Skip all others entirely.
Still run lint-process first (its findings feed Group 1 regardless).
Examples:
Resolve PROCESS_PATH before calling any tools:
find . -name "*.conv.json".lint-process — record findings. They become Group 1 quick-wins.Build a node map: id → { title, obj_type, logics[], sems[], outgoing edges }.
Trace the execution graph from the Start node following go.to_node_id and err_node_id edges.
Collect candidates for all five groups below.
Formula: SC = (N – 1) × T. Every node transition costs one state change. Fewer nodes = fewer tacts.
Detect chains A → B → C where all nodes have type: "set_param", connected sequentially with no branching.
Merge condition: all nodes share the same err_node_id (or all have none).
If err_node_id values differ — flag as candidate, do not merge automatically.
Merge action: combine all extra and extra_type objects into the first node. Remove subsequent nodes. Reconnect routing to where the chain ended.
Tacts saved: (chain length − 1) per task.
Detect chains of type: "api_code" nodes connected sequentially with no branching.
Merge condition: all share the same err_node_id.
If different — flag only; note that error handling must be unified first.
Merge action: concatenate src fields in order, separated by \n// ---\n. Keep one err_node_id. Remove subsequent nodes. Reconnect routing.
Tacts saved: (chain length − 1) per task.
Detect chains of type: "go_if_const" nodes where all check the same arg field.
Merge action: combine all conditions[] arrays into the first node. Each original branch keeps its own to_node_id. Remove subsequent condition nodes.
Do NOT merge if conditions check different fields — different semantics, merging hurts readability.
After merging, add a note to the plan:
"Merged conditions on field '{{field}}'. Review combined node for readability."
Tacts saved: (chain length − 1) per task.
Detect api_rpc nodes where no downstream node references any field that could only originate from the called process's reply.
Check: scan all downstream extra, condition arg/val, and src fields for parameter names not present in the task before the call. If none found — candidate for api_copy.
This change requires confirmation even in AUTO mode. Present:
"Node '[title]' calls process but does not use the reply. Replace with api_copy (fire-and-forget)? [yes/no]"
If confirmed: change type: "api_rpc" → type: "api_copy". Switch extra/extra_type to data/data_type per the api_copy schema (see ${CLAUDE_PLUGIN_ROOT}/docs/node-structures.md).
Apply lint findings:
scheme.nodes.extra/extra_type.After each type: "api" node, identify response fields not referenced by any downstream node.
Do NOT add a new cleanup node — inline the cleanup into the nearest existing downstream node:
delete data.<field>; at the top of src.Inside each api_code node's src, detect:
data.x = data.x — self-assignment, remove.Run this group when:
Critical nodes always get titles filled regardless of mode:
| Node type | Always fill title if empty |
|---|---|
api_code | Yes |
api | Yes |
api_rpc | Yes |
api_copy | Yes |
obj_type: 2 (End/Error) | Yes |
| Node type | Inference |
|---|---|
api | "[METHOD] [hostname][path]" from the url field |
api_rpc | "Call @[alias]" or "Call [conv_id]" |
api_copy | "Copy → @[alias]" or "Copy → [conv_id]" |
api_code | First meaningful line of src (strip data., max 40 chars) |
set_param | "Set [key1], [key2], ..." (first 3 keys) |
go_if_const | "Check [arg field]" |
obj_type: 2, icon error | "Error" |
obj_type: 2 | "Final" |
Never overwrite an existing non-empty title.
If params: [] and the Start node clearly receives input (inferred from downstream references to fields never set internally) — propose a params array.
Always ask for confirmation before applying — field types cannot be reliably inferred.
| Node type | Severity | Default timeout |
|---|---|---|
api_callback (Waiting for Callback) | 🔴 Critical — always add | 3600 sec |
api (API Call) | 🟡 Important — add without asking | 30 sec |
api_rpc (Call a Process) | 🟢 Recommended — add without asking | 60 sec |
Semaphor to_node_id must point to a valid error node.
If no suitable error node exists — create one at x + 300, same y as the parent node.
Use obj_type: 2 with title: "Timeout" and connect the semaphor to it.
Semaphor JSON:
{
"type": "time",
"value": 30,
"dimension": "sec",
"to_node_id": "<error_node_id>"
}
Prefer a light Condition + Set Parameters combination over an
api_codenode wherever the logic is only branching on values and assigning them. The logic becomes visible on the canvas, and there is no JavaScript left to fail at runtime. Default: replace wherever possible — "impossible" means only the cases in 5.3.Replacing costs tacts — this group works against Group 1. One Code node is one tact; on any path the replacement is a Condition plus a Set Param, so +1 tact per task, and a chain of k single-check Conditions costs up to +k. Only a branch-free node that becomes a single Set Param stays at +0; moving part of a Code node out (5.4) adds +1 per new node. Always state this cost in the plan. If the user asked to reduce tacts (Group 1 keywords), propose Replace only with +0, and list the rest as optional with their cost.
List every type: "api_code" node: title, which task keys it reads, which keys it writes (per outcome), where go and err_node_id lead. Put each into one category:
| Category | Meaning |
|---|---|
| Replace | Whole node → Condition + Set Parameters (5.2) |
| Simplify | Part of the logic moves out, a smaller Code node stays (5.4) |
| Merge | Join with an adjacent code node (1.2) — decided after replacements |
| Keep | Cite the 5.3 item, or "already optimal" (rename short names only) |
Present the table "node → category → result → tact cost → reason" in the plan, with the total tact change per task. Always confirm before changing any code node, even in AUTO mode. A node whose src carries a comment that it must stay Code is never proposed for replacement.
┌─ Set Param (outcome 1) ─┐
Condition ──┼─ Set Param (outcome 2) ─┼──► node the old code node's go led to
└─ Set Param (outcome N) ─┘
if/else → 2 branches; switch / if … else if … → one per distinct result (identical results share a branch).go_if_const in one Condition only when they test values of the same source. Outcomes that depend on different sources → a chain of single-check Conditions (one go_if_const each, default go to the next check).&& → several conditions inside one go_if_const (they are ANDed). || → several go_if_const leading to the same branch.go is the final else.go pointed to.Translating JS:
| In Code | In Condition / Set Parameters |
|---|---|
if (data.status === 'paid') | "param": "status", "fun": "eq", "const": "paid", "cast": "string" |
if (data.is_active === true) | "param": "is_active", "fun": "eq", "const": "true", "cast": "string" |
if (!data.status) / === '' — status is a string | "param": "status", "fun": "eq", "const": "" — matches only a missing or empty value; for a key that can hold false, 0 or null see 5.3 item 5 |
if (data.order.status === 'paid') | "param": "{{order.status}}" — a nested path must be wrapped in {{}}; a bare order.status is not resolved (only bare top-level names are) |
if (!data.items || !data.items.length) | Keep Code (5.3 item 3) — {{items[0]}} eq "" is not a length check: for items = [""] the JS is false and the Condition is true, so the task silently takes the other branch. Replace only if every writer of items is known to put objects or non-empty strings in it; then a missing key or element compares as "" |
if (data.a === data.b) | "param": "{{a}}", "fun": "eq", "const": "{{b}}" — const accepts a template |
if (data.total > 5) | "fun": "more", "cast": "number" |
data.x = 'const' | "x": "const" |
data.x = data.y | "x": "{{y}}" |
data.x = data.a + '_' + data.b | "x": "{{a}}_{{b}}" |
data.x = data.a + data.b (numbers) | "x": "$.math({{a}}+{{b}})" — $.math evaluates only two operands (a+b+c silently gives a+b): one operation per key, and a key that uses another key's result goes in the next Set Parameters node: keys of one node do not see each other (Runtime Behaviour). a+b+c = two nodes, +1 tact |
data.x = [] / {…} | JSON string value, extra_type array / object |
delete data.tmp | Set Param cannot delete keys → "tmp": "" — the key stays in the task; if it reaches a Reply or is read downstream, see 5.3 item 5 |
data.order = data.order || {}; data.order.status = … — Set Param keys {{order.status}}, {{order.total}} in one node do not merge: only one of them (the last alphabetically) survives, the rest are silently dropped, and the node still exits via go. Treat a single {{obj.x}} key over an existing object as unsafe too.
order, extra_type: object, value = JSON of all fields. Anything previously in the object is lost — confirm nothing earlier in the flow wrote it.data.x = data.x || 'default'. Possible as Condition (x eq "") + Set Param on the empty branch only; if x is a nested field, see item 1 → keep Code; if x can hold false, 0 or null, see item 5 → keep Code..length, regex, JSON.parse/stringify, .map/.filter/.reduce, iterating object keys, loops, date libraries, building arrays or tables from lists.!x, x || …, if (x)) on a key that can hold false, 0 or null: eq "" misses those values, and the task silently takes the other branch. Replace only if every writer of the key is known to produce a string.delete data.key where the key reaches a Reply, is copied to another process, or is checked for presence downstream: "key": "" leaves it in the task, so the output changes.src. Do it only if the remaining Code really shrinks — do not add a node for a single key..conv.json for {{key}} and data.key; keys returned in a Reply count as used).data, flatten nested if into early returns.orderTotal, customerQuery, padTwoDigits — not d, q, t, op. Exceptions: i/j loop counters, e in catch (e).Check behaviour locally: run the old and new src (Node.js) on inputs covering every branch and compare the resulting data key by key.
id: delete it, create the Condition with a new id, and re-point all incoming edges. Reusing the id breaks merges between stages ("referenced node … does not exist"). Code → Set Param (action → action) is safe.${CLAUDE_PLUGIN_ROOT}/docs/process/node-positioning-best-practices.md — do not re-layout the rest of the process.Present findings in this format before executing anything:
## Optimization Plan: <Process Title> (<ID>)
### Group 1 — Tact Reduction
| # | Type | Nodes | Tacts saved |
|---|--------------------|---------------------------------------|-------------|
| 1 | Merge set_param | "Set ref" → "Set amount" → "Set cur" | 2/task |
| 2 | Merge code | "Parse" → "Validate" | 1/task |
| 3 | Remove orphaned | "Old handler" (abc123) | 1/task |
| 4 | rpc→copy ⚠️ confirm | "Send notification" | wait saved |
Total nodes removed: N | Tacts saved: X/task
### Group 2 — Data Cleanup
| # | After node | Fields to remove | Inline into |
|---|---------------------|---------------------------|----------------------|
| 1 | "Call Stripe API" | payment_method_details... | "Parse response" |
### Group 3 — Readability
| # | Node (id) | Suggested title |
|---|----------------|----------------------------------------|
| 1 | api (abc123) | "POST api.stripe.com/v1/charges" |
| 2 | api_rpc (def) | "Call @payment-process" |
### Group 4 — Resilience
| # | Node | Issue | Action |
|---|-------------------------|-------------------------------|--------------------|
| 1 | "Call SMS API" | Missing timeout semaphor | Add 30sec |
| 2 | "Wait callback" 🔴 | Missing timeout semaphor | Add 3600sec |
### Group 5 — Code Node Reduction ⚠️ confirm
| # | Code node | Category | Result | Tact cost | Reason |
|---|----------------------|----------|-----------------------------------------------|--------------|------------------|
| 1 | "Set order flags" | Replace | Condition "Paid?" → 2 Set Params | +1 tact/task | if/else only |
| 2 | "Fill order fields" | Keep | — | 0 | 5.3 item 1 |
| 3 | "Build items table" | Simplify | constants → Set Param, loop stays in Code | +1 tact/task | 5.3 item 3 |
Total tact change: +2/task
### Requires action outside this process
- Hardcoded URL in "Call Stripe API" → use /corezoid-variable-manager
- Numeric conv_id 1307813 (×3 nodes) → use /corezoid-alias-manager
Always apply in this sequence:
| Change | Confirm in AUTO | Confirm in PLAN |
|---|---|---|
| Merge set_param / code / condition | No | Yes per group |
| api_rpc → api_copy | Always | Always |
| Replace / simplify code node (Group 5) | Always | Always |
run-task to verify Group 5 branches | Always | Always |
| Add semaphors | No | Yes per group |
| Fill titles (critical nodes) | No | No |
| Fill titles (other nodes) | No | Yes per group |
Fill params array | Always | Always |
| Create variable for hardcoded value | Always | Always |
PROCESS_PATH.lint-process — fix any errors before proceeding.push-process.run-task creates real tasks in the deployed process, and everything downstream runs too (API calls, Call Process, messages, payments). Ask the user before running them, naming the side-effecting nodes each branch reaches. If they decline, or the side effects cannot be made harmless, run on a non-production stage or skip, and report every branch as unverified;run-task once per Condition branch, with input that reaches it;| Finding | Action |
|---|---|
| Hardcoded URLs / tokens | Flag + point to /corezoid-variable-manager |
| Numeric conv_id without alias | Flag + point to /corezoid-alias-manager |
| Full Markdown documentation | Point to /corezoid-process-tech-writer |
| Cross-process audit | Point to /corezoid-project-review |
| Extract subprocess (architecture) | Discuss with user + point to /corezoid-create |
| Path | When to read |
|---|---|
${CLAUDE_PLUGIN_ROOT}/docs/node-structures.md | JSON schemas for all node types |
${CLAUDE_PLUGIN_ROOT}/docs/nodes/set-parameters-node.md | set_param merge rules |
${CLAUDE_PLUGIN_ROOT}/docs/nodes/code-node.md | Code node structure |
${CLAUDE_PLUGIN_ROOT}/docs/nodes/condition-node.md | Condition structure for Group 5 replacements |
${CLAUDE_PLUGIN_ROOT}/docs/nodes/set-parameters-built-in-functions.md | $.math and other value functions |
${CLAUDE_PLUGIN_ROOT}/docs/nodes/api-call-node.md | API Call semaphor configuration |
${CLAUDE_PLUGIN_ROOT}/docs/nodes/call-process-node.md | api_rpc vs api_copy decision |
${CLAUDE_PLUGIN_ROOT}/docs/nodes/copy-task-node.md | api_copy structure |
${CLAUDE_PLUGIN_ROOT}/docs/nodes/waiting-for-callback-node.md | api_callback critical semaphor |
${CLAUDE_PLUGIN_ROOT}/docs/process/error-handling.md | Error node patterns |
${CLAUDE_PLUGIN_ROOT}/docs/process/node-positioning-best-practices.md | Positioning new nodes |
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
corezoid, process-optimization, tact-reduction, node-merging, resilience
26 skills in this plugin
/corezoidCorezoid basics: platform model, .conv.json, nodes, MCP tools, validation. Use for any Corezoid task that no narrower corezoid-* skill covers.
/corezoid-accessShare processes, folders, stages, projects; groups, API-key users, invites, access audit. Triggers: "share", "доступ", "пошарь", "create API key".
/corezoid-alias-managerProcess aliases (short_name, conv[@alias]): create, list, modify, delete, link; callback hash / Direct URL. Triggers: "alias", "алиас".
npx claudepluginhub corezoid/corezoid-ai-plugin --plugin corezoidOther plugins' skills for the same job