本文へ移動
cccskills
無料GitHub で公開

datagrok-exec

Use whenever you need the Datagrok browser to actually execute JavaScript — adding viewers, filtering, modifying the view, or returning a result widget to the chat. Open this skill before calling the datagrok_exec tool.

インストール方法を見る

含まれるファイル(1)

  • SKILL.md10.7 KB

SKILL.md(原文)

インストールする前に、エージェントに与えられる指示の中身を確認できます。

datagrok-exec

The ONLY way code runs in the Datagrok browser is via the datagrok_exec tool. Regular markdown code blocks do NOT execute.

Call datagrok_exec to perform an action the user asked for (add a viewer, filter, open a file, run a function). For informational questions — "how do I…", "what is…", "explain…", "can you…" — do not call datagrok_exec; find the page via workspace/help/INDEX.md, read it, use it to find needed material, then answer in plain text.

Globals available inside the code

VariableTypeAvailable
grokmoduleAlways
uimoduleAlways
DGmoduleAlways
viewDG.ViewBaseAlways — check view.type for specific view type
tDG.DataFrameOnly when view.type === 'TableView'

The code runs in an async IIFE, so await works directly.

Tool result

The tool returns {success, returnValue?, verified?, error?}.

success only means the JS did not throw — NOT that the intended effect happened. A typo'd viewer name, a no-op, or an action that ran twice all return success: true. returnValue is whatever object your own code chose to return; it populates the chat confirmation shown to the user, but it is not proof — it is self-reported by the same code that took the action. Make your code return a plain confirmation object so the user sees accurate details:

ActionReturn
open / load table{name, rowCount}
add viewer{type}
filter{filteredRowCount, totalRowCount}
upload DataFrame{tableInfoId}
save layout{layoutId}
open app / view{viewName, viewType}
color / sort / pin{column}

Error: {success: false, error: "..."} — report verbatim, do not silently retry.

Never pre-announce success before calling the tool.

Verifying actions — required with every action

Proof does not come from your own action code — it comes from re-reading live state in a fresh scope. For any state-changing datagrok_exec, pass the verify parameter with the call: {assertion, description}. The browser runs your action code, then immediately runs the assertion in a fresh scope (globals grok, ui, DG, view, t) that cannot see your action's variables, and returns its result as verified: {passed, observed?} — one round-trip, no separate verify call needed.

The assertion is yours to design for whatever you changed: re-read that thing and return the observed result (truthy = verified). verified.passed: true → report the observed value, not the value you intended. verified.passed: false (or missing) → the action is NOT confirmed — but do not assume it failed: a faulty assertion (wrong property, wrong count, missing return) reads exactly the same. Never re-run state-changing action code on a failed verify. First re-read the affected state with a read-only check (a corrected datagrok_verify assertion); only if that shows the change is genuinely absent, fix and re-run the action — re-running one that already worked creates duplicate viewers/columns/rows. The standalone datagrok_verify tool exists for that fix-loop and for MCP calls that changed platform state (it takes the same {assertion, description}). The runtime blocks the turn from ending until a verification passes (bounded retries — if they run out, the response is shown to the user flagged as unverified, so never present unverified work as done).

Returning a result to the chat

Only return an HTMLElement when the explicit user goal is to see output in the chat ("show me the molecule", "display the table", "draw a plot"). Never return HTMLElements for intermediate results, confirmation data, or actions where the platform UI is the destination. An HTMLElement return replaces the confirmation object — no returnValue is sent.

Raw scalars, strings, or DG.DataFrame will NOT render; convert via the table below:

Result typeHow to render
scalarui.divText(String(value))
key-value pairsui.tableFromMap({key: value})
list of itemsui.divV(items.map((x) => ui.divText(x)))
DG.DataFrameDG.Viewer.grid(df).root
DG.Viewer / DG.Widgetobj.root
DG.ViewBase (incl. apps)open via grok.shell.addView(v) — do NOT return
molecule (SMILES / molblock)grok.chem.drawMolecule(smiles, 300, 200)
macromolecule (HELM)see HELM output below
graphicssee Graphics output below

Native top-menu commands

If an operation already exists as a top-menu command (aggregate, join, cluster, add column, …), invoke it instead of building a custom ui.dialog. Walk the menu with find() (chain through | groups), matching leaf text exactly:

