---
title: "Author a Desktop plugin"
description: "Use Desktop's native UI components, versioned plugin manifest, contextual bridge, and bundled compiler to build interfaces that belong in the app."
slug: "working-with-autohand-code/code/desktop/plugin-authoring"
sidebar:
  label: "Plugin authoring"
---

Use [Create mode](/working-with-autohand-code/code/desktop/creations) for the normal end-to-end workflow. This page explains the files and contracts behind a creation in Desktop 0.10.1.

## Start with the built-in guide

Open **Creations > Developer tools > Plugin Guide & SDK**, or right-click a creation and choose **How creations work**. The guide maps contribution surfaces to the actual app and can start a creation for a selected surface. The generated workspace's `AUTHORING.md` records the supported host API and current build instructions.

Desktop includes the compiler, native components, icons, and offline fonts. The agent calls `autohand_build_creation` with the workspace path to compile and validate the source. That tool is available through Desktop's existing agent gateway during an active turn. It writes the built bundle but does not install or enable it; the user reviews it in Preview.

## Files in a creation

| File | Purpose |
| --- | --- |
| `autohand.plugin.json` | Identity, protocol version, contributions, permissions, and optional settings, commands, or backend tools. |
| `autohand.plugin.build.json` | Frontend and optional backend source entries, with native UI enabled. |
| `src/app.tsx` | Your interface and behavior. |
| `AUTHORING.md` | The host contract and the user's brief. |
| `index.html` | The built, self-contained frontend named by the scaffold's manifest. |

A minimal full-page manifest looks like this:

```json title="autohand.plugin.json"
{
  "apiVersion": 1,
  "id": "my-focus-timer",
  "name": "My focus timer",
  "version": "0.1.0",
  "description": "A private focus timer",
  "frontend": "index.html",
  "ui": "native",
  "permissions": ["context:read", "storage"],
  "contributions": [
    { "id": "main", "surface": "nav-panel", "title": "My focus timer" }
  ]
}
```

Keep the scaffold's generated `id` when editing an existing creation. Changing the name is different from changing its identity.

## Use the actual Desktop components

```tsx title="src/app.tsx"
import {
  React, createRoot, Button, Input, Label
} from '@autohand/desktop-plugin-sdk/ui';

function App() {
  const [task, setTask] = React.useState('');
  const [started, setStarted] = React.useState(false);
  return (
    <main className="ah-page">
      <header className="ah-header">
        <h1 className="ah-title">Focus timer</h1>
        <p className="ah-description">One task at a time.</p>
      </header>
      <section className="ah-section ah-stack">
        <Label htmlFor="task">Your task</Label>
        <Input id="task" value={task}
          onChange={event => setTask(event.target.value)} />
        <Button disabled={!task.trim()} onClick={() => setStarted(true)}>
          Start focus
        </Button>
        {started ? <p role="status">Focus started: {task}</p> : null}
      </section>
    </main>
  );
}

createRoot(document.getElementById('root')).render(<App />);
```

This example demonstrates composition, not a complete timer. Replace the example action with the requested behavior before previewing it.

Use `Button`, `Input`, `Textarea`, `Checkbox`, `Label`, `Separator`, `Disclosure`, and `Icon` from the native entrypoint. Layout helpers include `ah-page`, `ah-header`, `ah-section`, `ah-row`, `ah-stack`, and `ah-muted`. Use the existing compact rows and sections rather than introducing a separate visual system.

Custom layout and data visualizations can use `--background`, `--foreground`, `--muted-foreground`, `--border`, `--primary`, `--secondary`, `--destructive`, `--font-ui-family`, and `--radius`. Do not redefine host tokens or hardcode a new palette or font. Desktop projects the user's live theme independently of the operating system's appearance.

## Context and private state

```ts
import { autohand } from '@autohand/desktop-plugin-sdk/app';

const note = await autohand.storage.get('daily-note');
await autohand.storage.set('daily-note', 'A useful reminder');

const unsubscribe = autohand.onContext(context => {
  // React to the project, thread, message, or file for this mounted surface.
});
// Call unsubscribe when the view no longer needs the listener.
```

Request the corresponding manifest permissions. Check the context's available actions before displaying controls that need a current chat or file. Use supported bridge methods; do not reach into Desktop's DOM or invent a method name.

Prompt commands insert text for review. Backend commands call an explicitly declared method. Open commands navigate inside Desktop. Use the built-in guide and `AUTHORING.md` for the exact current surface names and bridge methods.

## Build, inspect, and install

In Create mode, the selected agent calls the bundled build tool after editing the source. A valid bundle is self-contained, uses the native UI foundation, and no longer contains the starter marker. Desktop then presents its digest and access review in Preview.

For a plugin received from another developer, use **Creations > Developer tools > Install from a folder**, select its source directory, and choose **Review plugin**. Inspect the requested permissions before enabling it. Source changes require another reviewed installation or reload; an invalid update leaves the last working installation available.

Optional Node backends run in a separately supervised process after explicit local-code approval. This process is not an OS sandbox. Keep backend tools typed and narrowly scoped, support cancellation and disposal, and never embed credentials in a manifest or frontend bundle.

## Verify the result

Before sharing a plugin, exercise its controls, keyboard focus, empty states, stored data, and failure behavior. Switch between light, dark, and a custom Desktop theme without losing drafts. Reload the app and confirm persistence. Test disabling, re-enabling, and updating the creation while preserving its identity and saved information.
