Skip to content

Getting started

By the end of this page you will have compiled a .knip file into a .sb3 and watched it run in TurboWarp.

  • Node.js 20 or newernode --version to check.
  • A text editor. VS Code is recommended, because Katnip ships an extension for it.
  • Somewhere to run the result: TurboWarp (fastest, no account) or scratch.mit.edu.
Terminal window
npm install -g @katnip-org/compiler

That puts a katnip command on your path:

Terminal window
katnip help

If you cloned the repository:

Terminal window
pnpm install
pnpm build
node packages/compiler/build/cli.js help

Make a file called hello.knip:

sprite Cat {
events.onFlag() {
looks.say("Hello from Katnip!", 2);
motion.forward(50);
motion.turn(90);
}
}

Three things to notice:

  • Everything that runs lives inside a sprite. A bare statement at the top of the file is a declaration, not an action.
  • events.onFlag() { ... } is the green-flag hat block. Inside a sprite, it becomes a script.
  • looks.say and motion.forward are standard-library procedures that map onto Scratch blocks one-for-one.

Before building, type-check:

Terminal window
katnip check hello.knip
No semantic errors found.

Now break it on purpose — change the 2 to "two":

Semantic Error: Argument 2 of 'say' expects 'num', got 'str'
at line 3, column 39
|
3 | looks.say("Hello from Katnip!", "two");
| ^^^^^

That is the entire pitch for Katnip in one screenshot. Change it back.

Terminal window
katnip build hello.knip
Wrote hello.sb3

Drag hello.sb3 onto turbowarp.org and click the green flag. The cat says hello and takes a step.

The VS Code extension gives you live diagnostics as you type, syntax highlighting, and a build command.

Terminal window
code --install-extension Katnip-org.katnip-vscode

Reload the window, open a .knip file, and errors underline as you type. Ctrl+Shift+PKatnip: Build .sb3 compiles the file you are looking at.

Full details, including the debounce and on-save settings, are in VS Code extension.