# Run build and test tasks in Skink (tasks.json, cargo, npm)

> Run build, test and script tasks with Shift+F10: tasks.json (VS Code subset), detected cargo, npm, go, zig, pytest and make tasks, with errors in the gutter.

Source: https://skink.cc/code/tasks/

Press Shift+F10 to pick a task and run it in a terminal tab. Shift+F9 runs the last one again.

When it finishes, its errors show in the gutter and in the Problems list, as if a language server had reported them.

You do not need to write anything to start: Skink detects common tasks from your project files.

## Task keys and commands

| Key | Typed command | Does |
|---|---|---|
| Shift+F10 | `:task` | Pick a task and run it |
| | `:task LABEL` | Run the task with that label |
| Shift+F9 | `:task last` or `:rerun` | Run the last task again |
| Shift+F8 | `:problems` | Errors and warnings, including the task's |
| F6 / Shift+F6 | `:nextproblem` / `:prevproblem` | Next / previous problem in the file |

While a debug session runs, F6 pauses the program instead. F9 toggles a breakpoint.

## Detected tasks

| From | Tasks |
|---|---|
| `Cargo.toml` | `cargo build`, `cargo check`, `cargo clippy`, `cargo test`, `cargo run` |
| `package.json` | its `scripts`, run with npm, pnpm, yarn or bun |
| `go.mod` | `go build ./...`, `go vet ./...`, `go test ./...` |
| `build.zig` | `zig build`, `zig build test`, `zig build run` |
| pytest setups (such as `pytest.ini`) | `pytest` |
| `Makefile` | `make` and `make TARGET` for its targets |

Open the picker to see exactly what was found for your project.

## Write your own tasks.json

Put your tasks in `.skink/tasks.json`, or reuse an existing `.vscode/tasks.json`. Skink reads a subset of VS Code's format:

```jsonc
{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "test",
      "command": "cargo",
      "args": ["test", "--", "--nocapture"],
      "group": "test",
      "options": {
        "cwd": "${workspaceFolder}",
        "env": { "RUST_BACKTRACE": "1" }
      },
      "problemMatcher": "$rustc"
    },
    {
      "label": "lint file",
      "command": "eslint",
      "args": ["${file}"],
      "windows": { "command": "eslint.cmd" },
      "problemMatcher": ["$eslint-stylish"]
    }
  ]
}
```

### Supported fields

- `label`, `command`, `args`
- `options.cwd`, `options.env`
- `group`, `problemMatcher`
- per-OS overrides under `linux`, `osx` and `windows`

### Variables

| Variable | Becomes |
|---|---|
| `${workspaceFolder}` | The project root |
| `${file}` | The current file |
| `${relativeFile}` | The current file, relative to the root |
| `${fileDirname}` | The current file's folder |
| `${fileBasename}` | The current file's name |
| `${env:NAME}` | The environment variable `NAME` |

## Problem matchers: errors in the gutter

When a task ends, its output goes through problem matchers that turn error messages into diagnostics.

| Matcher | For |
|---|---|
| `$rustc` | Rust and cargo |
| `$tsc` | TypeScript |
| `$eslint-stylish`, `$eslint-compact` | ESLint |
| `$go` | Go |
| `$gcc` | C and C++ compilers |
| python tracebacks, pytest | Python |

With no `problemMatcher` in a task, all of them are tried. Set `"problemMatcher": []` to turn them off.

The problems stay until the task runs again.

## Task output

Tasks run in a terminal tab, so colours, progress bars and interactive prompts work.

- Ctrl+click a `file:line` in the output to open it.
- Shift+F11 (or `:scrollback`) opens the output in a tab you can search.

See [Terminal tabs](https://skink.cc/tools/terminal-tabs/).

For a quick one-off command, `:run CMD` runs it in the background in the project root and shows the output in a read-only tab.

**Tip:**
Want an AI agent to fix the failures? In the task's terminal tab, press Alt+Shift+E to send the last command and its output to the agent. See [AI agents](https://skink.cc/tools/ai-agents/).
