Kobo is an AI-conscious, general-purpose programming language built for the .NET ecosystem. Designed for both human developers and AI code generation, it emphasizes syntactic consistency, expressive programming constructs, and reduced complexity. This is a practical reference to the language as it exists today — Kobo is still in preview, and the syntax may evolve.
01 / FOUNDATIONS
Program structure
Files can contain import directives, using type replacements, a module declaration, types, functions, and extension blocks. Braces delimit blocks; identifiers are case-sensitive. Ordinary single-line statements generally do not need a semicolon.
import * from System
import * from System/Collections/Generic
import * from
{
System/Net,
System/Collections/Generic,
System/Linq
}
import * as Sys from System
using Math as M from System
module Example/Inventory
[public] class:Item
{
[public] property:string Name
}- Imports use
import ... from ...to bring names into scope without rewriting references. Use*for a namespace,* as Sysfor a namespace alias, a type name with optionalasalias, or a brace-enclosed list. They do not install packages. - Grouped wildcards use
import * from { System/Net, System/Linq }; the comma-separated namespace list may span lines and imports each namespace independently. - Static imports expose a type's static members:
import static Math from System. In a list, mark each static type separately:import { static Math, Console } from System. Static wildcards are rejected. - Type replacement uses
using Math as M from SystemsoM.Sqrt(144)identifies the fully qualified type. Single types, aliases, compound lists, generic definitions, and lexical scopes are supported. Onlyusing, notimport, performs this substitution. - Modules declare namespaces with forward slashes, as in
Company/Commerce/Orders. - Member access uses dots:
item.NameorConsole.WriteLine. - Declaration colons touch both sides: write
class:Item, notclass: Item.
VALUES & I/O
Console & JSON
Print(...) writes a line using supported argument forms. Input() reads a line; Input("Name: ") displays a prompt without a newline before reading. Strings support ${expression} interpolation. Prefix a string with verbatim to keep backslashes and ${...} exactly as written, or with raw to ignore escapes while still interpolating. @"..." and """...""" strings are not supported.
var:string name = Input("Name: ")
Print("Hello, ${name}!")
var:string source = raw """{"name":"Kobo"}"""
var:json details = source
var:string text = details.StringValue
Print(text)json supports property and indexer access. StringValue returns JSON text; implicit conversions between json and string parse or serialize it. Converting invalid JSON text throws JsonException.
NATIVE AI
Prompts & tools
Declare a typed request with prompt:Type name { ... } in a #:script or an async function. The body is plain text, including nested JSON; only ${expression} evaluates Kobo code. Use \${...} for a literal placeholder.
#:script
[tool, description("Adds two integers")]
function:int Add(int first, int second) => first + second
prompt:int result {
Use Add to calculate ${20} plus ${22}.
}
if result is int number
{
Print(number)
}A non-string prompt returns the requested type or the original response as a string alternative. Object, primitive, and collection responses are supported. [tool] exposes eligible functions to prompts. Configuration is read at runtime from kobo.ai.json; see the full guide for providers, authentication, and error handling.
02 / VALUES
Types & variables
Built-in types include the familiar numeric types, bool, char, string, and object. Arrays, collections, dates, tasks, and other .NET types are available through imports.
var:int count = 3
var message = "Welcome to Kobo"
var:string? nickname = null
var displayName = nickname ?? "Guest"
const:int MaximumAttempts = 5
var:int[] scores = [10, 20, 30]
var:List<string> names = ["Ada", "Grace"]var:Typedeclares an explicit type;varinfers locals and class, struct, or record fields from their initializers.- Inferred fields have fixed compile-time types and are private by default. Use
var:Typefor null, empty, target-typed, unresolved, or circular initializers, andvar:dynamicfor intentional dynamic binding. - Variables need an initial value. Constants use
const:Type Name = valueand constant expressions, including at global scope. ?marks nullable types,?.performs conditional access, and??supplies a fallback.- Collection expressions use square brackets. Import
System/Collections/GenericforList<T>.
class:Counter
{
var count = 0
[public] var Name = "Kobo"
[public, static, readonly] var Limit = 10
}Untyped fields used dynamic binding in earlier releases. Use var:dynamic to preserve that behavior when migrating.
var:union(int,string) result = 42
var:union(int,string) description = "Complete"Union types are supported in variable declarations. The compiler generates a shared namespace-level type for each case list; standalone union declarations are not supported.
03 / ABSTRACTIONS
Functions & classes
Functions put the return type after function:. Parameters use Type name, and modifiers appear in square brackets. Classes, structs, records, interfaces, properties, indexers, inheritance, and generics are available.
[public, static] function:int Add(int left, int right)
{
return left + right
}
[public] class:Box<T>
{
[public] property:T Value { get; set; }
}A function without a return value uses void. Generic constraints use where T is Constraint. A class can inherit from a parent type or implement interfaces with is:
[public] class:Dog is Animal, ISpeaker
{
}Use parent.Member to access inherited members and new(...) calls parent(...) to initialize the parent. Global functions and constants are available through the module's Global type.
A [partner] class:Template remains usable as a standalone class. List it with class:Owner partners Template to give the owner a distinct private nested implementation, initialized with calls Template(...). Only partner fields, properties, and functions marked [shared] are available inside the owner; they are not forwarded to its public API. If every partner has a public parameterless constructor, the compiler can initialize them automatically. Partner classes and owners currently belong in the same file.
Functions can attach side-effect-free Boolean requires and ensures clauses immediately after their headers. Preconditions run before the body, while postconditions run before each successful return; result names a returned value in an ensures clause. See the full guide for restrictions and examples.
04 / FLOW
Control flow & expressions
Kobo has familiar arithmetic, comparison, logical, conditional, and null-handling operators. Use if, else, switch, foreach, while, and for with brace-delimited blocks.
if score >= 90
{
Console.WriteLine("Excellent")
}
else if score >= 60
{
Console.WriteLine("Passed")
}
foreach name in names
{
Console.WriteLine(name)
}Equality alternatives can share a left-hand expression: if status == 200 || 201 || 204 compares status to each alternative. Use parentheses when mixing conjunctions and disjunctions.
05 / FUNCTIONS AS VALUES
Lambdas & delegates
Delegate types use (parameter-types)->return-type. A final delegate parameter can be called with a trailing lambda block.
var:(int)->int doubleValue = value => value * 2
var answer = doubleValue(21)
var:(string)->void write = message =>
{
Console.WriteLine(message)
}06 / DATA
LINQ queries
Kobo uses a select-first query form. Queries support filtering, equality joins, grouping, ordering, and projections. Multiline query statements require an explicit trailing semicolon.
var names = select person from people
where person.Age > 30
orderby person.Name
project person.Name;From-first from ... in ... queries are not supported. Use project { ... } to create an anonymous object projection.
Page results with skip and take before project. Follow the projection with | and a result step: list, first, last, or count, or, for a numeric projection, average, sum, min, and max. average, min, and max also accept a selector, as in | min(p => p.Length).
var page = select planet from planet_list
where planet.StartsWith('m')
skip 10 take 5
project planet | list;
var average_age = select p from people
where p.Age > 25
project p.Age | average;
var shortest = select planet from planet_list project planet | min(p => p.Length)07 / TOOLING
Build Kobo
Install the compiler with the .NET 11 SDK, then build a file or directory. A static Main produces an executable; without one, the output is a library.
dotnet tool install --global thinkmine.kobo.lang --prerelease
kobo build --source hello.kobo --output-directory ./build --name Hello
dotnet ./build/Hello.dllEvery build, run, and generate command requires --source to name the file or folder to use (--source . for the current folder). Build all files in a folder with kobo build --source ./src; add --recursive to include subfolders. For Kobo source in a .NET project, use thinkmine.kobo.lang.buildtools and the project's normal workflow.
Add --markdown to kobo build or kobo run to write the Markdown companion from ### comment blocks (by default test.kobo produces test.kobo.md; pass a relative path to rename it), and --publish-code to save the compiler source listing. Without --markdown, no Markdown is written. To write only the Markdown, use kobo generate with a required target file.
kobo run --source app.kobo --markdown --publish-code -- Ada
kobo build --source app.kobo --markdown docs/app.md
kobo generate --source app.kobo --markdown output.mdIn a script, a top-level render:<language> { ... } block adds its printed output to the generated Markdown as a fenced block, for example a Mermaid diagram. Render blocks run only when Markdown is generated, as their own small program that can use the script's functions, types, and constants but not its top-level variables.
render:mermaid {
Print("graph TD")
Print(" A --> B")
}Take the next step.
This is a quick web reference. Download the full language guide for detailed examples, async functions, exceptions, extensions, and complete build instructions.
EDITOR SUPPORT
Completion in VS Code
The Kobo extension suggests Kobo declarations, local names, .NET members, imports, and declarations from other workspace .kobo files, including unsaved open files. Prompt text stays plain; completion and highlighting apply to Kobo expressions inside ${...}. Project-specific .NET references are resolved by the consuming build, not loaded by the language server.