Installation with Homebrew (Recommended)
Homebrew is the simplest way to install Thinkwell system-wide:Manual Installation
- macOS (Apple Silicon)
- macOS (Intel)
- Linux (ARM64)
- Linux (x64)
Zero-Install (Node.js)
If you don’t want to install anything, you can use Thinkwell vianpx:
Create Your First Agent
Create a new TypeScript file calledgreeting.ts:
Run Your Script
The Thinkwell CLI can run TypeScript files directly without any compilation step:Understanding the Code
Let’s break down the key concepts:Imports
Thinkwell provides a standard npm package import:thinkwell- The main package, providingopen(),Agent, and other APIs
The @JSONSchema Pattern
The@JSONSchema JSDoc tag is central to how Thinkwell works. When you annotate an interface with @JSONSchema, Thinkwell automatically generates a JSON Schema and attaches it as a static Schema property:
Greeting.Schema when calling agent.think(), which tells the agent what structured output to produce. The JSDoc comments on properties become descriptions in the generated schema, helping the AI understand what each field should contain.
Agent Lifecycle
- Open -
open('claude')connects to the AI backend by name - Think -
agent.think(Schema).text(prompt).run()sends your prompt and returns structured output matching your schema - Close - Always close the agent when done to clean up resources
Next Steps
Now that you have a basic agent working, explore:- API Overview - Learn about schemas, tools, and the Plan API
- Sessions - Create multi-turn conversations with persistent context
