knowledge-shell-process-and-worktree

knowledge-shell-process-and-worktree is a skill for Claude Code, Codex from echoVic/blade-code. It costs 164 tokens per session (2,444 once invoked), scanned A, original, MIT.

Shell and Git worktree support for running commands, managing long-lived processes, and giving sessions isolated working directories. A Git worktree is a separate checkout linked to the same repository.

In plain words
What is it for?
Use it for foreground or background shell commands, stdin and termination, process cleanup, output limits, worktree creation and recovery, and applying or delivering changes.
Why use it?
It helps commands survive handoffs or stop cleanly, while keeping session changes isolated and checking the original workspace before delivery.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one. Also seen: mentions subagents.

Good fit Use it for foreground or background shell commands, stdin and termination, process…

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/echovic/blade-code/shell-process-and-worktree
Install

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.

Any agent
npx skills add echoVic/blade-code --skill shell-process-and-worktree
Clone the repo
git clone --depth 1 https://github.com/echoVic/blade-code

Made for: Claude Code, Codex.

Wrote 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.

agentmods badge for knowledge-shell-process-and-worktree

README.md
[![agentmods](https://agentmods.dev/badge/skills/echovic/blade-code/shell-process-and-worktree.svg)](https://agentmods.dev/skills/echovic/blade-code/shell-process-and-worktree)
Your own site
<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>
Per session 164 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,444 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

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.

ModelPer sessionOnce 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

Measured 3d ago against content hash 90f968fd3916, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-07, from the pricing page.

Security

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.

.trae/knowledges/tool-and-automation-platform/shell-process-and-worktree/SKILL.md · 67 lines

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 — 前台命令租约与 handoff
  • packages/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

  • bashTool in packages/cli/src/tools/builtin/shell/bash.ts — 本地、ACP、后台与自动 handoff 分流
  • BackgroundShellManager in packages/cli/src/tools/builtin/shell/BackgroundShellManager.ts — Session-owned Shell 生命周期
  • prepareForegroundProcess() in packages/cli/src/context/storage/DurableForegroundProcess.ts — 先持久登记再释放命令启动闸门
  • WorktreeManager.enter() / apply() / exit() in packages/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)
  • BashisConcurrencySafe=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)

Read the full file on GitHub · 67 lines

Changes

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.

  1. 3d ago First seen · 67 lines · 164 tokens per session scan A 90f968fd3916

Subscribe to this mod's changes

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.