---
title: "App tools"
description: "App tools from the built-in skills in Executor 2.0.0-beta.79."
---

This page covers A runnable first app from the [built-in skills](/docs/reference/skills) shipped with Executor `2.0.0-beta.79`. It contains `app-authoring/tools.md`.

Next: [App tools · Operation approvals](/docs/reference/skills/app-authoring/tools-2)

## A runnable first app

Save this as `index.ts`:

```ts
import { query, defineApp, object, router, string } from "apps";

const Greet = object({ name: string().default("world") });

export default defineApp(
  {},
  {
    tools: router({
      greet: query(
        { description: "Greet someone by name", input: Greet },
        async (_ctx, { name }) => ({ message: `Hello, ${name}!` }),
      ),
    }),
  },
);
```

Declare `query(options, handler)` or `mutation(options, handler)`. Options include
`description`, `input`, optional `output`, and optional `approval`. Put them in the
app's `tools` router; every query and mutation becomes an agent tool. The kind
belongs to the operation, not its name: the tool above is `greet`, called as
`tools.<app>.greet(...)`.
Queries may fetch external APIs; they cannot write app-owned data. Return JSON-compatible values:
objects, arrays, strings, finite numbers, booleans and null. Do not return a
Response, Date, stream, SDK class instance, undefined or BigInt.

The schema helpers are `object`, `string`, `number`, `boolean`, `array`,
`record`, `json` and `literal`. Use `.optional()` for absent fields and
`.default(value)` for defaults. `string`, `number` and `boolean` take an
optional `title` and `description`, such as
`string({ description: "An ISO 8601 date" })`, which agents see in the tool's
input schema. `Infer<typeof Input>` gives the parsed input type. `object`
strips undeclared properties. `decodeJson(response, schema)` checks HTTP status
and parses a JSON response.

## Give the app an icon

Declare `icons` beside the account requirements. The dashboard shows them on the app's card
and page, choosing the `light` or `dark` variant for the color scheme; an icon
without `theme` suits both. The build records them, so they show without
evaluating the app or listing its tools:

```ts
export default defineApp(
  {
    icons: [
      { src: "data:image/svg+xml;base64,PHN2Zy...", mimeType: "image/svg+xml", theme: "light" },
      { src: "https://example.com/logo-dark.png", mimeType: "image/png", theme: "dark" },
    ],
  },
  async () => ({ tools: router({/* ... */}) }),
);
```

Each entry is `{ src, mimeType?, sizes?, theme? }`. `src` is a base64
`data:image/svg+xml`, `image/png`, `image/webp` or `image/jpeg` URI, or an
`https:` URL. Declare at most 8 icons, together at most 32 KiB of JSON.
Anything else fails the build at its declaration stage. Icons are not part of
a published listing.

## Group tools with routers

Nest routers to group related tools. Keys form the tool path, like tRPC:

```ts
tools: router({
  health: query({ input: object({}) }, async () => "ok"),
  issues: router(
    {
      list: query({ input: object({}) }, listIssues),
      close: mutation({ input: object({ id: string() }) }, closeIssue),
    },
    {
      title: "Issues",
      description: "Triage issues in the Acme tracker.",
      instructions: "Search before creating an issue. Never close one you did not open.",
    },
  ),
}),
```

