A shebang interpreter for natural language scripts. Write what you want in plain English, make it executable, and run it.
#!/usr/bin/env think
Print "hello world" and exit
chmod +x hello.thought
./hello.thought
# => hello worldthink sends your script to an LLM, which executes JavaScript in a sandboxed runtime to accomplish the task. Output goes to stdout, debug goes to stderr — scripts are fully pipeable.
- Build
make build- Set up your API key
./bin/thought setupOr set the environment variable:
export THINKINGSCRIPT__ANTHROPIC__API_KEY=sk-ant-...- Run a script
./bin/think examples/weather.md "San Francisco"You can also run thoughts directly from a URL:
./bin/think https://example.com/weather.thought "NYC"When running from a URL, think displays the thought content and asks for confirmation before executing.
The first line #!/usr/bin/env think tells your OS to use think as the interpreter. Everything after the shebang (minus optional frontmatter) becomes the prompt sent to the LLM.
Scripts can include optional YAML frontmatter between --- delimiters to configure behavior:
#!/usr/bin/env think
---
agent: anthropic
model: claude-haiku-4-5
max_tokens: 8192
---
List all Go files in the current directory and count them.
All frontmatter fields are optional:
| Field | Description | Default |
|---|---|---|
agent |
Which agent definition to use | anthropic |
model |
Override the agent's default model | Agent's model |
max_tokens |
Maximum tokens for LLM response | 16000 |
effort |
Thinking depth: low, medium, high, xhigh, max |
medium |
Configuration is resolved with three layers (highest precedence first):
ENV vars use THINKINGSCRIPT__ prefix with __ as separator:
| ENV var | Description | Example |
|---|---|---|
THINKINGSCRIPT__AGENT |
Agent to use | anthropic |
THINKINGSCRIPT__MODEL |
Model override | claude-opus-5 |
THINKINGSCRIPT__MAX_TOKENS |
Max tokens | 8192 |
THINKINGSCRIPT__EFFORT |
Thinking depth (low–max) |
high |
THINKINGSCRIPT__ANTHROPIC__API_KEY |
Anthropic API key | sk-ant-... |
THINKINGSCRIPT__OPENAI__API_KEY |
OpenAI API key | sk-... |
THINKINGSCRIPT__OPENAI__API_BASE |
OpenAI base URL | http://localhost:11434/v1 |
THINKINGSCRIPT__CACHE |
Cache mode (see below) | off |
THINKINGSCRIPT_HOME |
Override home directory | ~/.mythinkingscript |
Note: THINKINGSCRIPT_HOME uses a single underscore (it's a path, not a config override).
See Frontmatter above.
~/.thinkingscript/
├── config.json # Global settings
├── policy.json # Global default policy
├── agents/
│ └── anthropic.json # Anthropic agent definition
├── bin/ # Installed thought binaries
├── thoughts/
│ └── <name>/
│ ├── policy.json # Per-thought policy
│ ├── workspace/ # Per-thought working directory
│ └── memories/ # Per-thought persistent memories
└── cache/<fingerprint>/ # Per-script cache (content-addressed)
└── fingerprint
config.json — Global defaults:
{
"version": 1,
"agent": "anthropic",
"max_tokens": 4096,
"max_iterations": 50
}agents/anthropic.json — Agent definition:
{
"version": 1,
"provider": "anthropic",
"api_key": "sk-ant-...",
"model": "claude-opus-5"
}The LLM has two tools available:
| Tool | Description |
|---|---|
write_stdout |
Write text to stdout (the only way to produce output) |
run_script |
Execute JavaScript in a sandboxed runtime |
The LLM's text responses go to stderr (debug). Only write_stdout produces actual output.
The run_script tool executes JavaScript in a sandboxed goja runtime with these globals:
| Global | Description |
|---|---|
fs.readFile, fs.writeFile, fs.readDir, etc. |
Filesystem access |
net.fetch(url, options?) |
HTTP requests |
env.get(name) |
Read environment variables |
sys.platform(), sys.arch(), sys.cpus(), etc. |
System info |
console.log, console.error |
Debug output (to stderr) |
process.cwd(), process.args, process.exit(code) |
Process info |
require(path) |
CommonJS module loading |
All JS is synchronous — no async/await/Promises.
When the LLM wants to access something sensitive, a prompt appears:
◆ NET api.github.com
❯ 1 Allow
2 Deny
- Allow: persist the decision to the thought's
policy.json - Deny: reject and save; the LLM adapts and tries another approach
- Non-interactive: all sensitive actions are denied by default (safe for CI/pipes)
Policies are JSON files that control what a thought can access:
{
"version": 1,
"paths": {
"default": "prompt",
"entries": [
{"path": "/Users/brad/projects", "mode": "rwd", "approval": "allow"}
]
},
"env": {
"default": "prompt",
"entries": [
{"name": "HOME", "approval": "allow"},
{"name": "AWS_*", "approval": "deny"}
]
},
"net": {
"hosts": {
"default": "prompt",
"entries": [
{"host": "*.github.com", "approval": "allow"}
]
},
"listen": {
"default": "deny",
"entries": []
}
}
}Path modes: r (read/list), w (write), d (delete). Combined like chmod: rwd for full access.
Wildcards: Env names support suffix wildcards (AWS_*). Hosts support prefix wildcards (*.github.com).
On first run, a thought automatically gets:
- Workspace (
~/.thinkingscript/thoughts/<name>/workspace/):rwd - Memories (
~/.thinkingscript/thoughts/<name>/memories/):rwd - CWD:
r(read-only)
# List policy for a thought
thought policy ls weather
# Add entries
thought policy add path weather /Users/brad/data --mode rwd
thought policy add env weather HOME
thought policy add host weather "*.github.com"
# Remove entries
thought policy rm path weather /Users/brad/data
thought policy rm env weather HOME
thought policy rm host weather "*.github.com"
# List global policy
thought policy lsControls how per-script cache is managed between runs. Caches are automatically invalidated when either the script content or the think binary changes.
| Mode | Description |
|---|---|
persist (default) |
Cache survives between runs |
ephemeral |
Cache works during the run but is wiped on exit |
off |
No cache at all |
THINKINGSCRIPT__CACHE=off think examples/weather.md "NYC"# Print cache directory for a script
thought cache ./hello.thought
# Clear cache for a specific script
thought cache --clear ./hello.thought
# Clear all caches
thought cache --clear-allstdout is sacred — only write_stdout tool output goes there. Scripts compose naturally with Unix pipes:
# Pipe data through an AI script
cat data.csv | ./summarize.thought > summary.txt
# Chain scripts
./generate-report.thought | ./format-output.thought#!/usr/bin/env think
Print "hello world" and exit
#!/usr/bin/env think
Fetch the current weather for the city provided as an argument.
Print a brief summary including temperature and conditions.
./weather.thought "San Francisco"#!/usr/bin/env think
Read stdin as JSON, extract all "name" fields, and print them one per line.
cat users.json | ./extract-names.thought#!/usr/bin/env think
List all .go files in the current directory, count them,
and print "Found N Go files" where N is the count.
# Build a thought into a standalone binary
thought build weather.thought -o weather
# Install to ~/.thinkingscript/bin/
thought install weather.thought# List all installed thoughts
thought ls
# Show details about a thought
thought info weather
# Run an installed thought
thought run weather "San Francisco"
# Get the path to a thought binary (for scripting)
thought bin weather
# Remove a thought (keeps data)
thought rm weather
# Remove a thought and its data
thought rm --force weather