grok.shell.topMenu.find('Data').find('Aggregate Rows...').click();
grok.shell.topMenu.find('Edit').find('Go To').find('Row...').click();
MenuCommands
EditUndo, Redo, Add New Column..., Add Rows..., Column Properties..., Find and Replace..., Go To | Row..., Go To | Next Selected, Go To | Prev Selected, Remove | Selected Rows, Remove | Selected Columns, Remove | Selected Rows or Columns
ViewColumns, Console, Context Panel, Schema, Tables, Variables, Toolbox, Windows, Home, Reset Filter, Edit Tooltip..., Embed..., Full Screen, Presentation Mode, Layout | Save to Gallery, Layout | Open Gallery, Layout | Clone View, Layout | Download, Layout | Clear
SelectAll, None, Invert, All Columns, Duplicates..., Missing Values..., Random Rows..., Extract Selected Rows, Filter to Column..., Selection to Column..., Selection to Filter
DataAggregate Rows... (also pivot), Join Tables..., Link Tables..., Compare Tables..., Compare Columns..., Append Tables..., Unpivot..., Split Column..., Split Column by RegExp..., Categorize..., Anonymize..., Batch Edit...
MLAnalyze | PCA..., Analyze | PLS..., Analyze | ANOVA..., Analyze | Multivariate Analysis..., Cluster | DBSCAN..., Cluster | MCL..., Models | Train Model..., Models | Apply Model..., Notebooks | New Notebook..., Reduce Dimensionality..., Impute Missing Values..., Pareto Front...

Per-area skills

For task-specific API surface, open the matching skill before writing code:

User intentSkill
Find / describe / add / remove / rename columns; set semType/units/format/friendly name; color codingdatagrok-df-and-columns
Calculated (formula-driven) columnsdatagrok-calc-column
Filter rows (range, categorical, contains, substructure, predicate)datagrok-filtering
Select rows; current row; selection ↔ filterdatagrok-selection
Add / configure / find / close viewersdatagrok-viewers
Grid sort, visibility, widths, pins, freeze; grid-only cell tintdatagrok-grid-customization
Cheminformatics: SMILES/MolBlock/InChI/canonicalizedatagrok-chem-data / datagrok-chem-toolkit

Multiple tool calls in one response

Each datagrok_exec call runs in its own scope (a fresh new Function(...) IIFE). Calls execute sequentially, but JS variables declared in one call are NOT visible in the next.

Persists across calls:

  • The view reference and the t DataFrame reference (column additions, filter changes, and other mutations are visible to later calls)
  • Anything pushed into the platform: viewers added, dialogs opened, columns appended, server-side state

Does NOT persist: const/let/var bindings, helper functions, cached values. A second call must re-derive from t.

Before consuming a query/function result, check the wrapper's return type in the apiRef:

// CORRECT — wrapper returns Promise<string>
const helm = await grok.data.query('Biologics:GetBiologicsPeptideHelmByIdentifier',
  { peptideIdentifier: 'GROKPEP-000002' });

// WRONG — assuming a DataFrame because most queries return one
const df = await grok.data.query('Biologics:GetBiologicsPeptideHelmByIdentifier', {...});
const helm = df.columns.byIndex(0).get(0);

Launching apps & views

Datagrok apps are functions with meta.role: app. Calling one via grok.functions.call('Pkg:appName') may return a DG.ViewBase (or nothing if the app opens its own view). A returned view is NOT yet attached to the workspace — hand it to grok.shell.addView(). Do NOT return the view from the code; open it.

const result = await grok.functions.call('Pkg:appName');
if (result instanceof DG.ViewBase)
  grok.shell.addView(result);

HELM output

const helmInput = await ui.input.helmAsync('', { editable: false });
helmInput.stringValue = helmString;
return helmInput.root;

Graphics output

Returned graphics elements may render blank without intrinsic dimensions. Extract Base64-encoded image data and wrap with explicit width and height:

const b64 = await grok.functions.call('Chem:ChemistryGasteigerPartialCharges', {mol: 'CCC', contours: 10});
return ui.image('data:image/png;base64,' + b64, 300, 200);

レビュー

まだレビューはありません。使ってみた感想をお寄せください。

同じリポジトリのスキル

概要と使いどころ

Add support for a new curve data format in the Curves package converter system

日本語の概要は準備中です。原文の説明を表示しています。

datagrok-ai/public742026年10月13日 更新

Create info panels that appear in the context panel based on semantic types

日本語の概要は準備中です。原文の説明を表示しています。

datagrok-ai/public742026年10月13日 更新

Add a new single-objective optimization algorithm to the sci-comp library. Use when the user asks to implement a new optimizer (e.g. gradient descent, BFGS, simulated annealing, differential evolution).

日本語の概要は準備中です。原文の説明を表示しています。

datagrok-ai/public742026年10月13日 更新

Add unit tests to a Datagrok package

日本語の概要は準備中です。原文の説明を表示しています。

datagrok-ai/public742026年10月13日 更新

Answer a "how do I …" question about the platform with a Gherkin scenario on @datagrok-libraries/bdd that is filmed into a how-to video (grok-bdd guide), so the answer is demonstrated, sent as a video plus numbered steps, and kept as a regression test

日本語の概要は準備中です。原文の説明を表示しています。

datagrok-ai/public742026年10月13日 更新

Translate hand-written Playwright specs (or any existing UI tests) into Gherkin features on @datagrok-libraries/bdd, then prove the features test what they claim by backward-matching them against the originals with independent reviewers, and fix the gaps in the core, the library and the features

日本語の概要は準備中です。原文の説明を表示しています。

datagrok-ai/public742026年10月13日 更新

datagrok-ai のスキルをすべて見る

このスキルの問題を報告する