> ## Documentation Index
> Fetch the complete documentation index at: https://jncpkg.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Tasks

> Define and run cross-platform tasks with jnc's built-in task runner.

# Tasks

jnc includes a cross-platform task runner. Define tasks in your manifest and run them with `jnc run`. Tasks execute inside the workspace environment with all dependencies available.

## Defining tasks

### Simple tasks

```toml theme={null}
[tasks]
start = "python main.py"
lint = "ruff check ."
format = "ruff format ."
```

### Tasks with options

Use the table format for more control:

```toml theme={null}
[tasks.test]
cmd = "pytest tests/"
depends-on = ["build"]

[tasks.build]
cmd = "python -m build"
```

## Running tasks

```bash theme={null}
jnc run test
jnc run lint
```

You can also run arbitrary commands (not just defined tasks):

```bash theme={null}
jnc run python -c "print('hello')"
```

## Task dependencies

Tasks can depend on other tasks. Dependencies run first, in the correct order:

```toml theme={null}
[tasks.build]
cmd = "make build"

[tasks.test]
cmd = "pytest"
depends-on = ["build"]

[tasks.ci]
depends-on = ["lint", "test"]
```

Running `jnc run ci` will execute `lint` and `test` (and their dependencies) before `ci`.

## Environment-specific tasks

Tasks belong to features, so you can define tasks for specific environments:

```toml theme={null}
[feature.test.tasks]
test = "pytest tests/ -v"

[feature.docs.tasks]
docs = "sphinx-build docs/ docs/_build"
```

Run them by targeting the environment:

```bash theme={null}
jnc run --environment test test
jnc run --environment docs docs
```

## Platform-specific tasks

Define tasks that only apply on certain platforms:

```toml theme={null}
[target.linux-aarch64.tasks]
setup = "bash setup.sh"
```

## Managing tasks with the CLI

```bash theme={null}
jnc task add start "python main.py"          # Add a task
jnc task add test "pytest" --depends-on build # Add with dependency
jnc task remove start                         # Remove a task
jnc task list                                 # List all tasks
jnc task alias ci lint test                   # Create a task alias
```
