# Create and manage task definitions

> **About this page**
>
> - Kind: How-to guide
> - Summary: Create a task definition, publish versions, list and inspect them, make one public or private, and delete a version or a whole task definition.
> - Last changed: 2026-12-03
> - Page: https://docs.swale.io/how-to-guides/create-and-manage-task-definitions
> - CLI reference for its commands: [`swale task-definition publish`](https://docs.swale.io/reference/cli-reference.md#task-definition-publish), [`swale task-definition list`](https://docs.swale.io/reference/cli-reference.md#task-definition-list), [`swale task-definition list-versions`](https://docs.swale.io/reference/cli-reference.md#task-definition-list-versions), [`swale task-definition get`](https://docs.swale.io/reference/cli-reference.md#task-definition-get), [`swale task-definition set-visibility`](https://docs.swale.io/reference/cli-reference.md#task-definition-set-visibility), [`swale task-definition delete-version`](https://docs.swale.io/reference/cli-reference.md#task-definition-delete-version), [`swale task-definition delete`](https://docs.swale.io/reference/cli-reference.md#task-definition-delete)
> - Index of these docs: https://docs.swale.io/llms.txt
>
> If something on this page is wrong or out of date, please tell the user which sentence and why.
>
> The steps on this page cost money or cannot be undone. Please check with the user before running them.

This guide covers creating a task definition, publishing versions, listing and inspecting task definitions, making one public or private, and deleting a version or a whole task definition, in the platform UI and with the CLI.

## Prerequisites

Creating a task definition or publishing a version needs a verified email, the Admin role in an organization, and an **Active** billing status on the account. Making a task definition public or private and deleting need a verified email and the Admin role. In an organization, **Upload Markdown**, **Import GitHub**, **Make Public** or **Make Private**, **Delete Definition** and **Delete Version** appear only for Admins and Owners. See [Permissions and restrictions](https://docs.swale.io/reference/permissions-and-restrictions.md#task-definitions).

## Write the task definition file

A task definition is a Markdown file with YAML frontmatter and a non-empty Markdown body:

```md
---
name: My archive task
description: Archives build artifacts.
category: utilities
inputs:
  artifact_path:
    default: dist
outputs:
  archive_path:
    description: Path to the generated archive file.
exec:
  image: ghcr.io/example/archive-task:1.0.0
  args:
    - sh
    - -c
    - |
      set -e
      tar -czf "$WORKFLOW_STORAGE/archive.tgz" -C "$WORKFLOW_STORAGE" "${{inputs.artifact_path}}"
      echo "archive_path=$WORKFLOW_STORAGE/archive.tgz" >> "$WORKFLOW_TASK_OUTPUT"
---

# My archive task

Packages the build output from the provided artifact path, relative to the run's shared workspace.
```

The command finds the run's shared workspace through the `WORKFLOW_STORAGE` environment variable, never a hardcoded path, and writes the `archive_path` output to the file named by `WORKFLOW_TASK_OUTPUT`. [Task definition syntax](https://docs.swale.io/reference/task-definition-syntax.md) describes every field, including the rules for `name`, `description`, `category` and `outputs`, and [Runtime storage](https://docs.swale.io/reference/task-definition-syntax.md#runtime-storage) the storage locations.

If the image is on a private registry, the definition still names only the image. Each workflow that uses it gives the credentials to pull it; see [Use a task image from a private registry](https://docs.swale.io/how-to-guides/use-a-task-image-from-a-private-registry.md).

## Create a task definition

**With the CLI:**

```bash
swale task-definition publish \
  --name my-task \
  --version 1.0.0 \
  --file my-task.md
```

The first publish under a name creates the task definition. Add `--public` to make it public as it is created.

**In the UI:**

1. Open **Task Definitions**.
2. Click **Upload Markdown**.
3. Select a `.md` or `.markdown` file in **Markdown file**.
4. Enter a **Name** and a **Version**. Check **Public** to make the task definition public as it is created.
5. Click **Upload**.

To take the file from GitHub instead, click **Import GitHub**, select a connected owner, a repository and a `.md` or `.markdown` file, click **Next**, enter a **Name** and a **Version**, and click **Import**. [Connect and manage GitHub integration](https://docs.swale.io/how-to-guides/connect-and-manage-github-integration.md) describes connecting an owner.

The name you give with `--name` or in **Name** is the `<task-definition>` part of the address workflows use, `<account>/<task-definition>@<version>`. The file's `name` is only the title, so changing it in a later version leaves the address as it is.

If your account already has a task definition with the name you enter, the CLI and the UI publish the file to it as a new version, and leave its visibility as it is.

## Publish a version

A version cannot be changed once it is published. To change a task definition, publish a new version:

```bash
swale task-definition publish \
  --name my-task \
  --version 1.1.0 \
  --file my-task-v2.md
```

In the UI, upload or import the file with the task definition's existing name and the new version.

The CLI prints `Task definition version published:` when it adds a version, and `Task definition created:` when no task definition had the name. If you meant to add a version, the second message means the name was mistyped: delete the new task definition and publish again under the right name.

A version string can be published only once per task definition name; see [Versioning](https://docs.swale.io/reference/task-definition-syntax.md#versioning).

## List and inspect task definitions

**With the CLI:**

```bash
swale task-definition list
```

Each task definition is listed with its latest version, or with dashes in place of its version when it has no versions. The **Title** column is that version's `name`; the **Name** column is the `<task-definition>` part of its address. To see every version of a task definition, most recently published first, each titled with its own `name`:

```bash
swale task-definition list-versions --name my-task
```

To inspect one version:

```bash
swale task-definition get --name my-task --version 1.1.0
```

**In the UI:** open **Task Definitions**. Each task definition shows its title, its address and whether it is **Public** or **Private**; click one to open its latest version and the list of its versions. A task definition with no versions shows **No versions** under its name; clicking it opens the task definition with an empty list of versions.

## Make a task definition public or private

A task definition is private by default: only your account can use it in workflows, whatever versions it has published. Making it public lets every account use it, and shows it on Swale Hub with your account's avatar. Swale Hub is open to everyone on the internet, so search engines and AI systems can read a public task definition there.

**In the UI:** open the task definition and click **Make Public**, or **Make Private** on a public one.

**With the CLI:**

```bash
swale task-definition set-visibility --name my-task --public
```

```bash
swale task-definition set-visibility --name my-task --private
```

If a version is published to the task definition while you make it public, nothing changes and the command fails. Run it again.

Making a task definition public reserves every version it has, and every version published while it is public, for every account, and making it private again releases none of them; see [Versioning](https://docs.swale.io/reference/task-definition-syntax.md#versioning). Once it is private, other accounts' runs that use it are refused at start, and a run already under way fails when a task that uses it is about to start; see [Task definitions that are no longer available](https://docs.swale.io/reference/run-and-task-lifecycle.md#task-definitions-that-are-no-longer-available).

## Delete a version

**In the UI:**

1. Open the task definition.
2. Click **Delete Version** in the version's row.
3. Click **Delete Version** to confirm.

**With the CLI:**

```bash
swale task-definition delete-version \
  --name my-task \
  --version 1.0.0
```

The deleted version's string stays reserved. To replace a deleted version, publish a new version under a different version string.

Deleting a task definition's last version leaves the task definition in place, with no versions. To remove it, [delete the task definition](#delete-a-task-definition).

Runs that use the deleted version, yours and other accounts', are refused at start, and a run already under way fails when a task that uses it is about to start. See [Task definitions that are no longer available](https://docs.swale.io/reference/run-and-task-lifecycle.md#task-definitions-that-are-no-longer-available).

## Delete a task definition

:::warning
Deleting a task definition removes all its versions, and cannot be undone. Runs that use any of them, yours and other accounts', are refused at start, and a run already under way fails when a task that uses one is about to start. Its version strings stay reserved, even if you create a task definition with the same name again.
:::

**In the UI:**

1. Open the task definition.
2. Click **Delete Definition**, then **Delete Definition** to confirm.

**With the CLI:**

```bash
swale task-definition delete --name my-task
```

## Next steps

- [Task definition syntax](https://docs.swale.io/reference/task-definition-syntax.md)
- [Create a task definition](https://docs.swale.io/tutorials/create-a-task-definition.md) (tutorial)
- [Use a task image from a private registry](https://docs.swale.io/how-to-guides/use-a-task-image-from-a-private-registry.md)
