Skir is a declarative language for defining data types, constants, and APIs. Write your schema once in a .skir file and generate idiomatic, type-safe code in TypeScript, Python, Java, C++, and more.
npx skir initOne YAML file. One command. Watch mode recompiles automatically.
The generated code feels native to each language and is easy to use.
The workflow is dead simple.
// shapes.skir
struct Point {
x: int32;
y: int32;
label: string;
}
struct Shape {
points: [Point];
/// A short string describing this shape.
label: string;
}
const TOP_RIGHT_CORNER: Point = {
x = 600,
y = 400,
label = "top-right corner",
};// Import the module generated by Skir
import { Point } from "../skirout/shapes";
// Construct a frozen (immutable) Point
const point = Point.create({
x: 3,
y: 4,
label: "P"
});
// Serialize to dense JSON: compact and allows schema evolution
const pointJson = Point.serializer.toJson(point);
console.log(pointJson); // [3, 4, "P"]
// Deserialize from JSON
const restored = Point.serializer.fromJson(pointJson);
console.log(restored.label); // "P"Modifying schemas in a long-lived or distributed system is riskyβone wrong move can break clients or make it impossible to deserialize old data.
Skir has simple guidelines and built-in checks to evolve your schema safely.
Define your RPC methods in Skir and invoke them like local functions a la gRPC. No more API contract mismatches between your frontend and backend or across microservices. Client and server are always in sync.
struct WhatToWearRequest {
temperature_celsius: float32;
raining: bool;
}
struct WhatToWearResponse {
bottom_outfit: string;
sunglasses: bool;
}
method WhatToWear(WhatToWearRequest):
WhatToWearResponse = 770862;import { ServiceClient } from "skir-client";
import { WhatToWear, WhatToWearRequest, WhatToWearResponse }
from "../skirout/outfit_picker";
const client = new ServiceClient("http://localhost:8080/api");
const response: WhatToWearResponse = await client.invokeRemote(
WhatToWear,
WhatToWearRequest.create({
temperatureCelsius: 25,
raining: false,
}),
);
if (response.sunglasses) {
console.log("Don't forget your sunglasses π");
}Choose between dense JSON for web APIs and databases, readable JSON for debugging, or binary for raw performance.
Stop copying files. Import types directly from any GitHub repository. Share common data structures across projects.
A powerful VS Code extension with all the features you need. Real-time validation, go to definition, automatic code formatting.
Generate production-ready code for all major programming languages.
Set up your first Skir project in minutes. Manage your entire project configuration from a single YAML file.