/selise-blocks:blocks-functionsfrom selise-blocks
Write, test, and deploy serverless Node functions on Blocks Logic, including triggers, secrets, runs/logs, and calling them from app code via the SDK.
Ships in selise-blocks. 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.
Read when SKILL.md points to them.
When invoking a project-scoped blocks command, either use the resolved account's saved selection or pass --project <tenantId> for that one command without changing saved state. --project applies to CLI commands only, never SDK calls.
A function is a Node 24 ES module the platform runs in a sandbox on demand. The tenant writes the handler; Blocks builds an image, runs it per call, and records every run with its logs. Two surfaces:
blocks logic function * — authoring and operating: create, save source and settings, test, deploy, inspect runs and logs, replay, cancel, delete. No SDK equivalent.blocksClient.logic.functions.* — calling a deployed function from app code: call(), invoke(), invokeRaw() (streaming), waitForResult(), url().For CLI work, use blocks-bootstrap first when account or project context is unknown.
Local snapshot: blocks/logic/functions.json lists the project's functions (summaries — no source), written by blocks pull --only logic. Read it before listing; check _meta.tenantId / _meta.pulledAt. The code itself comes from blocks logic function export.
create ──► save (working copy) ──► test (runs saved code, no deploy) ──► deploy (new live version)
▲ │
└──────────── edit again: status shows isDirty ◄─────────────┘
deploy succeeds. isDirty: true means saved code differs from the live version.--auth, --http-methods or --response-mode takes effect on the next deploy, not on save.The full author → test → deploy loop with a local directory is in flows/author-test-deploy.md. The handler contract (input, ctx, HTTP answers, streaming, warm sandboxes) is in references/handler.md.
| Command | Use |
|---|---|
blocks logic function list [--search <s>] [--status draft|live|paused] [--sort name|updated] | Find functions; isDirty, activeVersionNumber, runs24h. |
blocks logic function create --name <n> [--template minimal|httpecho|fetchtransform|reusedconnection] | New Draft seeded from a starter. Prints the id every other command takes. |
blocks logic function export <id> --dir <path> [--force] | Write index.js, package.json, package-lock.json (if any) and function.json locally. |
blocks logic function save <id> --dir <path> | Upload the directory as the working copy (read-merge-write — anything not supplied keeps its stored value). |
blocks logic function save <id> --http-methods GET,POST --auth token --response-mode sync --var KEY=VALUE | Change settings without touching source. |
blocks logic function test <id> [--input '<json>'] | Run the saved code once. Real side effects; recorded as a Test run. |
blocks logic function deploy <id> [--note <text>] | Ship the saved code as a new version; waits for the image build. |
blocks logic function url <id> [--path <sub>] | Public URL, xBlocksKey, methods, auth mode, response mode, deployed or not. |
blocks logic function runs [<id>] [--status failed] [--invoked-by http] → run <runId> → logs <runId> | Debug: what ran, with which input, what it returned, what it logged. |
blocks logic function replay <runId> / cancel <runId> | Re-run a past input on the live version / stop a queued or running run. |
blocks logic function versions <id> / source <id> <versionId> / build <buildId> | Deployed history, a version's code, one image build's log. |
blocks logic function audit <id> / limits / delete <id> [--force] | Who changed what; the fixed profile; delete (refused while workflows use it unless --force). |
Every write (create, update, save, deploy, replay, cancel, delete) takes --dry-run first, then --yes after approval. test runs code but changes no configuration.
save understands--http-methods GET,POST,PUT,PATCH,DELETE — verbs the URL answers; others get 405. --http-enabled=false turns the URL off (workflow steps still work); --workflow-enabled=false hides it from workflow steps.--auth token (default) — callers need a Blocks bearer token for this project; narrow with --roles a,b / --permissions a,b. --auth public — anyone with the URL and the project's x-blocks-key. Where the platform enforces rate limits, a Public function gets 600 calls/min by default; set your own with --requests-per-minute <n> (1–100000, or default).--response-mode async (default) — callers get 202 + runId + pollToken and collect the result. sync — the request is held (up to ~30 s) and the handler's return value is the HTTP response.--var KEY=VALUE (repeatable) / --unset-var A,B — non-secret variables, read as ctx.env.KEY. A credential-looking name (API_KEY, TOKEN, PASSWORD, Authorization…) must hold a secret reference, --var API_KEY={{secret.<secretId>}}; a typed value is refused (FUNCTION_FORBIDDEN_CONTENT). Create the secret with blocks-secrets first and use its id. The function receives the real value, masked in logs.--allow-install-scripts — let npm lifecycle scripts run at build (native packages like bcrypt, sharp).function.json (from export) carries the same settings as JSON — trigger, variables, outputActions, limits.requestsPerMinute — and save --dir applies it.blocks logic function limits reports them: 100 millicores, 128 MB, 30 s per run, 10 concurrent runs per function (more queue, none refused), 2 attempts (one retry after 5 s), 1 MB input, 5 MB result. A job longer than 30 s is not a function — fan it out into several calls or use blocks-workflow.
import { BlocksApiError, BlocksFunctionRunError } from "@seliseblocks/client";
import { blocksClient } from "../../lib/blocks/client";
// The value, whether the function is deployed sync or async:
const quote = await blocksClient.logic.functions.call<{ total: number }>("<functionId>", {
method: "POST",
path: "quotes", // handler sees input.path === "quotes"
body: { items: [{ sku: "A1", qty: 2 }] }
});
call(id, options) — invokes; a sync answer's body is returned, an async run is polled until it finishes and its result parsed. A returned { statusCode, headers, body } is unwrapped to body. Throws BlocksApiError for platform refusals and 4xx/5xx answers, BlocksFunctionRunError (status, errorCode, errorMessage) for a run that failed or timed out.invoke(id, options) — the transport-level result: { kind: "answered", status, headers, body, runId? } or { kind: "accepted", runId, runStatus, pollToken }. Then waitForResult(accepted, { intervalMs, timeoutMs }) or getResult(runId, pollToken) to collect it.invokeRaw(id, options) — the unread Response, for a streaming handler (async function*); send headers: { Accept: "text/event-stream" } for SSE.url(id, path?) — the absolute public URL to hand to a webhook provider or another backend.method (default POST), path, query (arrays repeat the key), body, headers, auth (default true — set false for a Public function called without a session), respondAsync, waitSeconds, signal.The SDK sends the signed-in user's token; for a Token function that user needs whatever --roles/--permissions the trigger demands, or the call is 403 FUNCTION_INVOKE_FORBIDDEN. Inside the function, await ctx.blocks.getAccessToken() returns that same caller's token for calling other Blocks APIs.
Callers outside the app (a payment provider's webhook, a cron elsewhere): give them the URL from blocks logic function url <id>, the project's tenant id as the x-blocks-key header, and — unless the trigger is Public — a Blocks bearer token. A webhook provider that cannot send a token needs --auth public; verify its signature inside the handler from input.rawBody and input.headers.
A workflow function action step runs a deployed function synchronously and passes its return value to the next step — see blocks-workflow for the node shape. The trigger must keep workflowEnabled on. Deleting a function that workflow steps point at is refused (FUNCTION_DELETE_BLOCKED) unless --force, after which those steps fail.
| Code | Meaning / next step |
|---|---|
FUNCTION_NOT_FOUND | Wrong id or another project — blocks logic function list. |
FUNCTION_VALIDATION | Bad save: package.json must declare "type": "module", names 2–64 chars, variable keys must be identifiers. |
FUNCTION_FORBIDDEN_CONTENT | A credential-looking variable/header holds a typed value (use {{secret.<id>}}), or test input carries a credential-looking key. |
FUNCTION_BUILD_FAILED | npm install or image build failed — blocks logic function build <buildId> shows the log. |
FUNCTION_BUILD_PENDING | deploy timed out waiting; nothing deployed — rerun with --build-id. |
FUNCTION_DELETE_BLOCKED | Active runs or workflow steps use it — --force only after confirming. |
FUNCTION_RATE_LIMITED / FUNCTION_UNAVAILABLE | Wait and retry; nothing ran. |
SDK FUNCTION_INVOKE_NOT_FOUND | Not deployed, or the id is wrong. |
SDK FUNCTION_INVOKE_METHOD_NOT_ALLOWED | Verb not in --http-methods (the Allow header lists the accepted ones). |
test exercises the saved code; the URL serves the deployed version.ctx exists only inside the handler. Touching it at module top level fails the run before the handler is called.{{secret.<id>}} variable; the platform refuses typed credentials.blocks logic function * in a terminal.blocksClient.logic.functions.call(...).blocks logic function runs <id> --status failed --json, then run <runId> and logs <runId>.save <id> --auth public --http-methods POST, deploy, blocks logic function url <id>; verify the signature from input.rawBody.save <id> --var OPENAI_API_KEY={{secret.<secretId>}}, deploy.versions <id>, source <id> <versionId>, write those files to a directory, save --dir, deploy.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub selisedigitalplatforms/blocks-skills --plugin selise-blocks25 skills in this plugin
/blocksStart here for any SELISE Blocks work. Routes a plain-language request — sign-in and projects, SSO, users, roles, MFA, data schemas and records, file storage, translations, mail, notifications, workflows, functions, proxies, secrets, deployments — to the right Blocks skill, and carries the rules every Blocks skill follows: the blocks CLI and @seliseblocks/client SDK only, never raw HTTP to the platform API; --dry-run before --yes; never read the CLI's credential files; when to report a finding. Use whenever work touches SELISE Blocks, the blocks CLI, or @seliseblocks/client./blocks-bootstrapGet a user from any starting state to a working SELISE Blocks setup — CLI installed, logged in, project selected — using the `blocks` CLI, never raw fetch/curl. Detects state from `blocks auth status --json` and `blocks doctor --json`, then routes to a flow: select or create a project, inventory a project that already exists, resolve the app's OIDC client, add a social identity provider, create the first end user, scaffold a new web app, or wire an existing one. Use for a new user, for `not_logged_in`/`project_not_selected`, or whenever login/project/app state is unclear./blocks-captchaConfigure the login captcha of a SELISE Blocks project through the blocks CLI ('captcha list/get/save/enable/disable/delete'): register a reCAPTCHA or hCaptcha site key and secret, switch it on or off, see which configuration blocks-iam actually enforces at login, and retire one. CLI-only, project-scoped; the captcha secret is stored server-side and never shown. Use for 'enable captcha on login', 'change the recaptcha keys', 'why is captcha not showing', 'turn captcha off'.Other plugins' skills for the same job