agent-desktop-ffi

agent-desktop-ffi is a skill for Claude Code, Codex from lahfir/agent-desktop. It costs 111 tokens per session (2,770 once invoked), scanned A, original, Apache-2.0.

A C-compatible interface for controlling agent-desktop through a shared library instead of starting its command-line program for every action.

In plain words
What is it for?
Use it to build and link the library, connect it from another language, inspect desktop state, and perform platform actions.
Why use it?
It lets programs written in languages such as Python, Swift, Go, or C++ call the platform directly while following a defined observe-and-act process.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it to build and link the library, connect it from another language, inspect desktop state, and perform platform actions.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/lahfir/agent-desktop/agent-desktop-ffi
About the project

agent-desktop is a command-line tool that lets AI agents inspect and control desktop applications through operating-system accessibility data instead of screenshots or pixel matching. It is used to automate applications such as Finder, Safari, Xcode, and Slack with structured JSON commands and results.

lahfir/agent-desktop · 1,036 stars · on GitHub

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add lahfir/agent-desktop --skill agent-desktop-ffi
Clone the repo
git clone --depth 1 https://github.com/lahfir/agent-desktop

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for agent-desktop-ffi

README.md
[![agentmods](https://agentmods.dev/badge/skills/lahfir/agent-desktop/agent-desktop-ffi.svg)](https://agentmods.dev/skills/lahfir/agent-desktop/agent-desktop-ffi)
Your own site
<a href="https://agentmods.dev/skills/lahfir/agent-desktop/agent-desktop-ffi"><img src="https://agentmods.dev/badge/skills/lahfir/agent-desktop/agent-desktop-ffi.svg" alt="Measured on agentmods" height="20"></a>
Per session 111 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,770 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00111 $0.02770
Opus 5 $0.00056 $0.01385
Sonnet 5 $0.00022 $0.00554
Haiku 4.5 $0.00011 $0.00277

Measured 7d ago against content hash fe7a1e08c972, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-07, from the pricing page.

Security

Grade A, and why

agent-desktop-ffi scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 7d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/agent-desktop-ffi/SKILL.md · 206 lines

How it starts

The opening of the file, as written. The whole thing — 206 lines — stays where its author put it; the contents beside it link to each section on GitHub.

agent-desktop-ffi

Direct C-ABI access to every PlatformAdapter operation. Build the cdylib with the workspace's release-ffi profile:

cargo build --profile release-ffi -p agent-desktop-ffi

The output is target/release-ffi/libagent_desktop_ffi.dylib (.so on Linux, .dll on Windows) plus a committed C header at crates/ffi/include/agent_desktop.h.

A Python ctypes smoke harness lives at tests/ffi-python/smoke.py and serves as a worked end-to-end example covering the ABI handshake, struct size validation, ad_version, and the snapshot pipeline leg. See tests/ffi-python/README.md for usage.

Four reference topics, loaded as needed:

  • ownership.md — who allocates / who frees, for every *mut T the FFI hands back to the caller.
  • error-handling.md — errno-style last-error contract, enum validation, panic boundary.
  • threading.md — host-thread contract, cross-process mutation serialization, AXIsProcessTrusted inheritance, and adapter-bound native handles.
  • build-and-link.md — ABI handshake, struct size validation, minimal C and Python examples, observe-act workflow, and prebuilt archive locations.

Observe-act workflow (canonical path)

ad_init(AD_ABI_VERSION_MAJOR)                    // verify header ↔ dylib match
adapter = ad_adapter_create_with_session("s1")   // or ad_adapter_create()
rc = ad_snapshot(adapter, "Finder", 0, 10, false, false, &json_out)
// parse json_out: locate snapshot-qualified refs in data.tree
ad_free_string(json_out)
// build action:
AdAction act = {0}; act.kind = AD_ACTION_KIND_CLICK;
rc = ad_execute_by_ref(adapter, "@s8f3k2p9:e5", NULL, &act, 0, &result_out)
ad_free_string(result_out)
ad_adapter_destroy(adapter)

ad_snapshot returns a {version, ok, command, data} JSON envelope identical to the CLI output. The data.tree field contains snapshot-qualified ref IDs for interactive elements. Pass a qualified ref, or a legacy bare ref plus its explicit snapshot_id, to ad_execute_by_ref to drive the pipeline (RefStore load → strict resolution → actionability preflight → dispatch).

Read the full file on GitHub · 206 lines

Files

What ships with it

4 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 7d ago First seen · 206 lines · 111 tokens per session scan A fe7a1e08c972

Subscribe to this mod's changes

agent-desktop-ffi is a skill published in the GitHub repository lahfir/agent-desktop (1,036 stars, last pushed yesterday), licensed Apache-2.0. It adds 111 tokens to every session and 2,770 once invoked, about $0.0006 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.