Skip to main content
The thinkwell CLI is the primary way to run and build Thinkwell agent scripts.

Usage

Running Scripts (Zero-Config)

The simplest way to run a Thinkwell script is to pass it directly to the CLI:
This runs your TypeScript file with native TypeScript support—no compilation step required. The CLI automatically processes @JSONSchema annotations. You can pass arguments to your script after the filename:

The run Subcommand

The explicit run subcommand is equivalent to passing a script directly:

Project Setup

thinkwell init

Initialize thinkwell in an existing directory:
This command:
  1. Creates package.json if none exists
  2. Adds thinkwell and typescript dependencies using the detected package manager (pnpm, yarn, or npm)
Options:
  • --yes, -y - Proceed without prompting for confirmation (CI-friendly)

thinkwell new

Create a new project in a new directory:
This creates a new directory with:
  • package.json with thinkwell dependency
  • tsconfig.json for TypeScript
  • src/main.ts with example agent code
  • .gitignore
  • .env.example

Type Checking

thinkwell check

Check a project for type errors:
This will essentially perform the same type checking as thinkwell build without writing any output files, which is faster for catching errors during development. In a workspace (pnpm or npm), all TypeScript packages are checked by default. Exit codes:
  • 0 - No type errors
  • 1 - Type errors found
  • 2 - Configuration error

Examples

Building Projects

thinkwell build

Compile your TypeScript project using the standard TypeScript compiler with @JSONSchema namespace injection:
This command compiles your project according to your tsconfig.json, applying @JSONSchema transformations first. Output (.js, .d.ts, source maps) is written to your configured outDir.

Examples

Configuration via package.json

Control which files receive @JSONSchema transformation:
Files not matched by include (or matched by exclude) are still compiled by TypeScript—they just skip @JSONSchema transformation.

Bundling Executables

thinkwell bundle

Compile your script into a standalone executable that can run without Node.js or Thinkwell installed:
The resulting binary includes:
  • Node.js 24 runtime with native TypeScript support
  • All thinkwell packages
  • Your bundled application code

Bundle Options

Target Platforms

Examples

Configuration via package.json

Set bundle defaults in your package.json:
CLI options override package.json settings.
Binaries are approximately 70-90 MB due to the embedded Node.js runtime. The --minify flag reduces bundle size, though the Node.js runtime dominates the total size.

Environment Variables

The agent environment variables let you swap agents at runtime without modifying code. For example, a script that calls open('claude') can be run with a different agent:
If both are set, THINKWELL_AGENT_CMD takes precedence.

Supported Agent Names