Full language guide

ClearKrypt from zero.

These docs assume no one has ever seen ClearKrypt before. They explain the file structure, syntax, modules, UI system, styling, layout, data, auth, networking, storage, platform targets, compiler pipeline, sandbox exports, and deployment flow.

Start here

ClearKrypt is a cross-platform app language. A ClearKrypt file describes the app, imports modules, defines styles, declares data types, builds screens, and attaches actions. The compiler then emits web, worker, phone, PC, C#, Swift, or other target code.

app "Hello ClearKrypt"
use ui

screen Home {
  layout Stack
  title "Hello"
  text "This is a ClearKrypt screen."
  button "Tap Me" {
    say "Button tapped"
  }
}

The word app names the app. use ui enables UI declarations like screen, title, text, button, card, list, and layout.

Program structure

A typical ClearKrypt project is a folder with one or more .ck files, assets, and optional config. The main entry usually contains app, use, style, type, store, task, and screen blocks.

PartPurpose
appNames the application and becomes metadata for targets.
useImports a standard library module or extension module.
styleDeclares visual tokens used by UI emitters.
typeDefines structured data.
storeDefines local or remote state.
screenDefines a visual route/page.
taskDefines reusable logic.
app "Field Ops"

use ui
use data
use auth
use network
use storage
use platform

style Brand { theme: dark accent: cyan radius: 20 spacing: 16 }

type Report { id: Text title: Text status: Text }

store local reports as List<Report> default []

screen Home { layout Stack title "Reports" }

Modules and use

use is not a vague command. It opts a file into a capability namespace. The compiler uses modules to validate syntax, include runtime adapters, and decide which target APIs are required.

ModuleEnablesExamples
uiscreens, layout, visual elementsscreen, title, text, card
datatypes, stores, list rendering, queriestype, store, from, where
authuser/session checksrequire user.isLoggedIn
networkHTTP and API callsget, post, api
storagelocal files, app storage, asset referencessave file, read file
platformdevice/runtime featuresphone, desktop, web checks
workerbackground/cloud workersroute, schedule, event
cryptohashing, signing, tokenshash, sign
aistructured AI calls and model adaptersclassify, summarize
testunit and snapshot teststest, expect
deploydeployment metadatadeploy cloudflare
use ui       # visual screens and components
use data     # types, stores, list binding
use network  # HTTP APIs
use worker   # Cloudflare-style edge worker targets

Types

Types describe the shape of data. Built-in types include Text, Number, Boolean, Date, List<T>, Map<K,V>, and user-defined records.

type User {
  id: Text
  name: Text
  admin: Boolean
  createdAt: Date
}

type WorkOrder {
  id: Text
  equipmentId: Text
  status: Text
  notes: List<Text>
}

UI elements

UI is declarative. You describe what should exist; the target emitter translates it into HTML, SwiftUI, C#, or another platform. The compiler should preserve intent 1-to-1 instead of relying on AI translation.

ElementMeaning
screenA page or route.
titlePrimary heading.
textParagraph/body text.
buttonAction trigger.
cardGrouped visual surface.
listRepeats data-driven UI.
inputUser entry field.
toggleBoolean input.
screen Dashboard {
  layout Stack
  title "Dashboard"
  card {
    text "Open Work Orders"
    button "View"
  }
}

Styling

Styling is explicit. use ui gives you elements, but style gives them a visual identity. Styles compile to CSS variables, SwiftUI modifiers, C# theme data, and runtime tokens.

style AppStyle {
  theme: dark
  accent: cyan
  surface: glass
  radius: 22
  spacing: 18
  font: system
}
TokenPurpose
themedark, light, auto
accentprimary brand accent
surfaceflat, glass, raised
radiuscorner roundness
spacingdefault gap between elements
fonttypographic family mapping

Layout

ClearKrypt should be usable without dragging. Stack is the safe default and aligns elements in order. Grid creates responsive cards. Dock pins regions. Freeform enables optional drag and @pos(x,y).

screen Home {
  layout Stack
  title "Aligned automatically"
  text "No drag required."
}

screen Designer {
  layout Freeform
  title "Move me" @pos(40, 40)
  button "Save" @pos(40, 120)
}

Data and stores

Stores are named state containers. local means browser/app storage. Remote adapters can map to Firebase, SQL, REST, or custom providers.

type Task { id: Text title: Text done: Boolean }

store local tasks as List<Task> default [
  Task { id: "1" title: "Learn ClearKrypt" done: false }
]

screen Tasks {
  layout Stack
  list tasks as task {
    card {
      text task.title
      toggle task.done
    }
  }
}

Auth

The auth module provides user/session concepts. Emitters can map this to Firebase Auth, custom JWT, OAuth, or platform identity providers.

use auth

task createReport(title: Text) {
  require user.isLoggedIn
  require user.role in ["admin", "tech"]
  say "Report created"
}

Network

The network module describes HTTP calls without hard-coding a specific JavaScript fetch implementation. Target emitters choose the native equivalent.

use network

api Weather {
  base "https://api.example.com"

  get forecast(city: Text) from "/forecast?city={city}"
}

Storage

Storage covers files, blobs, uploads, app cache, and generated assets. Targets can map to browser localStorage, IndexedDB, iOS files, Android storage, desktop files, or cloud storage.

use storage

task saveDraft(text: Text) {
  save text to local file "draft.txt"
}

Platform

Platform checks let one ClearKrypt source adapt behavior without forking the app.

use platform

when platform is phone {
  say "Use mobile scanner"
} otherwise {
  say "Use desktop upload"
}

Actions and tasks

Buttons run action blocks. Reusable actions should be moved to task blocks.

task greet(name: Text) -> Text {
  return "Hello " + name
}

screen Home {
  button "Greet" {
    let message = greet("Caleb")
    say message
  }
}

Error handling

ClearKrypt uses structured error handling so generated targets can map to try/catch, Result types, or native error systems.

try {
  save report to remote "reports"
} catch error {
  say "Save failed: " + error.message
}

Compiler targets

ClearKrypt target emitters should be deterministic. HTML Package emits index.html, style.css, and main.js. Native targets emit platform-specific project scaffolds or code files.

TargetOutput
webindex.html, style.css, main.js
workerCloudflare Worker script
phoneCapacitor-style phone project shell
pcElectron-style desktop shell
csharpC# target code
swiftSwiftUI target code
vmClearKrypt VM bytecode/IR

CLI

After publishing, users install the compiler globally from npm.

npm install -g clearkrypt
ck --help
ck init my-app
ck run app.ck
ck build app.ck --target web --out dist/web
ck build-all app.ck --out dist
ck studio app.ck --out studio

AI and crawler support

The site includes llms.txt, ai-index.json, robots.txt, sitemap.xml, and stable docs pages so crawlers and AI tools can learn ClearKrypt without guessing.

# ClearKrypt
Official docs: /docs
Sandbox: /sandbox
Compiler: /compiler
Package: npm install -g clearkrypt
Primary extension namespace: @clearkrypt/*