Use when constructing tensors, slicing them, or building transform pipelines using the SKaiNET public DSL — applies in both consumer apps and inside the SKaiNET repo. Trigger tokens include `tensor(`, `tensor {`, `data<`, `pipeline<`, `sliceView`, `segment {`, `rescale`, `normalize`, `unsqueeze` (in pipeline context), `FP32::class`, `FP16::class`, `Int8::class`, `Int32::class`, `Ternary::class`, `randn(`, `uniform(`. Do NOT fire on tensor *assertions* (in-repo tests go to the contributor `skainet-testing` skill) or on neural-network builders (`sequential` / `dag` go to `skainet-nn-dsl`).
How this skill is triggered — by the user, by Claude, or both
Slash command
/skainet-consumer-skills:skainet-data-dslThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Building blocks for tensor data: creation, initialisation, slicing, and transform pipelines for preprocessing. This skill is a cheatsheet — DSL skills teach usage rather than enforce constraints.
Building blocks for tensor data: creation, initialisation, slicing, and transform pipelines for preprocessing. This skill is a cheatsheet — DSL skills teach usage rather than enforce constraints.
FP32, FP16, Int8, Int32, Int4, Ternary).skainet-testing.sequential { } / dag { } — skainet-nn-dsl.skainet-java-interop.kmp.// (a) Direct entry — tensor(executionContext, dtypeKClass) { ... }
val t = tensor<FP32, Float>(ctx, FP32::class) {
tensor {
shape(2, 3) {
from(0f, 1f, 2f, 10f, 11f, 12f)
}
}
}
// from: SKaiNET/skainet-lang/skainet-lang-core/src/commonMain/kotlin/sk/ainet/lang/tensor/dsl/TensorDSL.kt:17-25
// (b) Phase-aware entry — data<T, V>(ctx) { tensor { ... } }
val t = data<FP32, Float>(ctx) {
tensor {
shape(2, 3) {
from(0f, 1f, 2f, 10f, 11f, 12f)
}
}
}
// from: SKaiNET/skainet-lang/skainet-lang-core/src/commonTest/kotlin/sk/ainet/readme/ReadmeSnippetsTest.kt:18-32
Use form (b) when you're already inside a phase-aware execution context (training vs eval) and want phase-tagged tensors. Use form (a) for plain inference / tests / examples.
shape(...) { ... }shape(28, 28) { zeros() } // FloatArray of zeros
shape(28, 28) { ones() }
shape(28, 28) { full(0.5f) } // every element = 0.5
shape(2, 3) { from(1f, 2f, 3f, 4f, 5f, 6f) } // explicit values, length must equal shape volume
shape(2, 3) { fromArray(myFloatArray) }
shape(28, 28) { randn(mean = 0f, std = 0.02f) }
shape(28, 28) { uniform(min = -1f, max = 1f) }
shape(28, 28) { init { idx -> (idx[0] + idx[1]).toFloat() } }
shape(28, 28) { randomInit({ rng -> rng.nextFloat() }) }
// from: SKaiNET/skainet-lang/skainet-lang-core/src/commonMain/kotlin/sk/ainet/lang/tensor/dsl/TensorDSL.kt:50-108
sliceView { segment { ... } }val view = bigTensor.sliceView {
segment { range(0, 10) } // dim 0: indices 0..9 (exclusive end)
segment { at(5) } // dim 1: pick exactly index 5
segment { all() } // dim 2: keep everything
segment { step(0, 20, 2) } // dim 3: every 2nd index from 0 to 20
}
// from: SKaiNET/skainet-lang/skainet-lang-core/src/commonMain/kotlin/sk/ainet/lang/tensor/TensorSliceBuilder.kt:18-26
The number of segment { } blocks MUST equal the rank of the tensor — validate(tensorShape) throws otherwise.
val preprocess = pipeline<Tensor<FP32, Float>>()
.rescale(ctx, scale = 255f)
.normalize(ctx, mean = imagenetMean, std = imagenetStd, channelAxis = -1)
.unsqueeze(0) // add batch dim at position 0
val batch = preprocess(rawImageTensor)
// from: SKaiNET/skainet-data/skainet-data-transform/src/commonMain/kotlin/sk/ainet/data/transform/TensorTransformDsl.kt:18-50
Available transform extensions: rescale, normalize, scaleAndShift, clamp, reshape (more to follow — file is the source of truth).
| Tag | Native value type V | Use |
|---|---|---|
FP32 | Float | default; training, inference, ground truth |
FP16 | Float (promoted) | half precision inference |
Int32 | Int | indices, labels |
Int8 | Byte | quantised inference |
Int4 | Byte (promoted) | aggressive quantisation |
Ternary | Byte | -1/0/+1 weights |
tensor<FP32, Float>(...) — the value-type parameter follows the table above. tensor<FP32, Int>(...) will not type-check.
tensor(...) { tensor { } } or data(...) { tensor { } } accordingly.from, fromArray, full) for tests; randn / uniform for parameter init; init / randomInit for custom generators.pipeline<...>() — every step takes the ExecutionContext so the tensors land in the right backend.sliceView { segment { ... } } only when the operation isn't already covered by a tensor-op like narrow, unsqueeze, squeeze, flatten (those are simpler and cheaper).ExecutionContext itself comes from DirectCpuExecutionContext.create() (CPU) or DefaultNeuralNetworkExecutionContext() for the phase-aware form — see ../skainet-inference/SKILL.md.../skainet-nn-dsl/SKILL.md.tensor { } to your Gradle project — see ../skainet-consumer-setup/SKILL.md.../skainet-java-consumer/SKILL.md.skainet-testing skill.// WRONG — wrong value-type for the dtype
val t = tensor<FP32, Int>(ctx, FP32::class) { tensor { shape(2) { from(1, 2) } } }
// RIGHT — match the dtype/value-type table
val t = tensor<FP32, Float>(ctx, FP32::class) { tensor { shape(2) { from(1f, 2f) } } }
val ti = tensor<Int32, Int>(ctx, Int32::class) { tensor { shape(2) { from(1, 2) } } }
// WRONG — manually slicing with index loops in user code
val rows = (0 until 10).map { i -> bigTensor[i] }
// RIGHT — sliceView
val rows = bigTensor.sliceView { segment { range(0, 10) }; segment { all() } }
// WRONG — chained scalar ops to do preprocessing
val x1 = raw.ops.divScalar(raw, 255f)
val x2 = x1.ops.subScalar(x1, mean)
val x3 = x2.ops.divScalar(x2, std)
// RIGHT — a transform pipeline
val pre = pipeline<Tensor<FP32, Float>>()
.rescale(ctx, 255f)
.normalize(ctx, floatArrayOf(mean), floatArrayOf(std))
val out = pre(raw)
references/tensor-builders.md — every entry point on TensorCreationScope and ShapeBuilder, with signatures.references/transform-ops.md — every transform extension function in skainet-data-transform, with arguments and defaults.npx claudepluginhub skainet-developers/skainet-coding-skills --plugin skainet-consumer-skillsProvides behavioral guidelines to reduce common LLM coding mistakes, focusing on simplicity, surgical changes, assumption surfacing, and verifiable success criteria.
Searches, retrieves, and installs Agent Skills from prompts.chat registry using MCP tools like search_skills and get_skill. Activates for finding skills, browsing catalogs, or extending Claude.
Creates, edits, and optimizes skills for Claude Code, including drafting, evaluating with test prompts, iterating on performance, and improving skill descriptions for better triggering accuracy.