技能创建器
skill-creator
创建、改进和评估自定义技能,把专业流程转化为可重复使用的 AI 能力。
shell_command【数据与研究】Run non-interactive shell commands inside an allowed workspace. First read the complete builtin://shell_command/SKILL.md to get skillToken; this SKILL.md read does not require skillToken. Do not use regex or partial reads to fetch only the token. Later calls without the correct skillToken will fail and must be retried, so get the token before running…
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
Use this bundled skill when the task is best handled by a terminal command: listing files, searching text, reading files, checking Git state, running builds/tests/formatters, starting a local dev server, or executing a project script.
This skill is intentionally a small terminal orchestration layer. It follows the same practical pattern used by coding agents such as Codex: keep commands non-interactive, keep the working directory explicit, prefer fast search/read tools, stream output back to the model, and let policy decide whether sensitive commands are allowed, denied, or require user confirmation.
rg as the default first tool for all project exploration and narrowing work, including project structure, file discovery, code navigation, symbol lookup, call-site discovery, config lookup, workflow tracing, tests, routes, error messages, broad inventories, and "where is this implemented?" questions.rg to locate candidate files and line numbers before reading file contents. Do not read many whole files to discover where something lives.rg --files first for project structure, file discovery, broad inventories, and file counts.rg -n "pattern" path first for text/code search, workflow tracing, symbol references, config keys, routes, CLI commands, and error strings.rg -n -m 20 "pattern" path when the initial result could be large.rg --files | rg "name-or-extension" for fast filename narrowing.git ls-files for "tracked files only" counts or inventories.Get-ChildItem only for simple, shallow Windows directory listings, for example Get-ChildItem -Name or Get-ChildItem -Name -Filter *.rs.Get-ChildItem -Recurse, find . -type f, dir /s, ls -R, or du for repository-wide discovery, search, inventories, or counts unless the command includes explicit exclusions and rg is unavailable.If rg is not found, use git ls-files for tracked-file discovery before falling back to platform recursive listings. When falling back to recursive listings, include explicit exclusions for dependency folders, VCS metadata, generated outputs, virtual environments, and caches.
Use rg as the main project navigation tool, not just as a project-structure tool and not only as a code-search tool. The normal investigation loop is:
rg --files when you need the project shape, likely directories, file names, or extension distribution.rg -n.Prefer this pattern over opening many files and scanning them manually. Reading file contents is for understanding confirmed candidates; rg is for finding those candidates.
Useful patterns:
rg -n "SkillConfirmation|handle_builtin_shell_command" cratesrg -n "tools/call|skillToken|allowedDirs" .rg --files | rg "skill|tool|config"rg -n -m 20 "pattern" pathrg -n "pattern" -g "*.rs" -g "*.ts" .cwd to the concrete directory where the command should run.cwd must be inside one configured allowed directory.exec; the gateway runs it through the platform shell. Do not include a shell executable prefix unless you intentionally need a nested shell.powershell -NoProfile -ExecutionPolicy Bypass -Command ... with UTF-8 handling. Write the exec string as PowerShell code by default; do not prefix normal commands with powershell.sh -lc .... Write the exec string as POSIX shell code by default.timeoutMs when a command may take longer than the configured default. Keep it bounded.multi_edit_file skill first.On Windows, treat PowerShell as the primary shell. The gateway already launches the exec text through PowerShell and configures UTF-8 input/output before running the requested command. This means exec should usually be Get-ChildItem -Name, not powershell Get-ChildItem -Name. The UTF-8 handling covers terminal text encoding; it does not make cmd.exe-specific syntax valid inside PowerShell.
External programs are still called directly from PowerShell:
git status --shortcargo testnpm run lintrg -n "pattern" srcPrefer native PowerShell cmdlets and parameters for shallow filesystem operations. For codebase navigation, search, discovery, feature tracing, broad inventories, and counts, use rg first.
Get-ChildItem -Name, Get-ChildItem -Name -Filter *.jsGet-ChildItem -LiteralPath "D:\path with spaces" -NameGet-Content -LiteralPath file.txt -TotalCount 200Test-Path -LiteralPath "D:\path"Remove-Item -LiteralPath file.txtexec: $env:NAME = 'value'; npm testcargo fmt --check; if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }; cargo testAssume Windows PowerShell compatibility unless the environment explicitly says pwsh is used. Avoid PowerShell 7-only operators such as && and || for control flow in Windows examples.
Avoid cmd.exe built-ins and switches unless you explicitly invoke cmd.exe as a fallback. In PowerShell, commands such as dir /b, copy, del, type, set NAME=value, and %VAR% expansion do not behave like they do in cmd.exe. For example, dir /b is wrong in PowerShell because /b is parsed as a path; use Get-ChildItem -Name instead.
Use cmd.exe only for compatibility with a command that genuinely requires cmd.exe syntax:
cmd.exe /d /c dir /b *.jscmd.exe /d /c some-legacy-script.batKeep the cwd argument set to the target workspace even when using cmd.exe as a fallback. Do not switch directories inside the command unless a project script requires it.
On Unix-like systems, the gateway runs exec through sh -lc. Prefer POSIX-compatible shell syntax in examples unless the task explicitly requires Bash, Zsh, Fish, or another shell.
ls -1sed -n '1,200p' file.txtNAME=value npm testcargo fmt --check && cargo testbash -lc 'source scripts/env.sh && ./scripts/test.sh'Use forward-slash paths and quote paths with spaces. Keep cwd set to the workspace instead of relying on cd where possible.
rg --filesrg "pattern" pathrg -n "functionName|StructName|configKey" srcrg -n "handleFoo|FooConfig|foo_enabled" srcrg --files | rg "skills|gateway|config"(rg --files <exclusions> | Measure-Object).CountGet-ChildItem -Name -Filter *.jsGet-Content -LiteralPath path -TotalCount 200sed -n '1,200p' pathgit status --short, git diff -- path, git log --oneline -n 20cargo test, cargo fmt --check, npm test, npm run lintPrefer rg and rg --files for discovery because they are fast and respect ignore files. Packaged gateway builds may provide a bundled rg on PATH; if rg is unavailable, use git ls-files for repository counts or the platform's normal alternative with explicit exclusions.
When the user asks for file counts, repository size, broad file inventories, or similar numeric summaries, do not count dependency folders, VCS metadata, generated outputs, virtual environments, or caches as meaningful project files. These directories can dominate the result and make the answer misleading. This is a hard requirement, not a preference.
Use commands that respect .gitignore and exclude high-volume irrelevant directories before counting:
git ls-files | Measure-Object on Windows, or git ls-files | wc -l on Unix-like systems.(rg --files -g '!node_modules/**' -g '!.git/**' -g '!target/**' -g '!dist/**' -g '!build/**' -g '!coverage/**' -g '!.next/**' -g '!.nuxt/**' -g '!.turbo/**' -g '!.cache/**' -g '!__pycache__/**' -g '!.pytest_cache/**' -g '!.mypy_cache/**' -g '!.ruff_cache/**' -g '!.venv/**' -g '!venv/**' -g '!env/**' -g '!.tox/**' | Measure-Object).Countrg --files -g '!node_modules/**' -g '!.git/**' -g '!target/**' -g '!dist/**' -g '!build/**' -g '!coverage/**' -g '!.next/**' -g '!.nuxt/**' -g '!.turbo/**' -g '!.cache/**' -g '!__pycache__/**' -g '!.pytest_cache/**' -g '!.mypy_cache/**' -g '!.ruff_cache/**' -g '!.venv/**' -g '!venv/**' -g '!env/**' -g '!.tox/**' | wc -lCommon directories to exclude from broad counts and inventories include:
.git, .svn, .hgnode_modules, .pnpm-store, .yarn, .next, .nuxt, .turbo, .parcel-cache, bower_componentstarget, dist, build, out, coverage, .coverage, htmlcov.venv, venv, env, .tox, __pycache__, .pytest_cache, .mypy_cache, .ruff_cache, .nox.cache, .gradle, .idea, .vscode, tmp, tempDo not use broad recursive commands such as Get-ChildItem -Recurse, find . -type f, dir /s, ls -R, or du at the repository root for counts or inventories unless they include explicit exclusions or the workspace is already known to be small. If rg is unavailable, prefer git ls-files for repository counts. For untracked non-ignored files without rg, use the platform's recursive listing only with exclusion filters.
Use the bundled read_file skill as the default way to read text files. It returns stable line-numbered output, enforces allowed-directory boundaries before reading, rejects binary files, and limits large reads. Use terminal reads only when read_file is disabled, unavailable, or clearly unsuitable for the target file type.
Use terminal commands for directory listings, search, generated command output, test/build output, and project-owned tools. Do not use cat, Get-Content, type, sed, head, or tail for ordinary source/config file reads when read_file can do the job.
Use bundled editing skills as the default way to create, modify, or rewrite files by hand. Use multi_edit_file for exact replacements, multi-file edits, file creation, deletion, and moves.
Prefer these editing skills because they give the gateway a clear set of affected paths before files are changed, produce reviewable deltas, and avoid fragile shell redirection or quoting problems.
Use shell-based writes only as a fallback after the bundled editing skills are clearly unsuitable or have failed repeatedly, or when an external tool is the correct owner of the output. Valid examples include:
git apply or a dedicated patch tool.Avoid ad hoc terminal writes such as echo ... > file, here-documents, Set-Content, Out-File, or scripts that manually rewrite source files when multi_edit_file can express the change. If shell-based writing is used as a fallback, explain why the bundled editing skill was not sufficient and keep the command narrowly scoped.
For batch edits to structured files, use structured APIs where practical. Use a JSON parser for JSON instead of regex. For code files, prefer narrow block-aware transformations, generated code followed by the project formatter, or project-owned tooling. Avoid broad regex replacements over Rust, JSON, YAML, TOML, or source files unless the pattern is tightly scoped, verified against current content, and followed by targeted validation.
After any shell-based write, inspect the resulting changes before reporting success:
git diff -- path for focused edits.git diff --stat for multi-file edits.When the terminal is being used to investigate or change code, do not treat "the patch applied" as the finish line. The reliable workflow is to understand the system's intent, make the smallest useful change, and verify the behavior that motivated the change.
git status --short and inspect files you will touch. Work with existing user changes and do not revert unrelated modifications.The gateway evaluates commands against the configured skill policy.
Treat destructive commands as high risk: recursive deletes, force moves, permission changes, process kills, package publishing, credential operations, and networked deployment commands should only run when the user clearly asked for them and policy allows them.
On Windows, do not compose destructive file operations by piping paths into another shell. Prefer native PowerShell cmdlets end to end, use -LiteralPath, and verify resolved absolute paths before recursive delete or move operations.
The gateway captures stdout and stderr and returns them to the caller. Markdown file reads are allowed to return larger output so a model can progressively load SKILL.md files and other instructions. Other command output may be truncated according to the configured limit.
For real command execution, the gateway also records lightweight tool events that admin clients can poll at /api/v2/admin/skills/events?after=<seq>. Shell commands emit started, stdoutDelta, stderrDelta, and finished events. These events are for UI/progress display; the final tool result remains the authoritative command result.
Keep terminal output intentionally small. Terminal commands can produce unexpectedly large output, and sending that output back to the model wastes context and tokens.
read_file with offset and limit. Start around 120-200 lines when inspecting a known region rather than reading the whole file.Get-Content -LiteralPath path -TotalCount 200 for the start of a file, or Get-Content -LiteralPath path | Select-Object -Skip 200 -First 200 for the next chunk.sed -n '1,200p' path, then sed -n '201,400p' path if needed.Get-Content -Raw, cat large-file, broad git diff, recursive directory listings, and commands with unbounded logs unless the file or output is already known to be small.rg -n "pattern" path, rg -n -m 20 "pattern" path, or rg --files path.git diff -- path, git diff --stat, git log --oneline -n 20, and git show --stat.If a command fails, use the exit code and stderr/stdout to decide the next step. Do not blindly rerun a failing command with broader scope.
cwd.git status --short, then use rg/rg --files to locate relevant files, symbols, call sites, config keys, and line numbers.read_file to read only the targeted files or line ranges that rg identified. Avoid reading broad file contents as a discovery strategy.multi_edit_file for manual source edits.git diff -- path or git diff --stat.