# What Is an Automation in Type.com?

> An automation is a workflow that Type.com runs for a Space. A trigger starts each run, and each run can use code, a managed agent, skills, and a sandbox.

Canonical page: https://docs.type.com/automations/overview/

An **automation** is a workflow that Type runs for a Space. A trigger starts each run: a schedule, a Slack message, a GitHub event, a Linear change, a webhook, an email, or a feed item. You do not run servers, queues, or schedulers. Type runs the work, keeps the history, and stops the automation when a run fails.

With automations, you can:

- **Run on a schedule**, from every minute to once a month.
- **React to events** from Slack, GitHub, Linear, email, RSS, and any service that sends webhooks.
- **Read and write data** in connected apps, with the Space's connections.
- **Give a step to the managed agent** when the step needs judgment, and get a typed result back.

## What you can build

**Monitor production**

Check the database, logs, and Sentry every 15 minutes. An agent investigates new signals. [Example](https://docs.type.com/automations/examples/security-monitor/index.md)

**Turn bugs into fixes**

File a Linear story for each bug in Slack, and open a fix pull request. [Example](https://docs.type.com/automations/examples/bug-reports-to-fixes/index.md)

**Harden your code**

Audit the code each morning and fix the most severe finding. [Example](https://docs.type.com/automations/examples/security-audit-fix/index.md)

**Write reports**

Write daily release notes with the team's skill. [Example](https://docs.type.com/automations/examples/release-notes/index.md)

## Two ways to build

| | Instruction automation | Code automation |
| --- | --- | --- |
| You write | What you want, in plain words | TypeScript stages |
| Each run | The managed agent follows your instructions | Code stages run your logic. Agent stages give a step to the managed agent. |
| Best for | Research, writing, and decisions | Fixed rules, filters, and writes that must happen the same way each time |
| Cost | AI usage on each run | Low. AI usage only in agent stages and AI filters. |
| Make it | Ask Type in a Space | Deploy with Type CLI, or ask Type to write it |

Start with instructions. When part of the job becomes a fixed rule, move that part into a code stage, and keep an agent stage for the part that needs judgment.

In Type.com's [recurring automation benchmark](https://type.com/benchmarks/recurring-automations), automations that saved each task's repeatable steps as code finished repeat runs of 250 business tasks from Zapier's AutomationBench 30.6× faster than fresh Claude Code sessions at the median, with 96.8% less model spend and no loss in accuracy. Both used Claude Opus 5.5.

## How a code automation works

A code automation is one TypeScript file that default-exports `automation({ output, deployment, stages })`. This one runs every weekday morning: code starts the run, the managed agent writes a summary, and code posts it.

```mermaid
flowchart LR
  weekdayMorning(["weekdayMorning · schedule"])
  start["start · code"]
  summarize{{"summarize · agent"}}
  post["post · code"]
  weekdayMorning -->|entry| start
  start -->|next| summarize
  summarize -->|onResult| post
```

```ts title="src/main.ts"
import {
  agent,
  agentResult,
  automation,
  code,
  complete,
  next,
  recurringEventSchema,
} from "@type-dot-com/sdk/automations";

// Replace with the ID of your Space.
const spaceId = "ch_example";

// What the agent stage gets, and what it must submit.
const day = z.object({ date: z.string() });
const summary = z.object({ text: z.string().min(1).max(2000) });

export default automation({
  // 1. The result of a finished run.
  output: z.object({ messageId: z.string() }),

  // 2. What starts a run, and the first stage that runs.
  deployment: {
    subscriptions: {
      weekdayMorning: {
        title: "Open work summary",
        description: "Summarize open work every weekday at 9:00",
        source: {
          kind: "recurring",
          schedule: {
            kind: "cron",
            expression: "0 9 * * 1-5",
            timezone: "America/New_York",
          },
        },
        entry: "start",
      },
    },
  },

  // 3. The steps of a run, in the order that they run.
  stages: {
    // Code: pass today's date to the agent.
    start: code({
      input: recurringEventSchema,
      transitions: ["summarize"],
      run({ input }) {
        return next("summarize", { date: input.scheduledAt.slice(0, 10) });
      },
    }),

    // Agent: read the Space's open threads and write a summary.
    summarize: agent({
      input: day,
      output: summary,
      instructions: "Summarize the open work in this Space in five bullets or fewer.",
      onResult: "post",
    }),

    // Code: post the summary in the Space.
    post: code({
      input: agentResult({ input: day, output: summary }),
      transitions: [],
      async run({ ctx, input }) {
        const sent = await ctx.write.sendMessage(
          { channelId: spaceId, content: input.result.text },
          { effectKey: `open-work:${input.taskInput.date}` },
        );
        if (sent.isErr()) {
          return err(sent.error);
        }

        return complete({ messageId: sent.value.messageId });
      },
    }),
  },
});
```

Once you deploy, Type.com takes over:

- **Subscriptions** start runs. Each one names its trigger and its **entry stage**.
- **Code stages** run your TypeScript in an isolated VM. They reach apps and the sandbox only through `ctx`.
- **Agent stages** give one step to the managed agent. Type checks the agent's result against the `output` schema. The result completes the run when `onResult` is omitted, or starts the named stage.
- **Ask stages** pause for a person’s answers, then continue at `onResult`.
- **Run history** records the output, the stages, and any errors of each run.

| Concept | What it is |
| --- | --- |
| **Automation** | One workflow in a Space. One `automation(...)` definition. |
| **Subscription** | A trigger, and the entry stage that it starts. An automation has one or more. |
| **Stage** | One step of a run: a code, agent, or ask stage. |
| **Decision** | What a code stage returns: `next(stage, input)`, `complete(output)`, or `blocked(reason)`. |
| **`ctx`** | What a code stage uses to read, write, call tools, and save state. |
| **Run** | One trigger, from the entry stage to `complete()`, `blocked()`, or a terminal agent result. |

Read [Core concepts](https://docs.type.com/automations/how-it-works/index.md) for the full model.

## What Type does for you

- **Runs the triggers.** Type.com keeps schedules, receives events, and filters them before your code starts.
- **Gives access safely.** A run uses the Space's connections and acts as the person who created the automation. Code never sees a credential.
- **Keeps history.** Each run records its output, its stages, and its errors.
- **Handles failures.** Type retries only when it can prove that the code did not start. Otherwise the automation keeps running and a repair agent starts for a code failure. A failed run never pauses it; if most of its recent runs fail, Type alerts its owner.

## Next steps

- [Quickstart](https://docs.type.com/automations/quickstart/index.md): Make an instruction automation, then deploy a code automation.
- [Core concepts](https://docs.type.com/automations/how-it-works/index.md): Triggers, stages, ctx, state, writes, tests, and failures.
- [Examples](https://docs.type.com/automations/examples/index.md): Ten complete automations to copy.
- [Reference](https://docs.type.com/automations/reference/sdk/index.md): Every trigger, method, field, command, and limit.
