Token导航 LogoToken导航TokenDH.com
开发执行命令github未标认证来源可访问许可证需确认审计提醒

dstackdstack 命令行

Agent Skill

dstack 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要围绕仓库状态、代码变更或协作事项进行整理时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

1,576

周安装

65

GitHub Stars

2,095

下载量

515
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:dstack(dstack 命令行)
来源仓库:https://github.com/dstackai/dstack
仓库路径:skills/dstack
安装命令:
npx skills add https://github.com/dstackai/dstack --skill dstack
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/dstackai/dstack --skill dstack

简介

dstack 用于在 GPU 云、Kubernetes 和本地环境编排开发工作负载。

  • 适用于创建和管理开发环境、任务执行和服务部署等基础设施场景。
  • 支持通过 *.dstack.yml 配置文件定义资源需求和工作流,提供统一调度。
  • 使用前需配置服务器连接和项目设置,注意资源配额和成本控制。
  • dstack 属于开发类 Skill,可作为该场景下的辅助能力补充。

SKILL.md

dstack

Overview

dstack provisions and orchestrates workloads across GPU clouds, Kubernetes, and on-prem via fleets.

When to use this skill:

  • Running or managing dev environments, tasks, or services on dstack
  • Creating, editing, or applying *.dstack.yml configurations
  • Managing fleets, volumes, and resource availability

How it works

dstack operates through three core components:

  1. dstack server - Can run locally, remotely, or via dstack Sky (managed)
  2. dstack CLI - Applies configurations and manages resources; the CLI can be pointed to a server and default project (~/.dstack/config.yml or via dstack project)
  3. dstack configuration files - YAML files ending with .dstack.yml

dstack apply plans, provisions cloud resources, and schedules containers/runners. By default it attaches when the run reaches running (opens SSH tunnel, forwards ports, streams logs). With -d, it submits and exits.

Quick agent flow (detached runs)

  1. Show plan: echo "n" | dstack apply -f <config>
  2. If plan is OK and user confirms, apply detached: dstack apply -f <config> -y -d
  3. Check status once: dstack ps -v
  4. If dev-environment or task with ports and running: attach to surface IDE link/ports/SSH alias (agent runs attach in background); ask to open link
  5. If attach fails in sandbox: request escalation; if not approved, ask the user to run dstack attach locally and share the output

CRITICAL: Never propose dstack CLI commands or YAML syntaxes that don't exist.

  • Only use CLI commands and YAML syntax documented here or verified via --help
  • If uncertain about a command or its syntax, check the links or use --help

NEVER do the following:

  • Invent CLI flags not documented here or shown in --help
  • Guess YAML property names - verify in configuration reference links
  • Run dstack apply for runs without -d in automated contexts (blocks indefinitely)
  • Retry failed commands without addressing the underlying error
  • Summarize or reformat tabular CLI output - show it as-is
  • Use echo "y" | when -y flag is available
  • Assume a command succeeded without checking output for errors

Agent execution guidelines

Output accuracy

  • NEVER reformat, summarize, or paraphrase CLI output. Display tables, status output, and error messages exactly as returned.
  • When showing command results, use code blocks to preserve formatting.
  • If output is truncated due to length, indicate this clearly (e.g., "Output truncated. Full output shows X entries.").

Verification before execution

  • When uncertain about any CLI flag or YAML property, run dstack <command> --help first.
  • Never guess or invent flags. Example verification commands: dstack --help # List all commands dstack apply --help <configuration type> # Flags for apply per configuration type (dev-environment, task, service, fleet, etc) dstack fleet --help # Fleet subcommands dstack ps --help # Flags for ps
  • If a command or flag isn't documented, it doesn't exist.

Command timing and confirmation handling

Commands that stream indefinitely in the foreground:

  • dstack attach
  • dstack apply without -d for runs
  • dstack ps -w

Agents should avoid blocking: use -d, timeouts, or background attach. When attach is needed, run it in the background by default (nohup...), but describe it to the user simply as "attach" unless they ask for a live foreground session. Prefer dstack ps -v and poll in a loop if the user wants to watch status.

