| name | nextask |
| description | Enqueue, monitor, and manage distributed tasks using the nextask CLI. Handles enqueueing commands with source snapshots, streaming live output, filtering and tagging tasks, managing workers, running sweeps, and batch processing. Use when the user mentions nextask, wants to run commands on remote workers, check task status, stream logs, manage a task queue, or organize runs with tags. Triggers even for "run this on the server", "check my training jobs", or "sweep over these parameters". |
| user-invocable | false |
See the README for install instructions and full documentation.
Use it to run commands on remote worker machines.
Common workflows
Enqueue a task
nextask enqueue "python train.py --lr 0.001" --snapshot --tag model=resnet,lr=0.001
--snapshot captures the current working tree (including uncommitted changes) and pushes to a git remote
--remote <url|path> override source remote for this snapshot
--tag key=value adds metadata for filtering (repeatable, both key and value required)
--attach / -a streams live output after enqueuing
Monitor tasks
nextask list
nextask list --status running
nextask list --tag sweep=exp3
nextask list --command "train"
nextask list --since 1h
nextask list --json
nextask show <id>
nextask log <id>
nextask log <id> --attach
nextask log <id> --tail 50 --attach
nextask log <id> --stream stderr
nextask wait <id>
nextask wait --tag sweep=exp3
nextask wait <id1> <id2> --any
Cancel / remove
nextask cancel <id>
nextask remove <id>
Workers
nextask worker
nextask worker --filter gpu=a100
nextask worker --once
nextask worker --once --rm
nextask worker --daemon
nextask worker --timeout 24h
nextask worker --exit-if-idle 5m
nextask worker --workdir /data/nextask
nextask worker list
nextask worker stop <id>
Example usages
Hyperparameter sweep
for lr in 0.1 0.01 0.001; do
nextask enqueue "python train.py --lr $lr" --snapshot --tag sweep=lr,lr=$lr
done
nextask wait --tag sweep=lr
nextask list --tag sweep=lr
Run and watch
nextask enqueue "python train.py" --snapshot --attach
Batch processing
for dataset in train val test; do
nextask enqueue "python process.py --data $dataset" --tag job=preprocess,data=$dataset
done
nextask wait --tag job=preprocess
One-off remote execution
nextask enqueue "nvidia-smi" --attach
Route to specific workers
nextask enqueue "python train.py" --snapshot --tag gpu=a100
nextask worker --filter gpu=a100
Saving results from tasks
Tasks run in a cloned workdir on the worker. To persist results (CSVs, models, logs), have the task commit and push them back:
nextask enqueue 'python train.py --output results.csv && git add results.csv && git commit -m "results" && git push origin HEAD' --snapshot
Or write results to a shared filesystem / object store that both the enqueue machine and worker can access.
Tagging and querying
Tags are key=value pairs for organizing, filtering, and routing tasks.
nextask enqueue "python run.py" --tag project=myapp,env=staging
nextask list --tag project=myapp
nextask list --tag project=myapp --status completed
nextask wait --tag project=myapp
nextask enqueue "python run.py" --tag gpu=a100
nextask worker --filter gpu=a100
Setup
nextask init db
nextask config
Related skills
nextask-setup-services — deploy PostgreSQL and a git server for snapshots. Use whenever services need to be set up, changed, or are not working.
nextask-setup-worker — set up workers (local, remote, cloud). Use whenever a worker needs to be added or reconfigured.
Configuration
Priority: CLI flags > ENV vars > .nextask.toml > ~/.config/nextask/global.toml.
Set db.url via --db-url, NEXTASK_DB_URL, or in config files.
Set source.remote for snapshot storage.
Key concepts
- Tasks go through:
pending → running → completed | failed | cancelled | stale
- Workers claim tasks atomically from PostgreSQL
- Heartbeats detect stale workers; tasks on dead workers become
stale
- Logs are captured in batches with stdout/stderr separation
- Snapshots preserve exact source code state without modifying the local repo. Pushed to
<source-remote>/refs/heads/<project-dir-name>/<taskID> (e.g., for task fmc17eq5 in a repo named myproject: refs/heads/myproject/fmc17eq5)
Troubleshooting
| Symptom | Fix |
|---|
Tasks stuck pending | Check nextask worker list, ensure --filter tags match --tag |
Tasks go stale | Worker crashed, check logs and restart |
| Worker can't reach DB | Verify URL, check firewall, test with nextask list --db-url "..." from worker host |
git clone fails in worker | Wrong source remote or token expired, verify with git ls-remote |
nextask list shows nothing | Check --db-url or config, try nextask config to see loaded values |