Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx skills add echoVic/blade-code --skill shell-process-and-worktreegit clone --depth 1 https://github.com/echoVic/blade-codeWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/skills/echovic/blade-code/shell-process-and-worktree)<a href="https://agentmods.dev/skills/echovic/blade-code/shell-process-and-worktree"><img src="https://agentmods.dev/badge/skills/echovic/blade-code/shell-process-and-worktree.svg" alt="Measured on agentmods" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00164 | $0.02444 |
| Opus 5 | $0.00082 | $0.01222 |
| Sonnet 5 | $0.00033 | $0.00489 |
| Haiku 4.5 | $0.00016 | $0.00244 |
Grade A, and why
knowledge-shell-process-and-worktree scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 67 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Module Structure
该节点连接命令执行与 workspace 隔离。Bash 可走本地、ACP 或沙箱路径,并把长前台 命令原进程移交为后台任务;worktree 管理器则将 Session 映射到独立 Git 工作目录并 在交付前验证源工作区没有漂移。
Directory Layout
packages/cli/src/tools/builtin/shell/— Bash、后台管理、stdin、终止与输出捕获packages/cli/src/context/storage/DurableForegroundProcess.ts— 前台命令租约与 handoffpackages/cli/src/context/storage/DurableProcessLeaseStore.ts— 可恢复的进程身份租约packages/cli/src/utils/process/— 启动闸门、进程组拥有权和跨平台终止packages/cli/src/utils/shell/— 命令归一化、只读审计和验证命令识别packages/cli/src/worktree/WorktreeManager.ts— worktree 生命周期、diff 制品和变更交付packages/cli/src/tools/builtin/worktree/worktreeTools.ts— Agent 可调用的进入/退出适配器
Key Entry Points
bashToolinpackages/cli/src/tools/builtin/shell/bash.ts— 本地、ACP、后台与自动 handoff 分流BackgroundShellManagerinpackages/cli/src/tools/builtin/shell/BackgroundShellManager.ts— Session-owned Shell 生命周期prepareForegroundProcess()inpackages/cli/src/context/storage/DurableForegroundProcess.ts— 先持久登记再释放命令启动闸门WorktreeManager.enter()/apply()/exit()inpackages/cli/src/worktree/WorktreeManager.ts— 隔离、交付和离开工作树
Gotchas
- Bash 明确是
isRetrySafe=false;即使抛出EBUSY/EAGAIN也不能自动重放,因为命令可能已经产生外部副作用 (packages/cli/src/tools/builtin/shell/bash.ts,packages/cli/tests/unit/tooling/tools/builtin/bash.test.ts) Bash的isConcurrencySafe=false但显式parallelism='shared':独立命令可同批进入,仍受 execute bucket 限流;由于没有file_path,通用 FileLockManager 不会替 Shell 串行工作区写入 (packages/cli/src/tools/builtin/shell/bash.ts,packages/cli/src/tools/execution/ToolExecutor.ts)- ACP terminal 执行设置
allowLocalFallback=false;远端终端失败必须原样失败,不能在宿主机悄悄重跑同一命令 (packages/cli/src/tools/builtin/shell/bash.ts,git:27f9df37) WriteStdin会产生外部可见输入且默认不可重放,最多接受 64 KiB;ACP 后台终端当前不支持 stdin 写入 (packages/cli/src/tools/builtin/shell/writeStdin.ts,packages/cli/tests/unit/tooling/tools/builtin/write-stdin.test.ts)- 前台自动转后台复用原进程,不重启命令;只有存在 Session、超时大于 handoff budget、非只读审计代理且首个命令不是
sleep时才有资格 (packages/cli/src/tools/builtin/shell/ForegroundCommandHandoff.ts,packages/cli/src/tools/builtin/shell/bash.ts) - foreground → background 租约提交失败时,前台 owner 仍保持权威并继续等待;不能同时把两个 lease 当作有效所有者 (
packages/cli/src/context/storage/DurableForegroundProcess.ts,packages/cli/src/tools/builtin/shell/bash.ts) - 后台 Shell ID 绑定 Session;TaskOutput、WriteStdin、KillShell 用其他 Session ID 查询时都按不存在处理,不能跨会话接管 (
packages/cli/src/tools/builtin/shell/BackgroundShellManager.ts,packages/cli/src/tools/builtin/task/taskOutput.ts) - 本地前后台输出各流只保留最后 1 MiB,随后还会按命令类型二次投影;
stdout_total_bytes/omitted_bytes才能区分“命令没输出”和“早期输出已丢弃” (packages/cli/src/tools/builtin/shell/BoundedOutputBuffer.ts,packages/cli/src/tools/builtin/shell/ShellOutputProjection.ts) - worktree 从 committed
HEAD创建,原工作区未提交改动不会复制;返回的sourceHadChanges是警告,不代表新 worktree 包含这些内容 (packages/cli/src/worktree/WorktreeManager.ts,packages/cli/src/tools/builtin/worktree/worktreeTools.ts) - worktree 交付要求源仓库 HEAD 和创建时工作状态指纹都未变化;只检查 patch 可应用而忽略源状态会覆盖任务期间的用户改动 (
packages/cli/src/worktree/WorktreeManager.ts) ExitWorktree(action='remove')在无法验证状态或存在未提交文件/未合并 commit 时拒绝,只有用户明确允许discard_changes=true才强制删除 (packages/cli/src/worktree/WorktreeManager.ts,packages/cli/src/tools/builtin/worktree/worktreeTools.ts)- stale worktree GC 只删除符合托管命名、足够旧、Git 身份一致且无脏文件/未推送 commit 的目录;异常目录和活跃 Session 均保留 (
packages/cli/src/worktree/WorktreeManager.ts)
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 3d ago First seen · 67 lines · 164 tokens per session scan A 90f968fd3916
knowledge-shell-process-and-worktree is a skill published in the GitHub repository echoVic/blade-code (178 stars, last pushed today), licensed MIT. It adds 164 tokens to every session and 2,444 once invoked, about $0.0008 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.
Other skills, from other repositories
github-pr-workflow
GitHub PR lifecycle: branch, commit, open, CI, merge.
work
Handle issue/PR work items with worktree isolation. Triggered by "/work [issuelink|description]" to start focused work.
meta-pre-commit-quality-gate
Run three quality gates (ruff + mypy + pytest) in parallel over the staged diff, then arbitrate a single BLOCK/APPROVE verdict. Use before committing changes locally when you want a comprehensive pre-commit gate beyond per-file linting — exactly the same gate set CI enforces.
commit
Create git commits with good messages. Use when user says "commit", "create commit", or asks to commit changes.
commit
Generate git commit messages from staged changes.
conventional-git
Conventional Commits v1.0.0 branch naming, worktree naming, and commit message standards for GitHub and GitLab projects. Use when creating branches, naming worktrees, writing commits, generating commit messages, reviewing branch conventions, or setting up changelog automation. Apply when your project needs consistent…