Skip to content
ƒtsforgev0.52.0
19

Stop bad output early

3 min read

TTSR (tool-text stream rules) watches the model’s output as it streams. If forbidden text appears inside a tool call (for example as any inside an edit payload), tsforge stops generation immediately, sends short correction text, and asks the model to retry.

The bad pattern never lands in your files.

Always on.

RuleBlocksTells the model
no-as-anyas anyuse proper types
no-ts-suppression@ts-ignorefix the real error
no-empty-catchempty catch {}log or handle errors
no-console-logconsole.logremove debug logging

These apply to tool argument text under src/**/*.ts(x). Each rule has a cooldown so one mistake does not loop forever.

Add your own stream rules in .tsforge/rules.json at the project root. They load on top of the built-ins; a custom rule whose name matches a built-in is ignored, so the built-in safety rules always win.

[
{
"name": "no-todo-comment",
"condition": ["//\\s*TODO", "//\\s*FIXME"],
"guidance": "Do not leave TODO/FIXME markers; finish the work or open an issue.",
"scope": "tool-args",
"repeatMode": "cooldown",
"repeatGap": 5,
"fileGlobs": ["src/**/*.ts", "src/**/*.tsx"]
}
]
FieldRequiredNotes
nameyesUnique; duplicates of a built-in are skipped
conditionyesArray of regex sources; matches if any one matches
guidanceyesCorrection text sent to the model on a hit
scopenotool-args, content, or both (default content)
repeatModenoonce (default) or cooldown
repeatGapnoTurns between refires when cooldown
fileGlobsnoRestrict to matching files; omit to apply everywhere

Invalid JSON or invalid regex is skipped silently. On load, tsforge reports how many custom rules were registered.

tsforge also writes its own TTSR rules: failures it made and then fixed in a repo are mined into .tsforge/learned-rules.json and loaded alongside the built-ins and your custom rules. So a mistake the model keeps making gets caught mid-stream next time. Automatically. See Learning from past runs.

  • 3 interrupts per task, then TTSR turns off for the rest of that task

Learning from past runs · Big picture · Environment variables