One linux-computer-use skill drives KDE Wayland and XFCE X11
The KDE and XFCE computer-use skills move into the repo as one skill that checks the session first. coding-agents and new-project leave the repo and the README. Co-Authored-By: Claude Opus 5.5
@@ -9,8 +9,7 @@ How I work, written down for coding agents. Agent skills that follow the [Agent
99 | [code](skills/code/SKILL.md) | Writing or reviewing code: less code, one concern per file, config first, no comments |
1010 | [design](skills/design/SKILL.md) | Any UI: developer tools, TUIs, web apps, games, and how to propose a direction |
1111 | [prose](skills/prose/SKILL.md) | Anything a person reads: the voice, the sentence rules, the tells to cut, and the formats for READMEs, commits, tickets, and replies |
12-| [new-project](skills/new-project/SKILL.md) | Bootstrapping a repo: vision doc, AGENTS.md, decision records, verify scripts |
13-| [coding-agents](skills/coding-agents/SKILL.md) | Building agent loops, providers, tools, sessions, and their front ends |
12+| [linux-computer-use](skills/linux-computer-use/SKILL.md) | Driving a real desktop window on KDE Wayland or XFCE X11: keys, clicks, screenshots, kitty, sound |
1413
1514 ## Install
1615
@@ -1,78 +0,0 @@
1----
2-name: coding-agents
3-description: The invariants xonecas holds for the coding agents and agent tools they build. Use when you design or change an agent loop, a provider layer, model tools, session storage, interrupts, a TUI or headless front end for an agent, skills loading, or subagents.
4----
5-
6-# Build a coding agent
7-
8-The user has built this many times: mini-coder in TypeScript, mini-coding-agent in Zig, tiny-c-agent in C, potatoz, termite, shoot, orc, and the rat family. These are the decisions that kept surviving. The project's design doc wins where it differs.
9-
10-Above all, the agent is minimal and transparent, and the user stays in control.
11-
12-## The loop
13-
14-- No loop limits. No turn cap, tool-call cap, token budget, or timeout imposed by the agent. The user's interrupt is the limit.
15-- No hidden work. The loop adds no reminders, hidden blocks, or meta-messages between steps.
16-- Provider errors surface as they are, never masked or summarized.
17-- A failed request is a rolled-back transaction. It never enters the context or the log, so the user retries by resending the turn unchanged.
18-- The default is no compaction and no automatic retries. A design that wants them says so, and records what it keeps, for example raw events kept in storage while the prompt is compacted.
19-
20-## Interrupts
21-
22-- **Esc** pauses politely at the next step boundary.
23-- **Esc** again while pausing, or **Ctrl+C**, cancels the turn. That aborts the request, kills each tool's process group, kills child agents from the bottom up, and records an aborted result.
24-- **Ctrl+C** on an idle input clears the draft. **Ctrl+D** on an empty draft exits.
25-- Completed side effects are never undone.
26-- A steering message sent during a turn waits in a queue, and joins the conversation at the next step boundary.
27-
28-## Context
29-
30-- The model sees the configured system prompt, plus the resource files the user opted into: `AGENTS.md` files and the skill index.
31-- Keep the prompt cache-friendly. Put stable content first, and keep tool schemas deterministic.
32-- Skills follow the Agent Skills spec. Index each skill by name and description, load the body on request, and load it once per session.
33-- Reasoning text can be stored, but it is not sent back to the provider.
34-
35-## Tools
36-
37-Keep few tools, and pick one of two designs:
38-
39-- **Three tools:** `read`, `edit`, and `bash`.
40-- **One code tool:** `execute(script)` or `code(script)`, which runs JavaScript in QuickJS. It binds the file, shell, skill, todo, ask, task, and MCP calls. Never add `read`, `edit`, or `bash` beside it.
41-
42-Tool arguments are untrusted. Validate them once, at the boundary. Generate the description the model sees from the binding table, because a binding the model can't see is a bug. Return the applied diff from an edit.
43-
44-## Permissions
45-
46-None. No sandbox and no permission layer. Tools run with the user's permissions. Isolation is the environment's job: `nono`, a container, a VM, or a remote box.
47-
48-## Providers
49-
50-- Providers are data. Implement each wire protocol once, such as `openai-completions`, `openai-responses`, `anthropic-messages`, and Google's. Each model names its protocol, base URL, and headers. The code has no branches for a specific provider.
51-- Generate the model catalog from models.dev with a script, and trim it to the models that the available keys reach.
52-- Record token counts, cache hits, and cost for every turn.
53-- Start with one curated model, and widen the list only by the user's decision.
54-
55-## Sessions
56-
57-- A session is an append-only log, fsynced on write. Never rewrite or delete a committed line. A failed write stops the turn.
58-- JSONL with one message per line is the default. SQLite is for trees of sessions, such as forks and subagents, or for large volume. Store each request and tool call as an intent and a resolution, and close open intents after a crash.
59-- The provider request is a fold over the log.
60-
61-## Front ends
62-
63-- The agent core never imports a front end. A TUI, a headless mode, and a server are projections of one event stream. They own no agent, provider, or tool logic.
64-- A headless mode is a well-behaved Unix tool, and its output is a plain log.
65-- A TUI follows the terminal rules in the **design** skill: scrollback first, a live region, and counted event markers.
66-- Diagnostics stay local. No telemetry.
67-
68-## Config
69-
70-The order of precedence is `--flag`, then `$VAR`, then a config key under XDG paths. Prefer global config. Add project-local config only when the design asks for it.
71-
72-## Subagents
73-
74-Subagents go one level deep, through `task()`. Define each one as a Markdown file in `.agents/agents/<name>.md`. Frontmatter sets the model and the effort, and the body is its system prompt. A subagent has no `task()` of its own. Parallel subagents work in separate git worktrees.
75-
76-## Verify
77-
78-Run against the real provider with the cheapest model that exercises the path, in a real kitty window, through the **verification** skill. No mock providers and no replay files.
@@ -0,0 +1,144 @@
1+---
2+name: linux-computer-use
3+description: Interact with a Linux desktop as a user would, on KDE Plasma under Wayland or XFCE under X11. Use it to test and verify GUIs and TUIs in a real window: find and focus windows, press keys, click, take screenshots, drive kitty, and measure sound.
4+---
5+
6+# Control a Linux desktop
7+
8+The user shares this desktop. Warn them before you start, touch only the windows you opened, and close only those. Keep screenshots and sockets in `/tmp/computer-use`.
9+
10+## Know the session first
11+
12+```bash
13+echo "$XDG_SESSION_TYPE $XDG_CURRENT_DESKTOP"
14+```
15+
16+- `wayland KDE`: use KWin's D-Bus, `scripts/key.py` and Spectacle. `xdotool`, `wmctrl` and `maim` cannot reach native Wayland windows.
17+- `x11 XFCE`: use `wmctrl`, `xdotool`, `xwininfo` and `maim`.
18+
19+A shell outside the GUI may report `tty` and an empty `DISPLAY`. On X11, export `DISPLAY=:0` before any X11 command.
20+
21+## KDE Plasma on Wayland
22+
23+### Find a window
24+
25+Search by title. Each row starts with the window's match id, `0_{uuid}`:
26+
27+```bash
28+busctl --user call org.kde.KWin /WindowsRunner org.kde.krunner1 Match s rats
29+```
30+
31+Read a window's size, position, `pid` and `desktopFile`, which is its Wayland app id:
32+
33+```bash
34+qdbus6 org.kde.KWin /KWin org.kde.KWin.getWindowInfo '{uuid}'
35+```
36+
37+Two windows can share a title. Tell yours from the user's by `pid`.
38+
39+### Press keys and click
40+
41+`scripts/key.py` focuses the window, then runs each step. A step is a combo or key name (`alt+o`, `ctrl+v`, `enter`, `space`, `down`), `click:X,Y` or `move:X,Y`, or text in lowercase letters, digits and spaces. Pass the uuid with its braces. Coordinates are global, so add the window's `x` and `y`:
42+
43+```bash
44+python3 ~/.claude/skills/linux-computer-use/scripts/key.py '{uuid}' click:1180,422 alt+o radio enter
45+```
46+
47+It stops if the window loses the focus before a step, so nothing lands in another window. It needs write access to `/dev/uinput` and `python-evdev`. It moves the user's real pointer, and each run takes the focus from them.
48+
49+Count volume or list steps from a known state, and check the result in a screenshot. A miscount looks like a bug.
50+
51+### Take a screenshot
52+
53+The user keeps working, so the active window may be theirs by the time you capture. Focus yours in the same command, with no wait between. Read the image, and delete it at once if it shows anything but your window:
54+
55+```bash
56+python3 ~/.claude/skills/linux-computer-use/scripts/key.py '{uuid}' && spectacle --background --nonotify --activewindow --output /tmp/computer-use/shot.png
57+```
58+
59+Spectacle takes a moment after it returns: wait for the file, then read it.
60+
61+## XFCE on X11
62+
63+The screen is `1280x800`. The top panel covers `y=0` to `y=27`, and the bottom panel covers `x=487` to `x=793` from `y=751` down. Place windows between `y=27` and `y=750`.
64+
65+### Find, focus, move and close windows
66+
67+`wmctrl`, `xdotool`, `xwininfo -id` and `maim -i` accept hex or decimal window ids.
68+
69+```bash
70+wmctrl -lpGx
71+```
72+
73+lists each window's id, workspace, pid, geometry, class and title. Launch an app and wait for its window:
74+
75+```bash
76+nohup kitty >/dev/null 2>&1 &
77+APP_PID=$!
78+for i in {1..30}; do
79+ WIN_ID=$(xdotool search --onlyvisible --pid "$APP_PID" 2>/dev/null | head -n1)
80+ [ -n "$WIN_ID" ] && break
81+ sleep 0.1
82+done
83+```
84+
85+Then:
86+
87+```bash
88+xdotool windowactivate --sync "$WIN_ID"
89+wmctrl -ir "$WIN_ID" -e 0,80,60,800,500
90+xwininfo -id "$WIN_ID"
91+wmctrl -ic "$WIN_ID"
92+```
93+
94+focus it, move and resize it, read its geometry and map state, and close it through the window manager.
95+
96+### Press keys and click
97+
98+```bash
99+xdotool getmouselocation --shell
100+xdotool mousemove --sync 300 250 click 1
101+xdotool mousemove --sync 300 250 mousedown 1 mousemove --sync 500 250 mouseup 1
102+xdotool type --delay 20 "echo 'hello world'"
103+xdotool key Return
104+xdotool key ctrl+shift+enter
105+```
106+
107+Button `1` is left, `2` middle, `3` right, `4` scroll up, `5` scroll down. Focus your window first: keys go to whatever has the focus.
108+
109+### Take a screenshot
110+
111+`maim` draws the pointer by default. Leave out `-u` when you need to check where the pointer is.
112+
113+```bash
114+maim /tmp/computer-use/desktop.png
115+maim -i "$WIN_ID" /tmp/computer-use/window.png
116+maim -g 800x500+80+60 /tmp/computer-use/region.png
117+```
118+
119+## Drive a TUI in kitty
120+
121+Remote control is off in `~/.config/kitty/kitty.conf`, so turn it on at launch with a unique socket:
122+
123+```bash
124+SOCK=/tmp/computer-use/kitty-$(date +%s)-$$.sock
125+nohup kitty -o allow_remote_control=yes --listen-on "unix:$SOCK" >/dev/null 2>&1 &
126+kitten @ --to "unix:$SOCK" ls
127+kitten @ --to "unix:$SOCK" send-text "ls -la\r"
128+kitten @ --to "unix:$SOCK" get-text
129+```
130+
131+A launch that returns 0 proves nothing about the socket: `ls` through it does. The config also matters on XFCE:
132+
133+- `initial_window_width 120c` and `initial_window_height 40c` open kitty at `1227x1067`, past the bottom of the screen. Resize it after launch.
134+- `hide_window_decorations yes` removes the titlebar. Move kitty with `wmctrl -ir`, not by dragging.
135+
136+## Hear what a window plays
137+
138+You cannot hear it, so measure it. Record the sink's monitor, which is what actually reaches the sink, before the sink's own volume. It holds every app's sound, so first check that only yours is playing:
139+
140+```bash
141+timeout 4 pw-record -P '{ stream.capture.sink=true }' --target <sink-node-name> --rate 48000 --channels 2 --format s16 /tmp/computer-use/out.wav
142+```
143+
144+Prove the monitor reads with a quiet control tone from `pw-play`. Recording a stream's node directly misleads: it read sound from a stream the speakers never got. A stream in `running` state and moving bars do not prove sound.
@@ -0,0 +1,96 @@
1+#!/usr/bin/env python3
2+import subprocess
3+import sys
4+import tempfile
5+import time
6+
7+from evdev import UInput, ecodes as e
8+
9+NAMES = {"alt": "LEFTALT", "ctrl": "LEFTCTRL", "shift": "LEFTSHIFT", "super": "LEFTMETA", "esc": "ESC"}
10+KEYS = {"enter", "space", "tab", "esc", "up", "down", "left", "right", "backspace"}
11+SCRIPT = 'print("%s " + workspace.cursorPos.x + " " + workspace.cursorPos.y + " " + (workspace.activeWindow ? workspace.activeWindow.internalId : ""));'
12+
13+
14+def qdbus(path, method, *args):
15+ return subprocess.run(["qdbus6", "org.kde.KWin", path, method, *args], check=True, capture_output=True, text=True).stdout.strip()
16+
17+
18+def state():
19+ token = f"KDECU{time.time_ns()}"
20+ since = int(time.time()) - 1
21+ with tempfile.NamedTemporaryFile("w", suffix=".js") as script:
22+ script.write(SCRIPT % token)
23+ script.flush()
24+ number = qdbus("/Scripting", "org.kde.kwin.Scripting.loadScript", script.name, "kdecu")
25+ qdbus(f"/Scripting/Script{number}", "org.kde.kwin.Script.run")
26+ qdbus("/Scripting", "org.kde.kwin.Scripting.unloadScript", "kdecu")
27+ for _ in range(40):
28+ log = subprocess.run(["journalctl", "--user", "--since", f"@{since}", "-o", "cat", "--grep", token], capture_output=True, text=True).stdout
29+ if token in log:
30+ _, x, y, *window = log.strip().splitlines()[-1].split()
31+ return int(x), int(y), window[0] if window else ""
32+ time.sleep(0.05)
33+ raise SystemExit("key.py: KWin did not answer")
34+
35+
36+def code(name):
37+ return getattr(e, "KEY_" + NAMES.get(name, name).upper())
38+
39+
40+def press(device, codes):
41+ for key in codes:
42+ device.write(e.EV_KEY, key, 1)
43+ device.syn()
44+ time.sleep(0.03)
45+ for key in reversed(codes):
46+ device.write(e.EV_KEY, key, 0)
47+ device.syn()
48+ time.sleep(0.03)
49+
50+
51+def travel(device, axis, distance):
52+ for _ in range(abs(distance) // 2):
53+ device.write(e.EV_REL, axis, 2 if distance > 0 else -2)
54+ device.syn()
55+ time.sleep(0.008)
56+
57+
58+def move(device, x, y):
59+ for _ in range(6):
60+ here_x, here_y, _window = state()
61+ if abs(here_x - x) <= 3 and abs(here_y - y) <= 3:
62+ return
63+ travel(device, e.REL_X, x - here_x)
64+ travel(device, e.REL_Y, y - here_y)
65+ time.sleep(0.05)
66+ raise SystemExit(f"key.py: the pointer stopped at {state()[:2]}, not {x},{y}")
67+
68+
69+def main():
70+ window, steps = sys.argv[1], sys.argv[2:]
71+ capabilities = [v for k, v in vars(e).items() if k.startswith("KEY_") and isinstance(v, int) and v < 249]
72+ events = {e.EV_KEY: capabilities + [e.BTN_LEFT], e.EV_REL: [e.REL_X, e.REL_Y]}
73+ with UInput(events, name="linux-computer-use") as device:
74+ time.sleep(0.6)
75+ subprocess.run(
76+ ["busctl", "--user", "call", "org.kde.KWin", "/WindowsRunner", "org.kde.krunner1", "Run", "ss", f"0_{window}", ""],
77+ check=True,
78+ )
79+ time.sleep(0.2)
80+ for step in steps:
81+ if state()[2] != window:
82+ raise SystemExit(f"key.py: {window} lost the focus, stopped before {step}")
83+ if step.startswith(("move:", "click:")):
84+ action, place = step.split(":")
85+ move(device, *map(int, place.split(",")))
86+ if action == "click":
87+ press(device, [e.BTN_LEFT])
88+ elif "+" in step or step in KEYS:
89+ press(device, [code(part) for part in step.split("+")])
90+ else:
91+ for char in step:
92+ press(device, [e.KEY_SPACE if char == " " else code(char)])
93+ time.sleep(0.05)
94+
95+
96+main()
@@ -1,86 +0,0 @@
1----
2-name: new-project
3-description: Start or restructure a project the way xonecas sets them up. Use when you bootstrap a new repo, write or trim an AGENTS.md or CLAUDE.md, add a design doc or a decision record, set up verify scripts, or pin a toolchain.
4----
5-
6-# Start a project
7-
8-A project starts with the user's vision doc, and grows one verified step at a time.
9-
10-## The vision doc is the user's
11-
12-The user writes `<project>.md`, as in `cast.md`, `shoot.md`, or `minimal-termite.md`. It says what the thing is, how it should feel, the invariants, the tech, and references to other tools. It is the source of truth, and agents never edit it.
13-
14-If the user asks for a longer design, write `DESIGN.md` or `SPEC.md` beside the vision doc, from the user's words only, one question at a time. Every change to the design needs the user's decision.
15-
16-The chain of truth is the user, then the design doc, then the vision doc, then the code. Keep it to one chain. A second design doc that agents wrote is drift, and it goes.
17-
18-Spikes come early and teach what the API needs. Keep them while they help, but they never overrule the vision doc.
19-
20-## AGENTS.md stays short
21-
22-Write `AGENTS.md`, and make `CLAUDE.md` a symlink to it, or the reverse. Often one or two lines are enough: the vision doc is the source of truth, and here is how to build and verify. Every line costs context in every session. "If a fact can be learned by reading the code, it does not belong here."
23-
24-```markdown
25-# <project>
26-
27-<One or two sentences: what it is, and its parts.> `<project>.md` holds the user's vision. Read it first, and never edit it.
28-
29-## Guardrails
30-
31-- <Invariant, stated as a fact.>
32-- Ask before adding a dependency.
33-- Do not add comments.
34-- Do not add scope. If that blocks, stop and report.
35-
36-## Verification
37-
38-- `scripts/verify` runs the format, lint, and test gates.
39-- <How to prove the change in the real product: the window, the script, the provider, and the model.>
40-- <The names of the environment variables that hold the keys. Never their values.>
41-
42-## Git
43-
44-- <The commit style, and whether a remote exists.>
45-```
46-
47-- A rule that a tool enforces can go in a table with two columns, the rule and what enforces it. A rule with nothing to enforce it is a request.
48-- The file describes the repo only. It makes no claims about the machine.
49-- Don't copy rules from a skill into it. Link the skill.
50-
51-## Decision records
52-
53-Put accepted decisions in `docs/<topic>.md`. Each file covers one decision:
54-
55-```markdown
56-# <Decision as a title>
57-
58-Date: YYYY-MM-DD
59-
60-## Context
61-## Decision
62-## Consequences
63-## References
64-```
65-
66-Measure before you decide, and put the measurement in Context. For example: "`ssh localhost 'sleep 60'` left no `sleep` process two seconds after the client was killed."
67-
68-## Scaffolding
69-
70-- Pin the toolchain from day one with `rust-toolchain.toml`, the minimum Zig version, or the `go` line.
71-- Add `scripts/verify` before the first feature. It runs the format, lint with warnings as errors, and the tests.
72-- Add a smoke script that sends one real request through the real binary.
73-- Measure performance from the first commit. Write the benchmark before you have something to optimize.
74-- If the project uses tickets, keep them in `tickets/` as Markdown, worked with the `rats` skill.
75-- Add a secrets hook that refuses commits containing keys, and set `git config core.hooksPath scripts/hooks`.
76-- Run `git init` with no remote. The user adds one when the project is ready.
77-- The README says how to build, how to run, and the URL to open. Nothing more until there is a product to describe.
78-- Clone, build, install. A new user runs one command for each, with nothing to fix by hand.
79-
80-## Port before you write
81-
82-Most new projects descend from an earlier one, such as mini-coding-agent, orc, shoot, rats, or termite. Copy what already works into the new repo, and own it from then on. Don't edit the source project. Don't carry over its scope.
83-
84-## Grow in proven steps
85-
86-Work in small steps that can each be proven. Each step ends working in the real product, and is checked with the **verification** skill before the next one starts.
@@ -26,7 +26,7 @@ Unit tests are for local behaviour, such as a parser or a fold. Behaviour that w
2626 | --- | --- |
2727 | CLI, headless | A plain shell run. Check the exit code. Check that stdout is clean when piped, with no escape sequences and no logs. |
2828 | TUI | A real kitty window, driven through its control socket. Read back the text and take screenshots. |
29-| Desktop GUI | The computer-use skill for the desktop, either **xfce-computer-use** or **kde-computer-use**. Take screenshots and recordings. |
29+| Desktop GUI | **linux-computer-use**. Take screenshots and recordings. |
3030 | Web | **agent-browser** or a real desktop browser. |
3131 | Daemon, server | A script that drives the real wire on a temporary home. |