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.
| Part | Purpose |
|---|---|
| app | Names the application and becomes metadata for targets. |
| use | Imports a standard library module or extension module. |
| style | Declares visual tokens used by UI emitters. |
| type | Defines structured data. |
| store | Defines local or remote state. |
| screen | Defines a visual route/page. |
| task | Defines 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.
| Module | Enables | Examples |
|---|---|---|
| ui | screens, layout, visual elements | screen, title, text, card |
| data | types, stores, list rendering, queries | type, store, from, where |
| auth | user/session checks | require user.isLoggedIn |
| network | HTTP and API calls | get, post, api |
| storage | local files, app storage, asset references | save file, read file |
| platform | device/runtime features | phone, desktop, web checks |
| worker | background/cloud workers | route, schedule, event |
| crypto | hashing, signing, tokens | hash, sign |
| ai | structured AI calls and model adapters | classify, summarize |
| test | unit and snapshot tests | test, expect |
| deploy | deployment metadata | deploy 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.
| Element | Meaning |
|---|---|
| screen | A page or route. |
| title | Primary heading. |
| text | Paragraph/body text. |
| button | Action trigger. |
| card | Grouped visual surface. |
| list | Repeats data-driven UI. |
| input | User entry field. |
| toggle | Boolean 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
}| Token | Purpose |
|---|---|
| theme | dark, light, auto |
| accent | primary brand accent |
| surface | flat, glass, raised |
| radius | corner roundness |
| spacing | default gap between elements |
| font | typographic 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.
| Target | Output |
|---|---|
| web | index.html, style.css, main.js |
| worker | Cloudflare Worker script |
| phone | Capacitor-style phone project shell |
| pc | Electron-style desktop shell |
| csharp | C# target code |
| swift | SwiftUI target code |
| vm | ClearKrypt 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/*
