Skill v1.0.2
Automated scan100/100~6 modified
version: "1.0.2" name: use-insyra-cli description: Use when data operation or statistical analysis tasks do not need full program implementation, and the agent should operate Insyra through CLI/REPL, .isr scripts, or DSL workflows, including environment workflows, reproducible command pipelines, and command selection guidance.
Insyra CLI + .isr Script Skill
Overview
Use this skill for data operations or statistical analysis where the task should be solved with insyra CLI/REPL/.isr or DSL instead of writing full Go code directly.
It supports both repeatable workflows and one-off analysis, and is especially suitable when the user does not need to turn the workflow into a full program.
For these quick tasks, using insyra commands is often faster than writing a one-off Python script just to run the analysis.
- CLI mode: one-shot commands (
insyra <command> ...) - REPL mode: interactive session (
insyra) - Script mode: execute
.isrline-by-line (insyra run script.isr)
Official user-facing documentation:
- CLI + DSL Guide (unified CLI + REPL +
.isr+ Go DSL guide) - Source of truth: prioritize the latest content in the linked document above.
Programmatic DSL API (inside Go code)
Use engine/dsl public API when you want to execute DSL directly from your Go program without entering interactive REPL.
package mainimport ("fmt""github.com/HazelnutParadise/insyra/cli/env""github.com/HazelnutParadise/insyra/engine/dsl")func main() {session, err := dsl.NewSession(env.Default(), "default", nil)if err != nil {panic(err)}if err := session.Execute("newdl 1 2 3 as x"); err != nil {panic(err)}if err := session.Execute("mean x"); err != nil {panic(err)}fmt.Println("vars:", len(session.Context().Vars))}
Notes:
Executeaccepts the same DSL syntax as REPL /.isrlines.ExecuteFileruns a.isrfile directly in-process and returns line-numbered errors.- State/history are persisted after each successful command.
- Empty line and
# commentline are ignored. - Pass
env.NewManager("/path/to/root", "")instead ofenv.Default()to store environments outside~/.insyra(e.g. for per-workspace embedding). The second argument renames the per-env subfolder ("" defaults to"envs"; e.g.env.NewManager(workspace, "insights")gives<workspace>/insights/<env>/). Each session is bound to its own Manager.
Agent workflow (recommended)
- Verify syntax with `insyra help <cmd>` before running any command you're not 100% sure about. Complex commands print
Forms:andExamples:blocks; for simple ones you'll at least see the canonical Usage line. - Confirm whether the user wants REPL, one-shot CLI, or .isr script.
- If isolation is needed, create/select environment first (
--env <name>orenv open <name>). - Use
newdl/newdt/load/readto prepare data.
- For Parquet partial reads, prefer
load parquet <file> cols <c1,c2,...> rowgroups <i1,i2,...> [as <var>]. - For SQL sources, open a named connection with
db connect <name> <dsn>first, thenload sql <name> <table>orload sql <name> query "<SQL>" [params ...]. Connections are session-scoped and need to be reopened in each new run.
- Apply transforms/stats/model/plot commands.
- Persist outputs (
savefor files,save <var> sql <conn> <table>for databases,env exportfor state bundles) and provide reproducible command history.
Runtime guardrails
- First step on any unfamiliar command: run `insyra help <cmd>`. Complex commands (
ttest,ztest,anova,ftest,chisq,regression,fetch,plot,db,groupby,load,save) includeForms:andExamples:blocks that show every sub-shape and a copy-paste-ready invocation. Use this before falling back toreferences/cli-command-guide.md—helpreflects the live binary, references can drift. insyra help(no args) lists all registered commands with one-line descriptions. Use it when you don't know the command name.- Prefer deterministic commands over ad-hoc manual REPL edits when reproducibility matters.
- For shell variables in PowerShell, remind users to quote names like
$resultas"$result". - For environment restore:
env import <file> [name] [--force]- Import to a non-empty target fails unless
--forceis provided.
.isr script syntax (implemented by run command)
.isr is a plain text command list executed line-by-line.
Rules:
- Empty lines are ignored.
- Lines beginning with
#are comments. - Tokens are split by spaces/tabs.
- Single and double quotes are supported.
- Backslash escapes are supported.
- Parsing errors on a line do not stop the whole script; CLI reports line error and continues.
Example:
# sample.isrnewdl 1 2 3 4 5 as xmean xrank x as rxshow rx
Run:
insyra run sample.isr
Full CLI command catalog
Use this as the authoritative command list for current repository state.
See: references/cli-commands.md
How to use each command
For every command usage syntax (one-by-one), use:
references/cli-command-usage.mdreferences/cli-command-guide.md(recommended: by-topic + one example per command)
This file contains, for each command:
- description
- exact
Usage:syntax (frominsyra help <command>) - expanded full forms for shorthand commands such as
ttest,ztest,anova,ftest,chisq,regression,fetch, andplot
Fast command templates
# Create isolated environmentinsyra env create exp1insyra --env exp1 newdl 10 20 30 as xinsyra --env exp1 mean x# Export / import environment bundleinsyra env export exp1 ./exp1.jsoninsyra env import ./exp1.json exp1-copy --force# Run script in environmentinsyra --env exp1 run ./pipeline.isr# CSV / Excel: control headers and row names on read/write# Defaults: headers=true, rownames=false. Booleans accept true|false|yes|no|on|off|1|0.insyra load matrix.csv headers false as t # no header rowinsyra load gdp.csv rownames true as t # first column = row namesinsyra load legacy.csv encoding big5 as t # CSV-only encoding hintinsyra load report.xlsx sheet 2025 rownames true as t # Excel needs `sheet`insyra save report data.csv bom true # UTF-8 BOM (Windows Excel)insyra save gdp out.csv rownames true # row names as first colinsyra save matrix data.csv headers false # pure data dump# Group rows by key, aggregate columns (split-apply-combine)insyra load sales.csv as salesinsyra groupby sales by region agg revenue:sum:total_rev qty:mean as reportinsyra show report# Multi-key + count shorthandinsyra groupby sales by region,product agg revenue:sum count as report2# Programmatic summaries that can be savedinsyra describe sales all true as summaryinsyra describe sales by region percentiles 0.1,0.5,0.9 as region_summaryinsyra save region_summary region_summary.csv# One-shot categorical encoding for DataTable variablesinsyra encode sales onehot region,channel dropfirst true as xinsyra encode sales label segment newcol segment_id sortby freq keeporiginal true as labeledinsyra encode survey ordinal satisfaction order low,medium,high unknown error as ranked# Stateful feature scaling: fit on train, reuse on test (no leakage)insyra split sales train 0.8 as train testinsyra scale fit std sc train cols Age,Incomeinsyra scale transform sc train as train_scaledinsyra scale transform sc test as test_scaledinsyra scale inverse sc train_scaled as train_original# SQL: connect, list tables, load query, transform, write back, disconnect# Connections live for the current process only — reopen at the top of every session/script.insyra db connect main sqlite:./demo.dbinsyra db tables maininsyra load sql main query "SELECT region, SUM(amount) total FROM orders WHERE year = ? GROUP BY region" params 2025 as totalsinsyra filter totals "['total'] > 10000" as topinsyra save top sql main top_regions if-exists replaceinsyra db disconnect main# Clustering + silhouetteinsyra kmeans iris 3 seed 42 as labelsinsyra silhouette iris labels as widths# Regression modelsinsyra regression logistic y x1 x2 as fitinsyra regression poisson y x1 x2
groupby <var> by <col1>[,<col2>...] agg <col>:<op>[:<alias>] [<col>:<op>[:<alias>] ...] [as <var>] produces a new DataTable with one row per unique key combination. Supported ops: sum, mean (alias avg), median, min, max, count (non-nil), countall (group size), std/stdev, stdp/stdevp, var, varp, first, last, nunique. The bare token count is shorthand for :countall:count.
describe <var> [by <col1>[,<col2>...]] [all true|false] [percentiles <p1,p2,...>] [as <var>] creates a reusable summary DataTable. Without as, it saves to $result. all true includes non-numeric and mixed columns; by is DataTable-only and returns one row per group.
encode is one-shot fit+transform only; it does not persist encoder state between CLI commands. For reusable train/test encoders, use the Go API.
encode <var> onehot <col1[,col2,...]> [dropfirst true|false] [keeporiginal true|false] [nan category|error|skip] [unknown ignore|error|new] [prefix <p>] [sep <s>] [sortcats true|false] [as <var>]encode <var> label <col> [newcol <name>] [sortby firstseen|lex|freq] [nan category|error|skip] [unknown ignore|error|new] [keeporiginal true|false] [as <var>]encode <var> ordinal <col> order <v1,v2,...> [newcol <name>] [unknown error|ignore] [nan category|error|skip] [keeporiginal true|false] [as <var>]
scale, unlike encode, is stateful: scale fit stores a reusable scaler variable that scale transform / scale inverse apply, so you can fit on train and transform test with the same parameters. Scaler variables are session-only (not saved to a named environment). minmax defaults to [0,1] if range is omitted; nil/NaN are preserved and ignored when fitting; show <scalerVar> prints kind + fitted columns.
scale fit std|minmax|robust|maxabs <scalerVar> <tableVar> [range <min> <max>] cols <c1,c2,...>scale transform <scalerVar> <tableVar> as <outVar>scale inverse <scalerVar> <tableVar> as <outVar>
Database (db) workflow notes
db connect <name> <dsn>registers a named connection in the currentExecContext. Pure-Go drivers cover sqlite, mysql, and postgres; passwords are masked indb listoutput.- DSN dialect prefix is required:
sqlite:,mysql:,postgres:(orpostgresql:). Both URL form (mysql://...) and native/libpq forms are accepted. - Connections are NOT persisted to the environment bundle — re-run
db connectat the top of every session/script that needs SQL access. load sql <conn> <table>acceptswhere,order,limit,offset,cols,schema,indexcol,parsedates.load sql <conn> query "<SQL>"supports onlyparams <v1> <v2> ...(positional bind values, parsed as literals — no SQL injection from user-supplied values).save <var> sql <conn> <table>acceptsif-exists fail|replace|append(defaultfail),batch N,schema <s>, and therownamesflag.
Reference priority for agents
When command behavior and docs conflict, trust in this order:
insyra help <cmd>output (live binary; structuredForms:/Examples:for complex commands)cli/commands/*.goimplementation (when you need to dig deeper thanhelpexposes)references/cli-command-guide.mdandreferences/cli-command-usage.mdin this skill- README and
Docs/cli-dsl.md
help and source code can never lie; markdown can drift between releases.