Getting started

Quickstart

Five minutes: install the CLI, write a short prompt, watch the checker prove a contradiction, then pin the fix with a test and ship the build artifact.

1

Install the CLI

TypeGlish is an npm package. Add it as a dev dependency and run any command with npx typeglish …. Needs Node 20.19+; the Z3 proof tier installs by default (skip with --omit=optional).

npm⧉ copy
$ npm i -D typeglish
2

Write your first prompt

Near-plain English, with the rules graded by force. Save as hello.tg:

hello.tg✓ compiles
# Role
Agent IS a support agent for Acme, a SaaS analytics company.

# Constraints
- Agent MUST keep every reply to at most 3 sentences.
- Agent ALWAYS escalates a refund request to a human.

Compile it — the checker reads every line as a typed clause:

shell⧉ copy
$ npx typeglish check hello.tg
 1 file — 0 error, 0 warning, 0 info
3

Break it, on purpose

Add a rule that argues with one you already have, then compile again:

shell⧉ copy
$ echo "- Agent NEVER escalates a refund request to a human." >> hello.tg
$ npx typeglish check hello.tg
hello.tg:6:1  error  logic/contradiction  Logical conflict —
  "escalates a refund request to a human." is both required and
  forbidden. Keep one, or scope the two rules so they cannot both
  apply (IF <condition> THEN …).
 1 file — 2 error, 0 warning, 0 info

That refusal is the product: the contradiction is proven at compile time (by Z3), not left for the model to resolve differently every conversation. npx typeglish --explain logic/contradiction spells out any code.

4

Fix it, prove it, ship it

Delete the conflicting line (or scope one with IF / UNLESS). Then pin the behavior with a $TEST so the argument stays settled:

hello.tg — appended✓ 1 test
$TEST escalation
  - input:: I want a refund — can I talk to someone?
  - expect::
    - offers to escalate the request to a human
shell⧉ copy
$ npx typeglish test hello.tg --dry
 hello.tg  coverage: 1/2 rules exercised
 1 prompt — 0 failed
$ npx typeglish build hello.tg
 built .typeglish/dist/hello.txt ← hello.tg

--dry validates the suite offline; a live run sends each case to a model (ANTHROPIC_API_KEY). build writes the deployable prompt plus a hash manifest — that artifact, not the .tg, is what your app ships.

You compiled, broke, proved, tested, and built a prompt. That loop — edit → check → score → test → build — is the whole workflow.

Troubleshooting

typeglish: command not found

It's a dev dependency, not a global — run it through npx typeglish … (or add a script to package.json). Confirm it installed with npx typeglish --version.

A prompt that "worked fine yesterday" now fails to compile

It probably did — the model was resolving the conflict silently, a coin flip per conversation. The checker just made the coin flip visible. The error names the conflicting rule and the shared action; scope one rule with IF / UNLESS, or delete it.

Checking an existing prose prompt

npx typeglish check prompt.md reads plain English as-is. Ungraded imperatives and hedges come back as advisory findings — grade the ones that matter with a modal and leave the rest. npx typeglish score prompt.md gives you a number to improve against.

Where next