tos-toolkit
Static analysis, scaffolding, and adversarial review for ThinkScript (thinkorswim) code.
ThinkScript has no compiler you can run in CI, no package manager, and no module system. This toolkit gives you the parts that can be automated, and is explicit about the part that cannot:
$ tos lint # structural checks — no thinkorswim needed
$ tos syntax-check # real grammar check — needs a local thinkorswim
$ tos review --mode diff # adversarial AI review of your changes
$ tos mcp # serve the toolkit to a coding assistant (MCP, stdio)
Everything except syntax-check runs on a bare Python install with no
thinkorswim anywhere in sight.
Reference: Commands · Configuration · Rules · Installing and publishing · Adopting it · Agents and CI · Architecture
Install
$ pipx install tos-toolkit # isolated CLI install (recommended)
$ uv tool install tos-toolkit # or with uv
$ pip install tos-toolkit # into the current environment
On PyPI. Requires Python 3.11+; the core has zero Python dependencies.
The optional grammar check needs a local thinkorswim install and a JDK. The
[parser] extra adds no dependencies — it exists so the requirement is visible:
$ pipx install "tos-toolkit[parser]"
Pin it in CI — tos-toolkit==0.2.2 — because a new lint rule can turn a previously
green build red.
tos syntax-check additionally requires a locally installed thinkorswim and a
JDK. Nothing from thinkorswim is bundled or redistributed — see
ADR 0004.
Quickstart
$ mkdir my-tos-scripts && cd my-tos-scripts
$ tos init
$ tos new study trend/ema_cloud_flip
$ tos lint
$ tos status
tos init writes tos.toml, the artifact directories (studies/, scans/,
strategies/, columns/), copy-ready templates, a justfile, and appends a
conventions section to AGENTS.md.
Commands
| Command | Needs ToS? | Purpose |
|---|---|---|
tos lint [paths] |
no | Structure: headers, delimiters, identifier collisions, artifact rules, unknown functions |
tos status |
no | Validation debt — which scripts are still draft |
tos new <kind> <path> |
no | Scaffold a file from the bundled templates |
tos init |
no | Scaffold a project |
tos docs [topic] |
no | The bundled ThinkScript knowledge base |
tos explain <name> |
no | Is this function real? What's its confidence? |
tos review |
* | Adversarial review of a diff, files, or the whole repo |
tos syntax-check |
yes | Grammar validation using the real parser |
tos review needs the codex CLI on PATH (pinned model gpt-6.1-sol).
harness = "claude" is available as a substitute when Codex is unavailable.
tos lint
$ tos lint --strict # warnings become failures
$ tos lint --json # machine-readable
$ tos lint studies/ # one subtree
$ tos --profile loose lint # language rules only, ignore our conventions
Exit codes: 0 clean, 1 findings at error level, 2 usage or config problem.
tos explain
The registry exists because inventing a ThinkScript function is the single most common mistake — and the platform will reject the whole study for it.
$ tos explain TrueRange
TrueRange [volatility] confidence=verified
TrueRange(high, close, low) - three required arguments
$ tos explain HasOption
HasOption [option] confidence=unverified
internal API only; prefer IsOptionable
WARNING: unverified. Paste-test before relying on it.
tos docs
$ tos docs --list
$ tos docs gotchas
$ tos docs --grep "crosses above"
The knowledge base ships inside the package, so it is available from any project without locating this repo.
Two layers, and why
The rules are deliberately split. Mixing them is what makes a linter unusable outside its author's repo.
Layer 1 — language-generic (always on). True of ThinkScript anywhere:
unbalanced delimiters, // is not a comment, tabs, case-insensitive identifier
collisions, rec self-reference depth, unknown function names, and the
platform's own artifact restrictions (a scan genuinely cannot call AddLabel).
Layer 2 — house conventions (profile-gated). The # @key: header block, the
@status: draft → validated lifecycle, studies/<category>/ layout. Opinionated
on purpose, and fully removable.
Pick a profile in tos.toml:
| Profile | Header block | Layout rules | Use when |
|---|---|---|---|
strict (default) |
required | enforced | you want the full workflow |
loose |
off | off | pointing at a corpus you didn't write |
Any individual rule can be overridden:
[checks]
unknown_functions = "warn" # off | warn | error
W090 = "off" # silence one code
Configuration
[profile]
name = "strict"
[project]
targets = ["studies", "scans", "strategies", "columns", "templates"]
templates_dir = "templates"
[header]
mode = "required" # required | optional | off
[parser]
enabled = true
tos_path = "/Applications/thinkorswim"
[review]
harness = "codex" # codex | claude
model = "gpt-6.1-sol"
effort = "high"
[checks]
unknown_functions = "warn"
Resolution order: built-in profile, then your tos.toml on top.
What this cannot do
Being explicit is the point:
- It cannot tell you a script works. Only pasting it into thinkorswim and watching it render does that.
syntax-checkonly checks grammar. It will happily acceptFooBarNotAFunction(close). Function names, arity, types, and semantics are not validated by it — that is whatlint's registry andrevieware for.- It cannot see the future. A study that looks into the future with a negative offset still parses.
- The registry is curated, not exhaustive. An unknown name is a prompt to verify, not a verdict.
The intended loop is:
tos lint → tos syntax-check → tos review → paste into ToS → @status: validated
Only the last step earns the right to call a script validated, and only a human can do it.
Documentation
docs/consuming.md— adopting this from a new or existing projectdocs/architecture.md— module layout and the layering ruledocs/adr/— decisions that are expensive to reversesrc/tos_toolkit/docs/knowledge-base/— the ThinkScript reference (tos docs)AGENTS.md— guidance for AI agents working on this repo
License
MIT. This project bundles no thinkorswim code.
Metadata
Release files for tos-toolkit 0.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| tos_toolkit-0.2.2.tar.gz | 79.9 kB | With provenance | Details for tos_toolkit-0.2.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| tos_toolkit-0.2.2-py3-none-any.whl | Python 3 | none | any | Details for tos_toolkit-0.2.2-py3-none-any.whl |
Total release size: 157.6 kB
Release files / tos_toolkit-0.2.2.tar.gz
| Download URL | tos_toolkit-0.2.2.tar.gz |
|---|---|
| Size | 79.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9401f99cc1dc1caca9a2b246149d7a23bc2265dbe65bb008ae1b6fec8ad9cb2e
|
|
BLAKE2b-256 checksum How to use checksums |
f37cb457c6a38fa2d3c09a9388815ba8a2665362456e25431995c1f92892a092
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 26, 2026.
Transparency logRelease files / tos_toolkit-0.2.2-py3-none-any.whl
| Download URL | tos_toolkit-0.2.2-py3-none-any.whl |
|---|---|
| Size | 77.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6360cc7ca3664cbc0cce54ebf1c5aafd929fefdcafdeded43cfd13899f27343a
|
|
BLAKE2b-256 checksum How to use checksums |
f878d333457fbf47b56de15a7e239bb45a1314cebe8517d9574aa118d090b8b1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 26, 2026.
Transparency logSecurity for tos-toolkit 0.2.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for tos_toolkit-0.2.2.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 26, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.