Optimizing

TG score

The TG score grades a prompt A–F from seven facets. It’s deterministic and explainable — no model in the loop.

The score facets

The TG score is a weighted blend of seven facets across a runtime plane (what the model reads) and a hygiene plane (how the source reads). Explain any facet with typeglish --explain <facet>.

FacetWhat it measuresWhat raises it
enforceability · runtime · w0.25How much of the prompt the checker can see into: the share of candidate rule lines that lower into checkable IR, how many hard rules parse proof-grade, and how many are measurable.Write rules as MUST / NEVER <verb> … with concrete bounds ("at most 3 sentences"), not vague qualities — a rule the checker can parse is a rule it can defend.
hardness · runtime · w0.15THE HARDNESS DOCTRINE (SPEC §15): how BINDING the prompt's language is. Every force word sits on a spectrum (must not ↔ must, never ↔ always, no ↔ all); hardness is its distance from the waver center (THE POLE LAW — both poles bind, the middle wavers), and a statement scores the MIN over its force words (one hedge softens the whole rule). An unhedged command is 1.0; 1.0 renders PURE BOLD in the editor.Commit to pole words — MUST / NEVER / ALWAYS / ALL / exact bounds ("at most 3") — and delete the soft middle: should, sometimes, about, try to, as needed each cap their statement below 1.0.
directness · runtime · w0.1THE DIRECTNESS AXIS (SPEC §15's sibling): explicit beats implicit. A statement is only as actionable as its encoded DOER (imperative/you > named > definite party > generic > by-passive > agentless passive > nominalization) and its RESOLVED pointers (a pro-form with no referent is a guess). Directness is the MIN over the two channels, averaged over action-shaped statements; states abstain.Use the imperative or a named doer ("Verify the order.", "You must ..."), keep the active voice (not "is verified" / "a review must take place"), and make every it/this point at something the prompt introduced.
density · runtime · w0.2Advisory, model-backed: information per token — mean residual value + non-redundancy from the semantic tier. Moves the number, never the gate; present only when the semantic report ran.Delete the lines the ablation marks removable and merge overlapping rules.
consistency · runtime · w0.2Deductions from logic/* and clarity/* findings — contradictions, dead rules, duplicates — rated per statement.Fix the ledger rows with logic/ or clarity/ codes; state each fact in one place.
structure · hygiene · w0.15Deductions from structure/* and typeglish/* findings — indentation, sections, references, terminators — rated per statement. (hygiene plane: authoring discipline)Fix the ledger rows with structure/ codes; most carry a one-click fix.
annotation · hygiene · w0.15Statement-documentation coverage: annotated statements over eligible statements — every statement should carry a @@ note saying what it is FOR. Source-only: @@ notes are stripped at compile. (hygiene plane)Put a "@@ why" note directly above each statement ("@@ name: why" also names it).
style · runtime · w0.1Deductions from style/*, prompt/*, spelling/*, grammar/* findings — hedging, vagueness, wordiness, typos — rated per statement. These SHIP: the flagged prose is what the model reads.Commit to modals, delete hedges, and apply the flagged rewrites.
security · runtime · w0.1Deductions from security/* findings — injection-shaped text and credential literals (a leaked secret also caps the grade at F).Remove secrets and injection scaffolding from the prompt; secrets belong in the host environment (@{env.NAME} in tool bindings).
The score gates CI: typeglish score <file> --min B exits non-zero below the floor, and the output names the biggest lever.