Agent Skillsvoidzero-dev/vite-plus › spawn-process

spawn-process

GitHub

指导在 Rust 项目中通过 vp_command crate 安全地执行子进程,涵盖二进制解析、命令构建及跨平台兼容处理。

.claude/skills/spawn-process/SKILL.md voidzero-dev/vite-plus

Trigger Scenarios

需要执行外部程序或脚本 Rust 代码中涉及 subprocess 调用

Install

npx skills add voidzero-dev/vite-plus --skill spawn-process -g -y
More Options

Non-standard path

npx skills add https://github.com/voidzero-dev/vite-plus/tree/main/.claude/skills/spawn-process -g -y

Use without installing

npx skills use voidzero-dev/vite-plus@spawn-process

指定 Agent (Claude Code)

npx skills add voidzero-dev/vite-plus --skill spawn-process -a claude-code -g -y

安装 repo 全部 skill

npx skills add voidzero-dev/vite-plus --all -g -y

预览 repo 内 skill

npx skills add voidzero-dev/vite-plus --list

SKILL.md

Frontmatter
{
    "name": "spawn-process",
    "description": "Guide for writing subprocess execution code using the vp_command crate",
    "allowed-tools": "Read, Grep, Glob, Edit, Write, Bash"
}

Add Subprocess Execution Code

When writing Rust code that needs to spawn subprocesses (resolve binaries, build commands, execute programs), always use the vp_command crate. Never use which, tokio::process::Command::new, or std::process::Command::new directly.

Available APIs

vp_command::resolve_bin(name, path_env, cwd) — Resolve a binary name to an absolute path

Handles PATHEXT (.cmd/.bat) on Windows. Pass None for path_env to search the current process PATH.

// Resolve using current PATH
let bin = vp_command::resolve_bin("node", None, &cwd)?;

// Resolve using a custom PATH
let custom_path = std::ffi::OsString::from(&path_env_str);
let bin = vp_command::resolve_bin("eslint", Some(&custom_path), &cwd)?;

vp_command::build_command(bin_path, cwd) — Build a command for a pre-resolved binary

Returns tokio::process::Command with cwd, inherited stdio, and fix_stdio_streams on Unix already configured. Add args, envs, or override stdio as needed.

let bin = vp_command::resolve_bin("eslint", None, &cwd)?;
let mut cmd = vp_command::build_command(&bin, &cwd);
cmd.args(&[".", "--fix"]);
cmd.env("NODE_ENV", "production");
let mut child = cmd.spawn()?;
let status = child.wait().await?;

vp_command::build_shell_command(shell_cmd, cwd) — Build a shell command

Uses /bin/sh -c on Unix, cmd.exe /C on Windows. Same stdio and fix_stdio_streams setup as build_command.

let mut cmd = vp_command::build_shell_command("echo hello && ls", &cwd);
let mut child = cmd.spawn()?;
let status = child.wait().await?;

vp_command::run_command(bin_name, args, envs, cwd) — Resolve + build + run in one call

Combines resolve_bin, build_command, and status().await. The envs HashMap must include "PATH" if you want custom PATH resolution.

let envs = HashMap::from([("PATH".to_string(), path_value)]);
let status = vp_command::run_command("node", &["--version"], &envs, &cwd).await?;

Dependency Setup

Add vp_command to the crate's Cargo.toml:

[dependencies]
vp_command = { workspace = true }

Do NOT add which as a direct dependency — binary resolution goes through vp_command::resolve_bin.

Exception

crates/vp_global_cli/src/shim/exec.rs uses synchronous std::process::Command with Unix exec() for process replacement. This is the only place that bypasses vp_command.

Version History

  • 8917f4a Current 2026-08-15 03:00

    核心依赖从 vite_command 变更为 vp_command。

  • a24eede 2026-07-24 11:29

Same Skill Collection

.claude/skills/add-ecosystem-ci/SKILL.md
.claude/skills/bump-vite-task/SKILL.md
.claude/skills/release-manager/SKILL.md
.claude/skills/sync-tsdown-cli/SKILL.md
.claude/skills/sync-upstream-cli-help/SKILL.md
.claude/skills/sync-upstream-dependency-docs/SKILL.md
.claude/skills/test-pkg-pr-new-migrate/SKILL.md
.claude/skills/verify-interactive-cli/SKILL.md

Metadata

Files
0
Version
aedb3d1
Hash
e28a7d2e
Indexed
2026-07-24 11:29

inicio - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-08-17 15:43
浙ICP备14020137号-1 $mapa de visitantes$