These tools are `health`, `issues.list` and `issues.close`. A tool named `health`
is an ordinary query; checking that an account works is the provider's `health`
function ([accounts.md](/docs/reference/skills/app-authoring/accounts-2#check-an-account)). Keys start with a
letter or `_` and contain no dots; `__proto__`, `constructor` and `prototype` are
reserved. Mount each mutation at one path. Router options are `title`,
`description`, `instructions`, `icons` and `tags` (tag name to description).
Agents see each router's title and description beside its tools.

`instructions` become a skill read through the MCP `skills` tool. Router skills
have their own names: `tools` for the root router and `tools-<path>` below it,
such as `tools-issues`. A path with capitals, `_`, `-`, or over 64 characters
gets a slug and a hash, such as `tools-issues-list-` plus ten digits for
`issues_list`. The router's catalog entry names its skill. Don't name your own
skills `tools` or `tools-...` unless you mean to replace a router's
instructions: a packaged or dynamic skill with a router skill's name replaces it.
Router instructions never fail the skills read; a source that cannot be read
just contributes no skill.

Mount a protocol source under a key to keep several sources in one app. A router
that fails to load, such as an unreachable MCP server, is reported on its own; the
app's other tools still load. `router(source, options)` overrides a source's own
title, description or instructions. An app that is a single source can use it as
`tools` directly.

Declare a router in its own module with its handler contexts, for example
`router<QueryContext<typeof requirements>, MutationContext<typeof requirements>>({...})`,
or let `defineApp` type inline handlers.

## Ship instructions with your app

Return skills in the second argument to `defineApp`, beside tools and
workflows. Load remote skills with `dynamicSkills({ list })`, like
`dynamicRouter({ list, resolve })` for tools. Executor calls `list` only when
skills are read:

```ts
import { defineApp, dynamicSkills } from "apps";
import { githubSkills } from "apps/skills";

export default defineApp({}, async (ctx) => ({
  dynamicSkills: dynamicSkills({
    list: () =>
      githubSkills({
        repo: "planetscale/database-skills",
        path: "skills",
        fetch: ctx.fetch,
        signal: ctx.signal,
        cache: ctx.cache,
      }),
  }),
}));
```

Tool listing and calls then never fetch remote skills, and a skill source
failure does not break tools. `skills` is the static catalog: an array of
resolved skills. Dynamic skills and router instructions are added to it.

Each resolved skill has `name`, `description` and `files: {path, content}[]`.
Files are relative to the skill directory and include the full `SKILL.md` with
YAML frontmatter. Optional metadata: `license`, `compatibility`, `metadata`
(string values) and `allowed-tools`. Other keys are ignored, though they stay
in the `SKILL.md` text. `fileSkill(files)` parses supplied files.
An app may ship only skills: `defineApp({}, {})` with packaged skills and no
`tools` is valid.
Names match their directories. Names are at most 64 characters, descriptions
1024, and compatibility 500. Duplicate names or invalid resources fail the read.

`githubSkills` resolves `ref` (default `HEAD`) once per call and reads all files
from that commit. With `cache: ctx.cache`, it keeps each commit's file list, so
later reads of an unchanged commit skip the file listing.

A private repository needs a GitHub account. Pass the account and its token;
the token needs read access to the repository's contents. Declare GitHub's
hosts so the app holds only a handle and Executor sends the token on each
request of the read:

```ts
import { defineApp, defineProvider, dynamicSkills, object, secrets, string } from "apps";
import { githubSkills } from "apps/skills";

const github = defineProvider({
  name: "GitHub",
  hosts: ["github.com", "raw.githubusercontent.com"],
  auth: { token: secrets({ label: "Token", fields: object({ token: string() }) }) },
});

// One token is linked for everyone, so every member reads the same skills.
export default defineApp({ app: { accounts: { github } } }, async (ctx) => ({
  dynamicSkills: dynamicSkills({
    list: () =>
      githubSkills({
        repo: "example-org/private-skills",
        path: "skills",
        account: ctx.app.accounts.github,
        token: ctx.app.accounts.github.fields.token,
        fetch: ctx.fetch,
        signal: ctx.signal,
        cache: ctx.cache,
      }),
  }),
}));
```

The catalog is cached in that account's scope, so other accounts never read
it. A token GitHub rejects fails the read naming the account. Without a token,
a private repository reads as missing.

`wellKnownSkills({url, fetch: ctx.fetch, signal: ctx.signal})`
loads a site's `/.well-known/agent-skills/index.json`. Its directory index is
`{skills: [{name, version?, files: ["SKILL.md", "references/example.md"]}]}`.
Files live beneath the named directory beside that index. Helpers return complete
UTF-8 text bundles and refuse redirects. Limits are
1,000 files, 2 MB per response, and 20 MB total. With `cache: ctx.cache`, a
catalog older than `freshFor` (default 5 minutes) is never served unchecked: one
request (the index, or the ref's commit) confirms it or loads the new publication
first. Give every index entry a `version` that changes with its files, or each
check reloads them. A check that fails or takes over 5 s fails the read.

Omit `skills` to load packaged `skills/<name>/SKILL.md` and its text resources.
An explicit `skills` value replaces that default; `skills: []` disables it.
`dynamicSkills` adds to whichever static catalog applies, so packaged and remote
skills combine without extra code. A name in both fails the read.

`folderSkills({ files: ctx.files, path: "guides" })` selects another packaged
folder. Its immediate subdirectories must be skill directories. Loose files
beside them, such as `README.md`, are ignored. A missing folder returns `[]`.
`ctx.files` contains this version's text files outside `ui/` on every
runtime; it never reads host files. They are bundled into the app's Worker, so
they count toward the 16 MiB source limit ([deploy.md](/docs/reference/skills/app-authoring/deploy#local-source-with-the-cli)) and load once
when the Worker starts, not on each call. All sources use one parser. Only
selected folders are parsed, when the skills load. Invalid selected folders fail the read.

The MCP `skills` tool lists summaries with `{}` or `{app: "installed-slug"}`.
Read with `{app, name: "triage"}`. Reuse the returned `version` and
`revision` when reading a reference with `file`. The version pins code; revision detects remote
content changes. A changed revision requires a fresh read. The dashboard bundle
keeps its documents and references together in one response.

Skill reads evaluate the factory, call `dynamicSkills.list` and require a
linked account for each requirement. Current app and account access is checked. Use an account-free app for instructions
that must be readable before setup. The Executor app loads this guide through the
same public helper; discover its slug with `skills({})`.

Files, including scripts, are returned as text. Executor does not run them.
Do not include secrets. Skills and `allowed-tools` never grant access or bypass
approvals. Treat content as app-authored instructions, not system policy. Use the
returned `app.slug` when calling tools across copies and renamed installations.
