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>.
| Facet | What it measures | What raises it |
|---|---|---|
enforceability · runtime · w0.25 | How 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. |
density · runtime · w0.2 | Advisory, 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.2 | Deductions 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.15 | Deductions 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.15 | Statement-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.1 | Deductions 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.1 | Deductions 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.