k2b-dev

assistant-code-mode

Inspect and transform unfamiliar data, analyze files, compare results across Cloud apps, or build and improve interactive and agent-only Apps in Assistant Studio. Use for quick code experiments, data analysis, file generation, resource SQL queries and combining discovered Cloud capabilities. For plain arithmetic or date offsets, answer directly or use calculate.

k2b-dev 0 1 Updated 3w ago

Resources

1
GitHub

Install

npx skillscat add k2b-dev/cloud/assistant-code-mode

Install via the SkillsCat registry.

SKILL.md

Assistant code mode

Choose the smallest useful result: one-off answer, exported file, or reusable
Studio App. Apps may expose agent actions, a display-only dashboard, or both.
Persistence is optional. One-off scripts stay in their chat and cannot be shared. Reuse an
existing Cloud feature when it fits. For a
quick reading of an uploaded PDF or Office document, read_file can return
Markdown; use code for exact cells, calculations, original PDF text or positions.

Start from the contract

Load the needed code_* tools individually through load_tools and read their
input schemas. They are Assistant tools, not capabilities or functions inside
code. Discover other Cloud operations before using capabilities.run.

Runtime namespaces are globals: no imports or package installation are needed.
Only relative imports of the resource's own source files are supported. There is
no DOM or native network access. Before using a namespace, read its reference
below for signatures, options and return values. Do not invent methods or infer
an API from a familiar library. For discovered Cloud capabilities and external
APIs, obtain their actual contracts separately.

Inspect supplied data before joining, filtering or calculating: column names,
types, units, date ranges and missing values. Ask only for decisions or inputs
that cannot be established from available evidence. For several real steps,
keep a short todo_write plan and update it as work changes; skip ceremony for a
small experiment. A failed experiment should change the next hypothesis.

First file script

Pass exact current-chat manifest paths as code_run.inputPaths, and this entry
as code_run.code for a small CSV:

export default async () => {
  const [input] = await files.list();
  if (!input) throw new Error("Select a CSV input.");
  const rows = await sheet.fromCsv(await files.read(input.name));
  return { rows: rows.length, columns: Object.keys(rows[0] ?? {}), sample: rows.slice(0, 3) };
};

input.name is the full path, such as /sales.csv; pass it unchanged to
files.read, which returns a File. CSV rows are objects keyed by headers:
rows[0] is already data. Do not drop it. For older Excel CSVs, use
sheet.fromCsv(file, {encoding:"windows-1252"}). Inspect actual headings first.
For a tiny experiment without files, export default () => ({answer:42}) suffices.
Each run has fresh variables. No saved resource or UI is required.

Reference routing

Read only the rows relevant to the task. Each link describes its own complete
supported surface; links within references add related workflows when needed.

Task / API Read
Source entry, input/output files, pickers, CSV, IDs Runtime and files
Inspect PDF pages, read PDF text/positions or XLSX/ODS cells, write ODS Documents
Generate a PDF, save one in Files, embed attachments, combine invoice HTML and XML PDF generation
Exact amounts, taxes, allocation, localized money Money
Export DATEV bookings or SEPA transfers DATEV and SEPA
Parse a CAMT bank report Bank reports
Calculate, create or read electronic invoices/XML/PDF attachments Electronic invoices
Controls, layouts and dialogs UI and dialogs, Analytics UI
Chart types, series and axes Charts
Long processing, progress, cancellation Background work
Persist JSON or files locally/shared Storage
Copy files between stores; list and download Filesv2 beside Grids documents File transfers
Resource SQL, schema, row CRUD, imports Database
Generate text, classify data or extract structured fields AI calculations
Discovered Cloud queries/actions Capability calls
External HTTPS and personal secrets HTTP and secrets
Call a published App action; declare handlers App actions
Reuse work across chats, create or edit an App Source workflow
Publish, restore, copy Publishing
Find recipients or change App/Skill sharing Access
Inspect, export, clear server data, or delete an App Management
Execute, inspect, interact, export, stop, diagnose errors Run and debug
Unfamiliar inputs or cross-app investigation Investigation
Complete app starters Examples

For a new app, read Source workflow and the closest complete example before
writing source, plus only the API references it uses. For analytical reports or
dashboards, also load assistant-data-analysis for metrics and source validation.

Choose the delivery

For a one-off chart, calculator, or interactive analysis in this conversation,
use code_run({code,inputPaths}), test the controls, then
code_present({runId,title}). Read Chat visualizations.
A successful run is visible to the agent only; present it before saying the
user can see it. No saved App or chat file is necessary.

Use a Studio App when the user needs an independently accessible, reusable
application. Use files.save, code_export, and present when the requested
result is a file. These are separate delivery choices.

Verify and deliver

Run the actual source (the saved revision for Apps) and test relevant controls with IDs returned by
code_run/code_interact, including invalid inputs and picker fixtures. Creating,
compiling or saving source does not verify behavior. If work.status is
running, wait with code_inspect({runId,waitMs:30000}); do not restart the job.
Inspect only when the returned snapshot needs more detail. Errors and
outputTruncated are not successful complete results.

For a CSV, call await files.save(sheet.toCsv(rows), "result.csv") inside code;
for a spreadsheet, await files.save(await sheet.toOds(sheets), "result.ods").
Then call the tool code_export with the returned runId and captured file
name, and present its returned chat path. files.save returns no path.
Reuse exported data via its path/version rather than retyping truncated output.
Reconcile row counts, exclusions and totals before reporting findings.

Open GUI apps with code_open. Saving or testing does
not replace a user's already-running app. Stop runs no longer needed that retain
UI, jobs or output files. Never claim an unexecuted result is verified.

Agent execution runs independently of the user's tab. Agent local storage is
temporary; shared storage, database writes and external actions are real, even
in tests. Cancellation and source restore do not undo them. Apps select local
files explicitly; they never gain implicit access to chat attachments. Use
code_secret for credentials, never chat or app controls. Honor normal access
and approval decisions; availability is not authorization for unrelated actions.