Overview

Klaat (Kodelabs As A Thing) is a modern command-line tool written in Kotlin and compiled to native machine binaries using GraalVM. It serves as a spiritual successor to the archived Google Codelabs command-line tool (claat).

Klaat enables technical writers, software engineers, and educators to convert structured Markdown files and Google Documents into beautiful, step-by-step interactive tutorials called codelabs.

Key Capabilities

  • Markdown & Google Docs Input: Generate tutorials using your favorite tools.
  • Built-in Live Preview: Instantly check your work on a local Ktor web server.
  • Zero Dependencies: Compiled directly to native machine code for instant startup and low memory usage.
  • Flexible Publishing: Export to standalone HTML files, standard Markdown output, or fully self-contained offline packages.

Installation

Klaat is distributed as a single native binary for macOS (Apple Silicon only) and Linux. Choose one of the installation methods below.

Homebrew (macOS & Linux)

Homebrew is the easiest way to install and manage Klaat versions.

Stable Release

brew tap kartikarora/klaat
brew install klaat

Snapshot Builds (Develop Branch)

brew tap kartikarora/klaat-snapshots
brew install klaat-snapshot

Quick Start

Export your first codelab in three simple steps.

1

Create a Markdown Tutorial

Save the following content to hello.md:

---
id: hello-world-tutorial
summary: An introductory tutorial
categories: General
status: Published
authors: Your Name
---

# Hello World Tutorial

## Step 1: Getting Started
Duration: 3

Welcome to this tutorial! 

## Step 2: Conclusion
Duration: 2

You are done!
2

Export the Codelab

Run the export command to generate HTML pages:

klaat export hello.md -o output/
3

Serve and Preview

Run the local preview server to review your work:

klaat serve -d output/

klaat help

The help command displays global help information, available subcommands, or detailed options for a specific subcommand.

NAME

klaat-help - Show help information for klaat or any subcommand

SYNOPSIS

klaat [OPTIONS] or klaat [COMMAND] --help

DESCRIPTION

Prints usage syntax, supported flags, subcommands, and options. Append --help or -h to any subcommand to inspect its specific parameters.

OPTIONS
Option / Flag Type Default Value Description
-h, --help Flag - Show command help message and exit.
EXAMPLES

Show global help and available commands:

klaat --help

Show help for a specific subcommand:

klaat export --help
klaat serve -h

klaat version

Prints version metadata including release build name, commit hashes, target platform architectures, and Gradle dependencies.

klaat version

klaat install-skills

The install-skills command dynamically unpacks KLAAT codelab authoring skills and formatting instructions into existing AI coding agent folders in the project workspace or global directories.

NAME

klaat-install-skills - Install KLAAT AI guidelines to active coding agent directories

SYNOPSIS

klaat install-skills [OPTIONS]

DESCRIPTION

Scans the directory for existing AI agent config paths and populates active folders with offline authoring references (klaat-markdown-author and klaat-gdocs-author). Supports over 55+ distinct coding agents, writing only to paths that exist.

OPTIONS
Option / Flag Type Default Value Description
-g, --global Flag - Install to global user home directories (e.g. ~/.claude, ~/.agents) instead of the project root.

klaat export

The export command reads a list of source files (Markdown or Google Docs IDs) and renders them into the specified output formats.

NAME

klaat-export - Export document sources into interactive codelab tutorials

SYNOPSIS

klaat export [OPTIONS] SOURCES...

DESCRIPTION

Parses Markdown documents or fetches documents from Google Docs API (using Document IDs), converts the parsed hierarchy into the codelab model representation, and outputs rendered static directories.

OPTIONS
Option / Flag Type Default Value Description
-f, --format String html Output format: html (web pages), md (markdown conversion), or offline (self-contained offline bundle).
-o, --out Path . Target directory where output directories will be written.
-ga String - Google Analytics measurement or tracking ID to inject (optional).
-p, --prefix URL https://distribute.kartikarora.me Asset hosting prefix for loading native styling elements.
-css File/URL - Custom CSS file path or remote stylesheet URL to load within generated HTML.
-favicon File/URL - Path or URL of a custom favicon.
-fonts URL - Google Fonts stylesheet import URL to load custom fonts.
-footer HTML/String - Custom footer HTML or text to display at the bottom of the codelab.
-extra JSON String - A JSON object representation of custom key-value pairs injected directly into output.
-pass_metadata Comma list - Comma-delimited keys list of frontmatter variables to carry over to generated outputs.
-auth String - Google API OAuth bearer token for manual Google Doc fetching bypass.
-e String web Target environment filter (e.g. web, kiosk).
EXAMPLES

