# For AI agents

How a coding agent reads tasks as JSON, files tasks without prompts and works in its own git worktree.

A coding agent works through your backlog with the same `mt` commands you use. Tasks are files in your repo, so an agent reads and edits them with the tools it already has, and `mt check` tells it when an edit breaks a rule. The examples below run against `examples/api-service/`, a sample backend project.

## Give your agent the skill

The Mindtape repository includes an agent skill in [`skills/mindtape/`](https://github.com/mlavrinenko/mindtape/tree/main/skills/mindtape). Its `SKILL.md` opens with the recipe an agent runs: `mt config show --resolved` for the project’s shape, `mt ls` and `mt find <words>` to pick a task, `mt add --describe` and `mt add` to file one, and `mt check` to validate.

The rest of the skill points at `mt <cmd> --help` and the files in `references/` instead of repeating what the CLI says. It uses the [Agent Skills](https://agentskills.io) format, so any agent that supports the format can load it.

With GitHub CLI 2.90 or later, install it with `gh skill`, a public preview. It takes the skill from the latest release:

```sh
gh skill install mlavrinenko/mindtape mindtape --agent claude-code --scope user
```

Replace `claude-code` with your agent. `gh skill install --help` lists the agents it knows, and [its manual](https://cli.github.com/manual/gh_skill_install) covers the other flags. `--scope user` loads the skill in every project.

Or use the [skills](https://skills.sh) CLI, which needs Node.js and installs from the default branch:

```sh
npx skills add mlavrinenko/mindtape --skill mindtape --agent claude-code --global
```

To install it by hand, copy `skills/mindtape/` with its `references/` into the skills directory your agent reads. [Claude Code](https://code.claude.com/docs/en/skills), [Codex](https://developers.openai.com/codex/build-skills) and [GitHub Copilot](https://docs.github.com/en/copilot/concepts/agents/about-agent-skills) each document theirs.

## Read these docs as Markdown

Every page of this site has a Markdown copy at `index.md` under its URL, such as [https://mlavrinenko.github.io/mindtape/concepts/index.md](https://mlavrinenko.github.io/mindtape/concepts/index.md) for Concepts, and each page’s header links to its copy. [https://mlavrinenko.github.io/mindtape/llms.txt](https://mlavrinenko.github.io/mindtape/llms.txt) lists every copy with its summary, so an agent can find the page it needs from one file.

## Read tasks as JSON

Every command that reports a list or an object prints it as JSON with `--json`: `mt ls`, `mt find`, `mt eval <task>`, `mt check`, `mt graph`, `mt board`, `mt at`, `mt preset ls`, `mt config show`, `mt @set ls` and `mt packs install`. `mt add --describe=json` prints a template’s slots, and `mt add --json` reports a write. `mt ls ready -n 1 --json` prints:

````json
{
  "$schema": "https://raw.githubusercontent.com/mlavrinenko/mindtape/main/schema/output/ls/1.schema.json",
  "tasks": [
    {
      "id": "index-the-orders-by-customer",
      "file": "tasks/index-the-orders-by-customer.typ",
      "title": "Index the orders by customer",
      "status": {
        "name": "proposed",
        "date": "2026-09-29",
        "note": null
      },
      "priority": {
        "framework": "ice",
        "inputs": {
          "confidence": 0.95,
          "ease": 9.0,
          "impact": 9.0
        },
        "score": 7.0
      },
      "difficulty": null,
      "kind": "fix",
      "assignee": null,
      "estimate": {
        "src-files": 1.0
      },
      "estimate_counts": {},
      "links": [],
      "waits_on": [],
      "tags": [
        "billing",
        "stateless"
      ],
      "derived_tags": [],
      "why": [],
      "children": 0,
      "progress": null,
      "due": "2026-10-02",
      "start": null,
      "reviewed": null,
      "body": "== AS-IS\nListing one customer's orders scans every row of `orders`.\n\n+ Run `curl localhost:8080/customers/4711/orders`.\n+ 🔴 It takes 3 seconds, because Postgres scans every row of `orders`.\n\n```sh\n$ psql \"$DATABASE_URL\" -c \"EXPLAIN ANALYZE SELECT * FROM orders WHERE customer_id = 4711\" | tail -1\nSeq Scan on orders  (actual time=0.020..2810.134 rows=12 loops=1)\n```\n\n== Environment\n- Production, release `v1.8.2`, with 12 million orders.\n\n== TO-BE\n- 🟢 The same request returns in under 50 ms.\n\n```sh\n$ curl -w '%{time_total}s\\n' localhost:8080/customers/4711/orders\n0.012s\n```\n\n== Changes\n- `migrations/0008_orders_customer_index.sql`, new: create the index with `CONCURRENTLY`, so writes keep flowing.\n\n== Out of scope\n- Paginating the orders list.",
      "recur": null,
      "extras": {},
      "derived": {
        "changes": [
          "migrations/0008_orders_customer_index.sql"
        ]
      },
      "collector_problems": []
    }
  ],
  "applied": {
    "rule": null,
    "superseded": false,
    "facets": {
      "filter": {
        "from": "manual",
        "value": "ready"
      },
      "sort": {
        "from": "match-all",
        "value": []
      },
      "columns": {
        "from": "match-all",
        "value": []
      }
    }
  },
  "truncated": {
    "shown": 1,
    "total": 8,
    "next_skip": 1
  },
  "retired": []
}
````

`applied.facets` says where each [facet](https://mlavrinenko.github.io/mindtape/cli/ls/index.md) of the listing, its filter, sort and columns, came from. `-n` keeps the reply short. `truncated` says how many tasks matched and where the next page starts, so `mt ls ready -n 1 --skip 1 --json` returns the next task. `truncated` is `null` when the list is complete. Its first key is `$schema`, a URL to [the JSON schema](https://mlavrinenko.github.io/mindtape/schema/index.md), which describes every field, so an agent can fetch the schema before it reads one.

`mt _cli --json` prints every command with its flags, defaults and accepted values, so an agent can learn the CLI without parsing `--help`.

## File a task without prompts

`mt add --describe=json` lists the template’s slots under `slots`: each one’s name, kind, whether it’s required, its default and its prompt. The same object carries the project’s `[[on.add]]` hooks under `hooks`, with the action each one applies. The agent writes the values as YAML or JSON and passes them with `-f -` on stdin, or passes a scalar field with its own flag, such as `--due`. [Templates & slots](https://mlavrinenko.github.io/mindtape/templates/index.md) covers the slots and the other ways to fill them.

When stdin or stdout isn’t a terminal, `mt add` doesn’t open an editor. A slot left empty fails the add, and the error lists every missing slot:

```
$ mt add "Log slow database queries" --print </dev/null
error: missing required slots: 'as-is', 'to-be', 'changes', 'out-of-scope'
hint: pass each with --set name=value, or with -f
hint: run mt add --describe to see the slots
```

It exits with code `2` and doesn’t write anything. With `--json`, the shorthand for `--format json`, a successful add prints an object whose first key is `$schema`, then `outcome` (`wrote`, `skipped` or `suffixed`), `path` and `slug`, its stem hash, the short name every command accepts. `--format path` and `--format path0` still print just the path.

## Trust the exit code

`mt` exits with 0 when a command succeeds, 1 when it fails and 2 when the command line is wrong, and it prints the reason on stderr. Every command that writes a task checks the result first and leaves the file untouched if the check fails. An agent can fix its input and run the command again.

- `mt check` exits with 1 when a task breaks a rule of severity `error`, and names the file and the line. Run it in CI or a pre-commit hook.
- A [flip hook](https://mlavrinenko.github.io/mindtape/hooks/index.md) can run your tests when you close a task, and refuse to close it while they fail.
- `mt` colors stdout and stderr only when each one is a terminal, and on stderr only the `error:`, `warning:`, `hint:` and `note:` prefix. `NO_COLOR` or `--color never` turn color off in a terminal too.

## Work in a git worktree

Tasks are files, so each git worktree has its own copy of the backlog. An agent in its own worktree sets its task’s status there, and that change merges with the code that makes it. There’s no server or index to update.

`mt` reads only the worktree it runs in. Two agents in two worktrees don’t see each other’s status changes until their branches merge, so decide which agent takes which task before they start.

To run `mt` on a worktree from another directory, pass `-w <path>` or set `MINDTAPE_WORKTREE`. To name your projects and read more than one at once, see [Read many projects](https://mlavrinenko.github.io/mindtape/read-many-projects/index.md).

## Pin today’s date

Set `MINDTAPE_NOW` to a date such as `2026-10-01`, and `mt` uses it for every date it stamps or compares. Then a test or a snapshot prints the same output on every run. [Configuration](https://mlavrinenko.github.io/mindtape/config/index.md) lists the formats it accepts.

## Keep your own data in a task

If you build a tool on Mindtape, store its data in a task field named `x-<name>`. `mt` keeps the field as written and returns it under `extras` in JSON. [Concepts](https://mlavrinenko.github.io/mindtape/concepts/index.md) describes these fields, and [Self-validating tasks](https://mlavrinenko.github.io/mindtape/self-validating-tasks/index.md) shows how to check one.
