UIs that agents can drive and test
Build a window that a coding agent can see, click, and check with no display. The agent writes the script, runs it headless, and reads the result as text or as a picture.

ztk::inject.How it works
ztk --headless runs a script with no display and the CPU renderer, so a window gives the same picture on each platform. Four commands let a script look at the window and drive it:
ztk::treegives each widget with its class, its box, and its map state.ztk::injectsends pointer, key, and text events through the hit test and the focus.ztk::snapshotgives a PNG image of a widget.ztk::debuggives short answers: why a widget looks as it does, what ran for a click, and what changed.
This check script builds a counter, finds the button in the tree, and clicks it. ztk --headless check.tcl prints n = 1:
set n 0
button .go -text Count -command {incr ::n}
label .count -textvariable n
pack .go .count -padx 12 -pady 8
update
foreach row [ztk::tree .] {
lassign $row path class x y w h mapped
if {$path eq ".go"} {
set cx [expr {$x + $w / 2}]
set cy [expr {$y + $h / 2}]
}
}
ztk::inject . motion $cx $cy
ztk::inject . press 1 $cx $cy
ztk::inject . release 1 $cx $cy
update
puts "n = $n"
exit
ztk --mcp app.tcl runs the app headless and serves the answers of ztk::debug as MCP tools. The site has llms.txt, llms-full.txt, and api.json for agents, and the repository has a skill for an agent that builds a ztk app.
ztk code claude shows a coding agent in a window: its terminal on the left, and a panel with its tasks, its changed files, and each tool call on the right. The agent runs in the sandbox of the system by default.
Real today
The commands, the MCP server, and the files for agents are part of ztk. The check script above runs in the tests of this repository.
Links
- For agents: the files, the skill, and the check script.
- Debugging:
ztk::debugand its answers. - ztk::inject, ztk::tree, and ztk::snapshot.
- Claude Code in a window:
ztk code claude. - Agents on the ztcl site:
ztcl codeand the MCP server of ztcl.