Export a local Markdown file into HTML:

klaat export tutorial.md -o build/codelabs/

Export a Google Doc using custom CSS styles:

klaat export 1sK...J6g -o build/ -css https://example.com/custom.css

klaat serve

The serve command hosts your exported codelabs locally so that you can view them as they will appear when deployed.

NAME

klaat-serve - Local web server for real-time codelab previews

SYNOPSIS

klaat serve [OPTIONS]

DESCRIPTION

Launches a lightweight Ktor web server hosting files of the specified directory. Offers automated browser execution upon initialization.

OPTIONS
Option / Flag Type Default Value Description
-p, --port Integer 9090 Port number to host the local preview server on.
-h, --host String localhost Address bound during startup binding.
-d, --dir Path . Relative directory location to serve files from.
--no-browser Flag - Bypasses automated browser launching during application startup.

klaat update

The update command scans an output directory, reads original resource paths from the metadata of existing codelabs, refetches the source (e.g., from Google Docs), and updates the rendered files in place.

NAME

klaat-update - Update existing codelabs from their configuration sources

SYNOPSIS

klaat update [OPTIONS] [PATHS...]

OPTIONS
Option / Flag Type Default Value Description
-ga String - Override Google Analytics measurement ID during update.
-p, --prefix URL - Override CDN asset loading prefix URL during update.

klaat demo

The demo command extracts the bundled showcase demo codelab into the current working directory, exports it to HTML, and immediately launches the local preview server.

NAME

klaat-demo - Extract, export, and preview the interactive feature showcase

SYNOPSIS

klaat demo [OPTIONS]

DESCRIPTION

Unpacks the bundled feature-showcase.md and its assets (images) into the current directory, executes the export pipeline targeting the specified output folder, and begins serving the resulting codelabs locally via Ktor.

OPTIONS
Option / Flag Type Default Value Description
-addr String localhost:9090 Hostname and port to bind for the preview server.
-o, --out String output Directory to export the generated demo codelab into.
-f, --format String html Output format (html, md, offline).
-prefix String https://distribute.kartikarora.me Asset prefix URL for stylesheets and web components.
--no-browser Flag false Do not automatically open the browser when the server starts.
--no-serve Flag false Extract and export only, without starting the preview server.
EXAMPLES

Extract and launch the live demo immediately:

klaat demo

Extract and export without starting the server:

klaat demo --no-serve

Codelab Format Guide

The syntax schema, YAML frontmatter, Google Docs visual mappings, and supported rich elements are documented on a dedicated format guide page.

menu_book

Looking for the Formatting Rules?

Read about frontmatter structure, code blocks, info alerts, checks, surveys, tables, video embeds, and Google Doc mappings.

arrow_forward Go to Format Guide

Google Docs Setup

To pull documents directly from Google Docs using document IDs, Klaat requires access permission tokens using OAuth Desktop App configurations.

1. Setup credentials.json

Create a file named gcp_credentials.json in the project root or copy it to the resources directory (src/main/resources/credentials/gcp_credentials.json):

{
  "installed": {
    "client_id": "YOUR_CLIENT_ID.apps.googleusercontent.com",
    "client_secret": "YOUR_CLIENT_SECRET",
    "redirect_uris": ["http://localhost"],
    "auth_uri": "https://accounts.google.com/o/oauth2/auth",
    "token_uri": "https://oauth2.googleapis.com/token"
  }
}

2. Authentication workflow

On your first export command executing a Google Document ID source, Klaat will:

  1. Launch your default web browser redirecting to Google Auth services.
  2. Request user authorization confirming Read Access permissions for Google Docs.
  3. Saves credentials locally within a file token storage: ~/.klaat/tokens/StoredCredential.

Differences from original claat

While Klaat serves as a spiritual successor with high flag compatibility, there are some differences:

  • Built with Kotlin: Rewritten from Go into Kotlin. Relies on Flexmark and FreeMarker underneath.
  • Auto-browser in serve: The serve command opens your browser automatically. Disable this with --no-browser.
  • Storage Path: Authentication tokens are stored inside ~/.klaat/tokens/, whereas Go claat stores them in ~/.claat/ or browser configurations.