# Make a step that does it

> A step the game does for the player, after they agree: it asks what it needs, runs an executor and proves the result.

You write a step with a **Do it** button: the game asks the player what it needs, shows what will run, runs it once they agree, and checks on its own that it worked. "I did it" stays only on what the player alone can do.

**Before you begin (15 minutes)**

- A quest pack that passes `alta lint`: the [quickstart](https://docs.altasystem.ai/quickstart) makes one, `my-pack`.
- Read [The game does it, the player agrees](https://docs.altasystem.ai/concepts/do-it) if the words input, executor or proof are new.

### Ask for what the step needs

`inputs` is the form of the plan card. Each input has an `id`, a `kind` (text, choice, email, path, number, boolean, secret) and a label in each language. `saves` keeps the answer, so a later step can prefill it with `from`.

The game checks every value twice, in the page and on the player's own server, with the same rules as `alta lint`.

```json [my-pack/do-it.json]
[
  {
    "id": "name",
    "kind": "text",
    "max": 40,
    "label": { "en": "Its name", "fr": "Son nom" },
    "saves": "answers.do-it.name"
  }
]
```

### Hand it to an executor

`run.do` names an executor of the [closed list](https://docs.altasystem.ai/reference/standards/executors): each one is a fixed command the game knows, never a command written in your file. `run.args` gives its arguments: a literal, `{ "input": "<id>" }` for a value of the form, or `{ "answer": "answers.<key>" }` for an answer already given.

The player sees the plan card (what runs, what it changes, how to undo it) and says yes. Nothing runs before that.

```json [my-pack/do-it.json]
{ "do": "setup.daemon-name", "args": { "name": { "input": "name" } } }
```

### Prove it with a check

The step is done when its `check` passes, never when the run ends. A check only reads the machine: here, that the main agent has a name. Pick one in the [check types](https://docs.altasystem.ai/reference/standards/checks).

```json [my-pack/do-it.json]
{
  "id": "name",
  "kind": "action",
  "title": {
    "en": "Give your helper a name",
    "fr": "Donne un nom à ton assistant"
  },
  "inputs": [
    {
      "id": "name",
      "kind": "text",
      "max": 40,
      "label": { "en": "Its name", "fr": "Son nom" },
      "saves": "answers.do-it.name"
    }
  ],
  "run": {
    "do": "setup.daemon-name",
    "args": { "name": { "input": "name" } }
  },
  "check": { "type": "identity" }
}
```

### Ask for a secret, safely

A token, a key or a one-time code is a `secret` input: a password field, sent once to the player's own machine, then straight to the program. It has no `default`, `from`, `saves` or `pattern`, and it only feeds an argument the executor declares secret, such as `token` of `channel.connect`. Never write a key in your file: `alta lint` refuses it.

```json [my-pack/do-it.json]
{
  "id": "connect",
  "kind": "action",
  "title": { "en": "Connect Telegram", "fr": "Branche Telegram" },
  "inputs": [
    {
      "id": "token",
      "kind": "secret",
      "label": { "en": "The bot's token", "fr": "Le jeton du bot" },
      "hint": {
        "en": "Pasted once, sent to your machine only, never kept by the game.",
        "fr": "Collé une fois, envoyé à ta machine seulement, jamais gardé par le jeu."
      }
    }
  ],
  "run": {
    "do": "channel.connect",
    "args": { "channel": "telegram", "token": { "input": "token" } }
  },
  "check": { "type": "channel", "id": "telegram" }
}
```

### Leave the player only what is theirs

Some steps need the player: speaking, approving a system window, another device, another site. Such a step is `manual` and says why, with `human`. The game still helps: a `run` that changes nothing opens the right pane, and a `check` proves the result, so "I did it" disappears. With no proof of its own, `provenBy` names the step whose proof covers it.

```json [my-pack/do-it.json]
{
  "id": "microphone",
  "kind": "manual",
  "human": "approve",
  "os": ["macos"],
  "title": { "en": "Allow the microphone", "fr": "Autorise le micro" },
  "run": { "do": "mac.open-pane", "args": { "pane": "microphone" } },
  "check": { "type": "permission", "name": "microphone" }
}
```

```json [my-pack/do-it.json]
{
  "id": "bot",
  "kind": "manual",
  "human": "external",
  "title": {
    "en": "Create a bot with BotFather",
    "fr": "Crée un bot avec BotFather"
  },
  "hint": {
    "en": "In Telegram, write /newbot to @BotFather. It answers with a token.",
    "fr": "Dans Telegram, écris /newbot à @BotFather. Il répond avec un jeton."
  },
  "provenBy": "connect"
}
```

### Put it in your pack and check it

Save the complete example as `my-pack/do-it.json`, next to `quests.json`, and check the folder. Every file of the folder is checked.

```json [my-pack/do-it.json]
{
  "schema": "alta.quests/0.3",
  "branch": "core",
  "quests": [
    {
      "id": "do-it-chat",
      "uid": "core.do-it.chat",
      "act": 2,
      "giver": "operator",
      "title": {
        "en": "Talk from your phone",
        "fr": "Parle-lui depuis ton téléphone"
      },
      "summary": {
        "en": "The game names your helper, connects Telegram and approves the pairing. You only do what is yours.",
        "fr": "Le jeu nomme ton assistant, branche Telegram et accepte l'appairage. Tu ne fais que ce qui est à toi."
      },
      "reward": { "xp": 60 },
      "steps": [
        {
          "id": "name",
          "kind": "action",
          "title": {
            "en": "Give your helper a name",
            "fr": "Donne un nom à ton assistant"
          },
          "inputs": [
            {
              "id": "name",
              "kind": "text",
              "max": 40,
              "label": {
                "en": "Its name",
                "fr": "Son nom"
              },
              "saves": "answers.do-it.name"
            }
          ],
          "run": {
            "do": "setup.daemon-name",
            "args": { "name": { "input": "name" } }
          },
          "check": { "type": "identity" }
        },
        {
          "id": "bot",
          "kind": "manual",
          "human": "external",
          "title": {
            "en": "Create a bot with BotFather",
            "fr": "Crée un bot avec BotFather"
          },
          "hint": {
            "en": "In Telegram, write /newbot to @BotFather. It answers with a token.",
            "fr": "Dans Telegram, écris /newbot à @BotFather. Il répond avec un jeton."
          },
          "provenBy": "connect"
        },
        {
          "id": "connect",
          "kind": "action",
          "title": {
            "en": "Connect Telegram",
            "fr": "Branche Telegram"
          },
          "inputs": [
            {
              "id": "token",
              "kind": "secret",
              "label": {
                "en": "The bot's token",
                "fr": "Le jeton du bot"
              },
              "hint": {
                "en": "Pasted once, sent to your machine only, never kept by the game.",
                "fr": "Collé une fois, envoyé à ta machine seulement, jamais gardé par le jeu."
              }
            }
          ],
          "run": {
            "do": "channel.connect",
            "args": {
              "channel": "telegram",
              "token": { "input": "token" }
            }
          },
          "check": { "type": "channel", "id": "telegram" }
        },
        {
          "id": "pair",
          "kind": "action",
          "title": {
            "en": "Approve your phone",
            "fr": "Accepte ton téléphone"
          },
          "inputs": [
            {
              "id": "code",
              "kind": "text",
              "max": 16,
              "pattern": "^[A-Za-z0-9-]{1,16}$",
              "label": {
                "en": "The code the bot sent you",
                "fr": "Le code que le bot t'a envoyé"
              }
            }
          ],
          "run": {
            "do": "channel.pair-approve",
            "args": {
              "channel": "telegram",
              "code": { "input": "code" }
            }
          },
          "check": {
            "type": "channel",
            "id": "telegram",
            "state": "paired"
          }
        },
        {
          "id": "hello",
          "kind": "manual",
          "human": "device",
          "title": {
            "en": "Say hello from your phone",
            "fr": "Dis bonjour depuis ton téléphone"
          },
          "provenBy": "pair"
        }
      ]
    },
    {
      "id": "do-it-voice",
      "uid": "core.do-it.voice",
      "act": 2,
      "giver": "daemon",
      "title": {
        "en": "Let it hear you",
        "fr": "Laisse-le t'entendre"
      },
      "summary": {
        "en": "The microphone is yours to allow; the language is set by the game.",
        "fr": "Le micro, c'est à toi de l'autoriser ; la langue, le jeu la règle."
      },
      "requires": ["core.do-it.chat"],
      "reward": { "xp": 40 },
      "steps": [
        {
          "id": "microphone",
          "kind": "manual",
          "human": "approve",
          "os": ["macos"],
          "title": {
            "en": "Allow the microphone",
            "fr": "Autorise le micro"
          },
          "run": {
            "do": "mac.open-pane",
            "args": { "pane": "microphone" }
          },
          "check": {
            "type": "permission",
            "name": "microphone"
          }
        },
        {
          "id": "language",
          "kind": "action",
          "title": {
            "en": "Choose the language it listens for",
            "fr": "Choisis la langue qu'il écoute"
          },
          "inputs": [
            {
              "id": "locale",
              "kind": "choice",
              "label": {
                "en": "Language",
                "fr": "Langue"
              },
              "default": "en-US",
              "choices": [
                {
                  "id": "en-US",
                  "label": {
                    "en": "English",
                    "fr": "Anglais"
                  }
                },
                {
                  "id": "fr-FR",
                  "label": {
                    "en": "French",
                    "fr": "Français"
                  }
                }
              ]
            }
          ],
          "run": {
            "do": "openclaw.config-set",
            "args": {
              "path": "talk.speechLocale",
              "value": { "input": "locale" }
            }
          },
          "check": {
            "type": "config",
            "path": "talk.speechLocale"
          }
        }
      ]
    }
  ]
}
```

```sh [Terminal]
alta lint my-pack
```

```text [Output]
ok   my-pack/do-it.json (quests)
ok   my-pack/quests.json (quests)
2 checked, 0 errors, 0 warnings
```

### Read what alta lint says

Add `"saves": "answers.do-it.token"` to the secret input and check again. Under the rule, [`step.input-secret`](https://docs.altasystem.ai/reference/errors#step-input-secret), `alta lint` says which case it is (`detail`), where (`in`), and what this file can write instead (`hint`).

```sh [Terminal]
alta lint my-pack
```

```text [Output]
FAIL my-pack/do-it.json (quests)
     error: quests[0].steps[2].inputs[0]: A secret stays between the player and their machine: never prefilled, kept, shown or written in a file, and it only feeds an argument the executor declares secret. [step.input-secret]
       in: quest core.do-it.chat, step connect
       detail: input token: a secret has no saves (it is never prefilled, kept or shown)
       hint: remove "saves" from this input: the player types a secret each time, and the program keeps it in its own store
       fix: Remove default, from, saves and pattern from a secret input, bind it to the executor's secret argument, and never write a key or a token in the file.
       docs: https://docs.altasystem.ai/reference/errors#step-input-secret
ok   my-pack/quests.json (quests)
2 checked, 1 error, 0 warnings
```

**Try it:**

```sh
alta dev my-pack
```

Open the address it prints, then the quest **Talk from your phone**: each step that does it shows **Do it**. In the demo, the card shows what would run; nothing runs on your machine.

## Pitfalls

| Do | Avoid |
|---|---|
| One executor per step, and a check that proves its result | A step that is done when the run ends |
| `human` on every manual step, with a helper and a proof when there is one | "I did it" on something the machine could do |
| A `secret` input for every key, token or code | A key in `run.args`, or a secret saved for later |
| `os` on a step whose executor runs on one system | A macOS-only helper offered on Linux |

An executor runs only if the owner started the game with its capability (for example `--allow-setup`), and some do not run in a hosted world: the card then says why, in words.

## Go further

- [The game does it, the player agrees](https://docs.altasystem.ai/concepts/do-it): why steps are written this way.
- [Executors](https://docs.altasystem.ai/reference/standards/executors) and [check types](https://docs.altasystem.ai/reference/standards/checks): every action and every proof.
- [Errors](https://docs.altasystem.ai/reference/errors#standard-quests): every rule of `alta lint`.

**Next:**

- [Executors](https://docs.altasystem.ai/reference/standards/executors)
- [A sign-in step](https://docs.altasystem.ai/guides/quests/sign-in-step)
- [Validate in CI](https://docs.altasystem.ai/guides/tools/validate-ci)