All other commands: Use 10-60s timeout. Most complete within this range. While waiting, monitor the output - it may contain errors, warnings, or prompts requiring attention.

Confirmation handling:

  • dstack apply, dstack stop, dstack fleet delete require confirmation
  • Use -y flag to auto-confirm when user has already approved
  • For dstack stop, always use -y after the user confirms to avoid interactive prompts
  • Use echo "n" | to preview dstack apply plan without executing (avoid echo "y" |, prefer -y)

Best practices:

  • Prefer modifying configuration files over passing parameters to dstack apply (unless it's an exception)
  • When user confirms deletion/stop operations, use -y flag to skip confirmation prompts

Detached run follow-up (after -d)

After submitting a run with -d (dev-environment, task, service), first determine whether submission failed. If the apply output shows errors (validation, no offers, etc.), stop and surface the error.

If the run was submitted, do a quick status check with dstack ps -v, then guide the user through relevant next steps: If you need to prompt for next actions, be explicit about the dstack step and command (avoid vague questions). When speaking to the user, refer to the action as "attach" (not "background attach").

  • Monitor status: Report the current status (provisioning/pulling/running/finished) and offer to keep watching. Poll dstack ps -v every 10-20s if the user wants updates.
  • Attach when running: For agents, run attach in the background by default so the session does not block. Use it to capture IDE links/SSH alias or enable port forwarding; when describing the action to the user, just say "attach".
  • Dev environments or tasks with ports: Once running, attach to surface the IDE link/port forwarding/SSH alias, then ask whether to open the IDE link. Never open links without explicit approval.
  • Services: Prefer using service endpoints. Attach only if the user explicitly needs port forwarding or full log replay.
  • Tasks without ports: Default to dstack logs for progress; attach only if full log replay is required.

Attaching behavior (blocking vs non-blocking)

dstack attach runs until interrupted and blocks the terminal. Agents must avoid indefinite blocking. If a brief attach is needed, use a timeout to capture initial output (IDE link, SSH alias) and then detach.

Note: dstack attach writes SSH alias info under ~/.dstack/ssh/config (and may update ~/.ssh/config) to enable ssh <run name>, IDE connections, port forwarding, and real-time logs (dstack attach --logs). If the sandbox cannot write there, the alias will not be created.

Permissions guardrail: If dstack attach fails due to sandbox permissions, request permission escalation to run it outside the sandbox. If escalation isn’t approved or attach still fails, ask the user to run dstack attach locally and share the IDE link/SSH alias output.

Background attach (non-blocking default for agents):

nohup dstack attach <run name> --logs > /tmp/<run name>.attach.log 2>&1 & echo $! > /tmp/<run name>.attach.pid

Then read the output:

tail -n 50 /tmp/<run name>.attach.log

Offer live follow only if asked:

tail -f /tmp/<run name>.attach.log

Stop the background attach (preferred):

kill "$(cat /tmp/<run name>.attach.pid)"

If the PID file is missing, fall back to a specific match (avoid killing all attaches):

pkill -f "dstack attach <run name>"

Why this helps: it keeps the attach session alive (including port forwarding) while the agent remains usable. IDE links and SSH instructions appear in the log file -- surface them and ask whether to open the link (open "<link>" on macOS, xdg-open "<link>" on Linux) only after explicit approval.

If background attach fails in the sandbox (permissions writing ~/.dstack or ~/.ssh, timeouts), request escalation to run attach outside the sandbox. If not approved, ask the user to run attach locally and share the IDE link/SSH alias.

Interpreting user requests

"Run something": When the user asks to run a workload (dev environment, task, service), use dstack apply with the appropriate configuration. Note: dstack run only supports dstack run get --json for retrieving run details -- it cannot start workloads.

"Connect to" or "open" a dev environment: If a dev environment is already running, use dstack attach <run name> --logs (agent runs it in the background by default) to surface the IDE URL (cursor://, vscode://, etc.) and SSH alias. If sandboxed attach fails, request escalation or ask the user to run attach locally and share the link.

Configuration types

dstack supports five main configuration types. Configuration files can be named <name>.dstack.yml or simply .dstack.yml.

Common parameters: All run configurations (dev environments, tasks, services) support many parameters including:

  • Git integration: Clone repos automatically (repo), mount existing repos (repos)
  • File upload: files (see concept docs for examples)
  • Docker support: Use custom Docker images (image); use docker: true if you want to use Docker from inside the container (VM-based backends only)
  • Environment: Set environment variables (env), often via .envrc. Secrets are supported but less common.
  • Storage: Persistent network volumes (volumes), specify disk size
  • Resources: Define GPU, CPU, memory, and disk requirements

Best practices:

  • Prefer giving configurations a name property for easier management
  • When configurations need credentials (API keys, tokens), list only env var names in the env section (e.g., - HF_TOKEN), not values. Recommend storing actual values in a .envrc file alongside the configuration, applied via source.envrc && dstack apply.
  • python and image are mutually exclusive in run configurations. If image is set, do not set python.

files and repos intent policy

Use files and repos only when the user intends to use local/repo files inside the run.

  • If user asks to use project code/data/config in the run, then add files or repos as appropriate.
  • If it is totally unclear whether files ore repos must be mounted, ask one explicit clarification question or default to not mounting.

files guidance:

  • Relative paths are valid and preferred for local project files.
  • A relative files path is placed under the run's working_dir (default or set by user).

repos + image/working directory guidance:

  • With non-default Docker images, prefer explicit absolute mount targets for repos (e.g., .:/dstack/run).
  • When setting an explicit repo mount path, also set working_dir to the same path.
  • Reason: custom images may have a different/non-empty default working directory, and mounting a repo into a non-empty path can fail.
  • With dstack default images, the default working_dir is already /dstack/run.

AMD image selection policy

When resources.gpu targets AMD (e.g., MI300X), you have to set image.

Use the official ROCm Docker image namespace as the default source: https://hub.docker.com/u/rocm

  1. If the user provides an image, use it as-is. Do not override user intent.
  2. **If the user asks for a specific framework/runtime, prefer official rocm/* framework images and select tags with the latest available ROCm version by default. Pick the most recent ROCm-compatible tag appropriate for the requested AMD GPU family.**

- SGLang: rocm/sgl-dev - vLLM: rocm/vllm - PyTorch-only: rocm/pytorch

  1. If no framework is specified (generic AMD dev/task use case), default to rocm/dev-ubuntu-24.04.

Additional guidance:

  • Prefer :latest where applicable for generic/default recommendations, unless the user asks for pinning or reproducibility.
  • Ensure AMD-compatible images include ROCm userspace/tooling; avoid non-ROCm images for AMD GPU runs.

1. Dev environments

Use for: Interactive development with IDE integration (VS Code, Cursor, etc.).

type: dev-environment
name: cursor

python: "3.12"
ide: vscode

resources:
  gpu: 80GB

Concept documentation | Configuration reference

2. Tasks

Use for: Batch jobs, training runs, fine-tuning, web applications, any executable workload.

Key features: Distributed training (multi-node) and port forwarding for web apps.

type: task
name: train

python: "3.12"
env:
  - HUGGING_FACE_HUB_TOKEN
commands:
  - uv pip install -r requirements.txt
  - uv run python train.py
ports:
  - 8501  # Optional: expose ports for web apps

resources:
  gpu: A100:40GB:2

Port forwarding: When you specify ports, dstack apply forwards them to localhost while attached. Use dstack attach <run name> to reconnect and restore port forwarding. The run name becomes an SSH alias (e.g., ssh <run name>) for direct access.

Distributed training: Multi-node tasks are supported (e.g., via nodes) and require fleets that support inter-node communication (see placement: cluster in fleets).

Concept documentation | Configuration reference

3. Services

Use for: Deploying models or web applications as production endpoints.

Key features: OpenAI-compatible model serving, auto-scaling (RPS/queue), custom gateways with HTTPS.

type: service
name: llama31

python: "3.12"
env:
  - HF_TOKEN
commands:
  - uv pip install vllm
  - uv run vllm serve meta-llama/Meta-Llama-3.1-8B-Instruct
port: 8000
model: meta-llama/Meta-Llama-3.1-8B-Instruct

resources:
  gpu: 80GB
  disk: 200GB

Service endpoints:

  • Without gateway: <dstack server URL>/proxy/services/f/<run name>/
  • With gateway: https://<run name>.<gateway domain>/
  • Authentication: Unless auth is false, include Authorization: Bearer <DSTACK_TOKEN> on all service requests.
  • Model endpoint: If model is set, service.model.base_url from dstack run get <run name> --json provides the model endpoint. For OpenAI-compatible models (the default, unless format is set otherwise), this will be service.url + /v1.
  • Example (with gateway): curl -sS -X POST "https://<run name>.<gateway domain>/v1/chat/completions" \ -H "Authorization: Bearer <dstack token>" \ -H "Content-Type: application/json" \ -d '{"model":"<model name>","messages":[{"role":"user","content":"Hello"}],"max_tokens":64}'

Concept documentation | Configuration reference

4. Fleets

Use for: Pre-provisioning infrastructure for workloads, managing on-prem GPU servers, creating auto-scaling instance pools.

type: fleet
name: my-fleet
nodes: 0..2

resources:
  gpu: 24GB..
  disk: 200GB

spot_policy: auto # other values: spot, on-demand
idle_duration: 5m

On-demand provisioning: When nodes is a range (e.g., 0..2), dstack creates a template and provisions instances on demand within the min/max. Use idle_duration to terminate idle instances.

Distributed workloads: Use placement: cluster for fleets intended for multi-node tasks that require inter-node networking.

SSH fleet (on-prem or pre-provisioned):

type: fleet
name: on-prem-fleet

ssh_config:
  user: ubuntu
  identity_file: ~/.ssh/id_rsa
  hosts:
    - 192.168.1.10
    - 192.168.1.11

Concept documentation | Configuration reference

5. Volumes

Use for: Persistent storage for datasets, model checkpoints, training artifacts.

type: volume
name: my-volume

backend: aws
region: us-east-1

resources:
  disk: 500GB

Instance volumes (local, ephemeral, often optional):

type: dev-environment
# ... other config
volumes:
  - instance_path: /dstack-cache/pip
    path: /root/.cache/pip
    optional: true
  - instance_path: /dstack-cache/huggingface
    path: /root/.cache/huggingface
    optional: true

Attach to runs: Use volumes in dev environments, tasks, and services. Network volumes persist independently; instance volumes are tied to the instance lifecycle.

Concept documentation | Configuration reference

Essential CLI commands

Apply configurations

Important behavior:

  • dstack apply shows a plan with estimated costs and may ask for confirmation
  • In attached mode (default), the terminal blocks and shows output
  • In detached mode (-d), runs in background without blocking the terminal

Workflow for applying run configurations (dev-environment, task, service):

  1. Show plan: echo "n" | dstack apply -f config.dstack.yml Display the FULL output including the offers table and cost estimate. Do NOT summarize or reformat.
  2. Wait for user confirmation. Do NOT proceed if:

- Output shows "No offers found" or similar errors - Output shows validation errors - User has not explicitly confirmed

  1. Execute (only after user confirms): dstack apply -f config.dstack.yml -y -d
  2. Verify apply status: dstack ps -v

Workflow for infrastructure (fleet, volume, gateway):

  1. Show plan: echo "n" | dstack apply -f fleet.dstack.yml Display the FULL output. Do NOT summarize or reformat.
  2. Wait for user confirmation.
  3. Execute: dstack apply -f fleet.dstack.yml -y
  4. Verify: Use dstack fleet, dstack volume, or dstack gateway respectively.

Fleet management

# Create/update fleet
dstack apply -f fleet.dstack.yml

# List fleets
dstack fleet

# Get fleet details
dstack fleet get my-fleet

# Get fleet details as JSON (for troubleshooting)
dstack fleet get my-fleet --json

# Delete entire fleet (use -y when user already confirmed)
dstack fleet delete my-fleet -y

# Delete specific instance from fleet (use -y when user already confirmed)
dstack fleet delete my-fleet -i <instance num> -y

Monitor runs

# List all runs
dstack ps

# Verbose output with full details
dstack ps -v

# JSON output (for troubleshooting/scripting)
dstack ps --json

# Get specific run details as JSON
dstack run get my-run-name --json

Attach to runs

# Attach and replay logs from start (preferred, unless asked otherwise)
dstack attach my-run-name --logs

# Attach without replaying logs (restores port forwarding + SSH only)
dstack attach my-run-name

View logs

# Stream logs (tail mode)
dstack logs my-run-name

# Debug mode (includes additional runner logs)
dstack logs my-run-name -d

# Fetch logs from specific replica (multi-node runs)
dstack logs my-run-name --replica 1

# Fetch logs from specific job
dstack logs my-run-name --job 0

Stop runs

# Stop specific run (use -y after user confirms)
dstack stop my-run-name -y

# Abort (force stop)
dstack stop my-run-name --abort

List offers

Offers represent available instance configurations available for provisioning across backends. By default, dstack offer ignores fleet configurations and shows all available offers that match the request. Use --fleet to inspect offers available through specific fleets.

# Filter by specific backend
dstack offer --backend aws

# Filter by GPU type
dstack offer --gpu A100

# Filter by GPU memory
dstack offer --gpu 24GB..80GB

# Combine filters
dstack offer --backend aws --gpu A100:80GB

# Limit to a specific fleet
dstack offer --fleet my-fleet

# Combine offers from multiple fleets
dstack offer --fleet my-fleet --fleet other-fleet

# JSON output (for troubleshooting/scripting)
dstack offer --json

With one --fleet, dstack offer shows offers available through that fleet. With multiple --fleet, it combines offers available through the selected fleets. Identical backend offers are shown once, while matching existing instances stay separate.

Max offers: By default, dstack offer returns first N offers (output also includes the total number). Use --max-offers N to increase the limit. Grouping: Prefer --group-by gpu (other supported values: gpu,backend, gpu,backend,region) for aggregated output across all offers, not --max-offers.

Troubleshooting

When diagnosing issues with dstack workloads or infrastructure:

  1. Use JSON output for detailed inspection: dstack fleet get my-fleet --json dstack run get my-run --json dstack ps -n 10 --json dstack offer --json
  2. Check verbose run status: dstack ps -v
  3. Examine logs with debug output: dstack logs my-run -d
  4. Attach with log replay: dstack attach my-run --logs

Common issues:

  • No offers: Check dstack offer and ensure that at least one fleet matches requirements
  • No fleet: Ensure at least one fleet is created
  • Configuration errors: Validate YAML syntax; check dstack apply output for specific errors
  • Provisioning timeouts: Use dstack ps -v to see provisioning status; consider spot vs on-demand
  • Connection issues: Verify server status, check authentication, ensure network access to backends

When errors occur:

  1. Display the full error message unchanged
  2. Do NOT retry the same command without addressing the error
  3. Refer to the Troubleshooting guide for guidance

Additional resources

Core documentation:

Additional concepts:

Guides:

Accelerator-specific examples:

Full documentation: https://dstack.ai/llms-full.txt

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

34.31%
按下载量换算177

Claude

29.89%
按下载量换算154

Cursor

20.74%
按下载量换算107

Gemini CLI

8.85%
按下载量换算46

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

可疑

权限和风险

执行命令

安装流程涉及命令执行,可能通过 npx skills add https://github.com/dstackai/dstack --skill dstack 联网下载 Skill 或依赖。用户安装前应确认命令来源、仓库内容和执行环境。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在 warning/failed 结果,不能写成本站确认安全。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills