一键导入
command-execution
Terminal command safety, delegation routing, and guarded execution. Load when running shell commands or delegating to Bash subagents
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Terminal command safety, delegation routing, and guarded execution. Load when running shell commands or delegating to Bash subagents
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
External API evaluation and MCP server wrapper generation. Load when integrating a REST/GraphQL API as a workspace tool
Capability-based provider system patterns. Load when creating providers or wiring module-provider integration
Full-stack WebSocket subscription development. Load when adding WS routes, topic services, or debugging WS data flows
Systematic Python type error resolution (mypy/pyright). Load when fixing backend type check failures
Type-first Python with Pydantic, Protocol, and discriminated unions. Load when writing models or enforcing typing
Systematic type error resolution for Python (mypy/pyright) and TypeScript (vue-tsc). Use when fixing type errors, resolving type check failures, or optimizing type imports.
| name | command-execution |
| description | Terminal command safety, delegation routing, and guarded execution. Load when running shell commands or delegating to Bash subagents |
| user-invocable | false |
Terminal command safety and guarded execution for Claude Code CLI. Covers both direct execution (quick commands run inline) and delegated execution (commands dispatched to Bash subagents with full pre-flight validation).
Apply when:
Task(subagent_type="Bash")</when_to_use>
ls, cat, git status, make -C backend testDelegate via Task(subagent_type="Bash") with this skill's methodology. The subagent runs command guards (G1-G5) for safe, auto-approved execution.
| Signal | Why Delegate |
|---|---|
| Expected output >5KB | Keeps parent context clean — executor summarizes findings |
| 3+ commands to run | Parallelization and batch cleanup value |
| Daemon/server lifecycle | Reliable start, capture, kill lifecycle management |
| Large build output | Timeout enforcement + post-capture extraction |
| Command requires Makefile discovery | Only if parent doesn't already know the target |
Single command, output <5KB, command known?
YES → Run directly (apply pre-command checks below)
NO ↓
Multiple commands needing parallel execution?
YES → Delegate: Task(subagent_type="Bash") + command-execution skill
NO ↓
Expected output >5KB or needs post-capture extraction?
YES → Delegate: Task(subagent_type="Bash") + command-execution skill
NO ↓
Daemon lifecycle (start, observe, kill)?
YES → Delegate: Task(subagent_type="Bash") + command-execution skill
NO → Run directly
MANDATORY pre-flight — run for EVERY command before execution.
COMMAND GUARD — Pre-Flight Checklist
│
├── G1. ALLOWLIST CHECK
│ Does the command match a settings.json allow pattern?
│ ✅ make -f project.mk * ✅ make -C backend *
│ ✅ make -C frontend * ✅ poetry run pytest *
│ ✅ poetry run python * ✅ poetry run mypy/pyright/black/isort *
│ ✅ npm run * ✅ npx *
│ ✅ git (read ops) ✅ gh *
│ ✅ docker-compose -f docker-compose.dev.yml *
│ ✅ docker ps/logs ✅ ls/pwd/which/wc/sort/uniq
│ ❌ NOT ON LIST → REFUSE — report "BLOCKED: command not in allowlist"
│
├── G2. DENYLIST CHECK
│ Does the command match a settings.json deny pattern?
│ ❌ rm -rf * ❌ sudo * ❌ curl/wget *
│ ❌ pip install * ❌ npm install * ❌ poetry add/remove *
│ ❌ git push --force * ❌ git reset --hard *
│ ❌ git checkout . / git clean ❌ docker rm/rmi *
│ ❌ kill -9 * ❌ alembic downgrade *
│ MATCH → REFUSE — report "BLOCKED: command in denylist"
│
├── G3. ENVIRONMENT WRAPPER
│ Is the command using proper project wrappers?
│ ❌ npm test → ✅ make -C frontend test
│ ❌ python script.py → ✅ poetry run python script.py
│ ❌ pip install X → ✅ make target (denied anyway)
│ ❌ pytest → ✅ poetry run pytest / make -C backend test
│ BARE COMMAND → REFUSE — report "BLOCKED: missing env wrapper"
│
├── G4. TIMEOUT ENFORCEMENT
│ Every command MUST have a timeout.
│ | Command Type | Timeout |
│ |---------------------------|---------|
│ | File reads, git ops | 30s |
│ | Tests, incremental builds | 120s |
│ | Clean builds, installs | 300s |
│ | Docker builds | 600s |
│ Rule: 2-3x estimated duration. Always use `2>&1`.
│ NO TIMEOUT → ADD ONE before execution.
│
└── G5. OUTPUT PLAN
Expected output >50KB?
YES → Note in report; use Bash timeout to prevent truncation issues
NO → Direct capture
Before executing, emit a one-line verdict:
GUARD: ✅ PASS — `make -C backend test` [timeout: 120s] [output: <5KB]
GUARD: ❌ BLOCKED — `pip install requests` — denylist match (G2)
</command_guards>
Classify the invocation to select the execution path:
| Signal | Path |
|---|---|
| Caller provided exact command + timeout → single command | FAST — skip to Phase 2 |
| Caller provided exact commands + timeout → multiple commands | BATCH — Phase 1 dependency check, then Phase 2 |
| Caller provided description, not exact command | FULL — Phase 1 discovery, then Phase 2 |
make -C backend / poetry run; Node → make -C frontend / nvm use &&; Docker/git → direct OKRun command guards (G1-G5) for EVERY command. No exceptions.
For each command that passes guards:
Bash tool with appropriate timeoutBash tool calls in a single message (Claude Code runs them concurrently)Bash with && chaining, or sequential tool calls where exit code mattersBash(run_in_background: true), then TaskOutput to check statusAlways include 2>&1 to capture stderr.
For each completed command:
Callers invoke via Task(subagent_type="Bash") with skill context:
You are a command execution specialist. Follow the command-execution skill methodology:
- Run command guards (G1-G5) before every command
- Use proper environment wrappers (make targets, poetry run)
- Apply timeouts to all commands
- Return structured execution report
Execute: `{command}` [timeout: {N}s]
Extract: {what to look for — errors, test failures, coverage}
Context: {why these commands are being run}
Single command:
Execute: `make -C backend test` [timeout: 120s]
Extract: test results, failures, coverage numbers
Context: validating backend after broker module refactor
Parallel batch:
Execute the following commands in parallel:
1. `make -C backend test` [timeout: 120s]
2. `make -C frontend test` [timeout: 120s]
Extract: test results and failures from each
Context: pre-commit validation across both stacks
Sequential chain:
Execute sequentially:
1. `make -C backend generate` [timeout: 120s]
2. `make -C frontend generate` [timeout: 120s]
3. `make -C frontend test` [timeout: 120s]
Extract: errors at each step; final test results
Context: regenerating clients from updated models, then validating
Daemon lifecycle:
Execute: `make -f project.mk dev-backend` as background [timeout: 30s for startup check]
Extract: startup confirmation, bound port, initialization errors
Context: verify backend starts cleanly after config change
</caller_protocol>
## Command Execution Report
### Guard Verdicts
| # | Command | Verdict |
|---|---------|---------|
| 1 | `{cmd}` | ✅ PASS [timeout: Ns] |
| 2 | `{cmd}` | ❌ BLOCKED — {reason} |
### Execution Summary
| # | Command | Status | Duration | Exit Code |
|---|---------|--------|----------|-----------|
| 1 | `{cmd}` | ✅ Success / ❌ Failed / ⏰ Timeout | {N}s | {code} |
### Findings
#### Command 1: `{short_cmd}`
**Key Output**:
{Relevant extracted content per caller's Extract request}
**Errors/Warnings** (if any):
{Error or warning text}
</output_format>
| Don't | Do Instead |
|---|---|
| Skip command guards for "obvious" commands | Run guards G1-G5 for every command — no exceptions |
npm run build (bare command) | make -C frontend build (env-aware wrapper) |
| Execute without timeout | Always set timeout per G4 table |
Pipe during execution (cmd | head -50) | Capture full output, extract post-execution |
Guess a make target name | Search Makefiles to verify target exists |
| Run denied commands and ask forgiveness | Check denylist first — refuse immediately |
| Modify files or write code | You are an executor, not an implementer |
| Ignore exit codes | Check $?: 0=success, 124=timeout, other=failure |
Delegate a simple make test | Run directly — delegation overhead exceeds value |
| Run 5 parallel commands manually in parent | Delegate — executor handles parallel launch + batch cleanup |
</anti_patterns>