# Import &amp; export

How to bring tasks in from another tracker with `mt import` and `jq`, and take them out with `mt ls '' --json`.

`mt import` moves tasks from another tracker: it reads tasks as JSON in the [canonical schema](https://mlavrinenko.github.io/mindtape/schema/index.md) and writes one `.typ` file for each. `mt ls '' --json` prints every task in the same schema. A `jq` program turns another tracker’s export into that schema, or the schema into another tracker’s format. The recipes below run in the docs build, so each output on this page is what the command printed.

## Import

`mt import` reads a file, or standard input if you don’t give one. It checks each record against this project’s config: the [status legend](https://mlavrinenko.github.io/mindtape/statuses/index.md), the priority scale, the `kind` values and the allowed tags. It checks the batch as one set, so records that link to each other resolve. Then it writes the records that pass. It reports a record that fails and doesn’t write it, and it still writes the rest.

The report on standard error names each record, `filed` or `skipped`, with the reason for a skip. When a content rule’s `message` replaces the check’s own words, they follow on an indented `note:` line, as `mt check` prints them. It also lists each change made to fit the config: `mapped`, `defaulted`, `dropped` or `violated`. `mt import` writes the records that pass, prints the report, then exits 1 if it skipped any record, so a script can tell a partial import from a whole one.

If the source’s status names differ from your legend, `--map old=new` renames a status before the check. `--dir <path>` sends the whole batch to one directory instead of each record’s `file`, resolved from the project root. `--dry-run` checks the batch and doesn’t write anything. Its report says `would file` for each record it would write and ends with `dry run: nothing
written`. The [`mt import` page](https://mlavrinenko.github.io/mindtape/cli/import/index.md) lists every flag.

The adapters in `contrib/jq/import/` read only the tracker’s own export, not your config. They emit the status names of the legend `mt init` writes by default: `proposed`, `done` and `cancelled`. If your legend differs, add `--map` to `mt import`, such as `--map proposed=todo`.

### From Taskwarrior

`task export > taskwarrior.json` saves Taskwarrior’s tasks. `contrib/jq/import/taskwarrior.jq` reshapes them:

```
$ jq -f contrib/jq/import/taskwarrior.jq taskwarrior.json | mt import
3 filed, 0 skipped
  Fix the login timeout bug: filed as fix-the-login-timeout-bug
    extras carried: x-tw
  Renew domain registration: filed as renew-domain-registration
    extras carried: x-tw
  Investigate flaky CI job (duplicate of #2 filed elsewhere): filed as investigate-flaky-ci-job-duplicate-of-2-filed-elsewhere
    extras carried: x-tw
```

A `pending` task becomes `proposed`, `completed` becomes `done` and `deleted` becomes `cancelled`. Any other status, such as `recurring` or `waiting`, passes through unchanged. If your legend lacks it, `mt import` skips that task and says so, unless you add `--map`, such as `--map waiting=proposed`. Priority `H`, `M` and `L` become 8, 5 and 2. The `project` and the tags become tags. The description becomes the title, and also the body under a `Summary` heading. The UUID, urgency, annotations and dependencies go into the `x-tw` field.

### From GitHub Issues

`gh issue list --state all --json number,title,body,state,labels,assignees,createdAt,url > issues.json` saves a repository’s issues. `gh` fetches 30 unless you pass `--limit`. `contrib/jq/import/github.jq` reshapes them:

```
$ jq -f contrib/jq/import/github.jq issues.json | mt import --dir tasks/github
3 filed, 0 skipped
  Login page throws 500 on empty password: filed as login-page-throws-500-on-empty-password
    extras carried: x-gh
  Add dark mode toggle: filed as add-dark-mode-toggle
    extras carried: x-gh
  Investigate memory leak in worker pool: filed as investigate-memory-leak-in-worker-pool
    extras carried: x-gh
```

An open issue becomes `proposed` and a closed one `done`. Labels become tags, and the creation date becomes `start`. The issue number, URL and assignees go into the `x-gh` field. `--dir tasks/github` writes the batch to `tasks/github/`. If the project derives tags from folders, each task gets a `github` tag.

### From todo.txt

todo.txt is one task per line, so a first `jq` pass splits the file into a JSON array of lines. `contrib/jq/import/todo.txt.jq` reshapes the array:

```
$ jq -R -s 'split("\n") | map(select(length > 0))' todo.txt \
  | jq -f contrib/jq/import/todo.txt.jq | mt import
3 filed, 0 skipped
  Fix the login timeout bug @office: filed as fix-the-login-timeout-bug-office
    extras carried: x-todotxt
  Renew domain registration next:asap: filed as renew-domain-registration-next-asap
    extras carried: x-todotxt
  Investigate flaky CI job (duplicate of #2 filed elsewhere) @ci: filed as investigate-flaky-ci-job-duplicate-of-2-filed-elsewhere-ci
    extras carried: x-todotxt
```

A line that starts with `x ` becomes `done`, and any other line `proposed`. Priority `(A)`, `(B)` and `(C)` become 8, 5 and 2. A `+project` word becomes a tag and a `due:` value the due date. The title keeps `@context` words and any other `key:value` word. The `x-todotxt` field contains them too, with the priority letter. Adjust the patterns in the adapter to the parts of the format your file uses.

## Round trip

An export imports back whole. `mt import` names each file from the record’s `id`, so a link to a task still resolves. A record with no `id`, like the ones the jq adapters emit, takes its name from its title, the way `mt add` names it. An `id` containing a `/` or a `.` follows the same rule. Without `--dir`, `mt import` writes a record to the folder its `file` names if that folder is under a task root. A multi-folder export then imports back as the same folders. If another task anywhere in the project already uses the name, `mt import` gives it a `-2` suffix and the report says `alpha: filed as alpha-2`. A link to it doesn’t follow the rename.

This exports `examples/round-trip/`, whose four tasks use every field the import writes:

```
$ mt ls ''
SLUG#  STATUS        PRIORITY   DUE         ASSIGNEE  TITLE
z2v    🔨 wip        🔴 high    2026-10-15  ada       Expire idle sessions
phb    💡 proposed                                    Rotate the signing key
f3q    ✅ done       🟡 normal                        Pick a session store
w8v    🚫 cancelled                                   Keep the legacy login form

4 of 4 tasks · your filter
$ mt ls '' --json > tasks.json
```

The empty filter `''` lists every task. Leave it out and `mt ls` applies the project’s default [view](https://mlavrinenko.github.io/mindtape/named-sets/index.md#views), which in a new project hides finished tasks, so their records would be missing from the file.

A new project, made by `mt init --no-input`, takes the file back:

```
$ mt init --no-input
wrote ./.mindtape/config.toml
preset: flow
want something else? mt init --list-presets shows the other presets
next: mt add "My first task"
$ mt import ../round-trip/tasks.json
4 filed, 0 skipped
  expire-idle-sessions: filed
  rotate-the-signing-key: filed
    extras carried: x-ops
  pick-a-session-store: filed
  keep-the-legacy-login-form: filed
$ mt ls ''
SLUG#  STATUS        PRIORITY   DUE         ASSIGNEE  TITLE
z2v    🔨 wip        🔴 high    2026-10-15  ada       Expire idle sessions
phb    💡 proposed                                    Rotate the signing key
f3q    ✅ done       🟡 normal                        Pick a session store
w8v    🚫 cancelled                                   Keep the legacy login form

4 of 4 tasks · your filter
```

The docs build compares the two projects’ `mt ls '' --json` output and fails if any field differs.

## Export

There’s no export command. Each task is a `.typ` file in your repository, so git and `cp` already move them. For another tracker’s format, pipe `mt ls '' --json` through `jq`.

### To todo.txt

```
$ mt ls '' --json | jq -r '.tasks[] | select(.status.name != "cancelled")
  | (.priority | if type == "object" then .score else . end) as $p
  | [ (if .status.name == "done" then "x" else empty end),
      (if ($p | type) == "number" and $p >= 7 then "(A)" else empty end),
      .title,
      (.tags[] | "+" + .),
      (.due // empty | "due:" + .) ]
  | join(" ")'
(A) Expire idle sessions +backend +security due:2026-10-15
Rotate the signing key +security
x Pick a session store +backend
```

The recipe drops cancelled tasks, because todo.txt has no mark for them. A finished task starts with `x`, and a priority of 7 or more becomes `(A)`.

### To CSV

`mt ls --format csv` prints the listing’s columns:

```
$ mt ls '' --format csv
id,status,priority,due,assignee,title
expire-idle-sessions,wip,8,2026-10-15,ada,Expire idle sessions
rotate-the-signing-key,proposed,,,,Rotate the signing key
pick-a-session-store,done,5,,,Pick a session store
keep-the-legacy-login-form,cancelled,,,,Keep the legacy login form
```

For other columns, build the rows in `jq` and format them with `@csv`:

```
$ mt ls '' --json | jq -r '["title", "status", "priority", "due"],
  (.tasks[] | [.title, .status.name, (.priority | if type == "object" then .score else . end), .due])
  | @csv'
"title","status","priority","due"
"Expire idle sessions","wip",8.0,"2026-10-15"
"Rotate the signing key","proposed",,
"Pick a session store","done",5.0,
"Keep the legacy login form","cancelled",,
```

A priority from a framework such as `ice` is an object, which `@csv` refuses. The recipe then takes its `score`.

### To Taskwarrior

```
$ mt ls '' --json | jq '[.tasks[] | {
    description: .title,
    status: ({done: "completed", cancelled: "deleted"}[.status.name] // "pending"),
    tags: .tags,
    due: (if .due then (.due | gsub("-"; "")) + "T000000Z" else null end)
  } | with_entries(select(.value != null))]'
[
  {
    "description": "Expire idle sessions",
    "status": "pending",
    "tags": [
      "backend",
      "security"
    ],
    "due": "20261015T000000Z"
  },
  {
    "description": "Rotate the signing key",
    "status": "pending",
    "tags": [
      "security"
    ]
  },
  {
    "description": "Pick a session store",
    "status": "completed",
    "tags": [
      "backend"
    ]
  },
  {
    "description": "Keep the legacy login form",
    "status": "deleted",
    "tags": []
  }
]
```

The array has the fields and date format `task export` prints. Save it to a file and run `task import` on it. The docs build skips that step, because it has no Taskwarrior.

> **Tip:** The [canonical schema](https://mlavrinenko.github.io/mindtape/schema/index.md) lists every field a recipe can read, and which of them `mt import` reads back.
