process-lifecycle
/process-lifecycle
Use when changing subprocess execution, cancellation, process-tree cleanup, orphan reaping, or Windows child hardening.
- Author
- AnalystTom ↗
- Repository
- robots-no-mistakes ↗
- Licence
- MIT
- Last repository change
- 06.11.2026
Assessment and security
- Files in this package
- 1
- Scripts
- 0
- HTML comments
- 0
- URLs in SKILL.md
- 0
No signals detected. Repository changed on 06.11.2026, without references to retired models or APIs.
MIT, open: use and modify while retaining author attribution.
What it does and when to use it
Use when changing subprocess execution, cancellation, process-tree cleanup, orphan reaping, or Windows child hardening.
Original author description
Use when changing subprocess execution, cancellation, process-tree cleanup, orphan reaping, or Windows child hardening.
How it works
SKILL.md has no level-two headings · 11 lines, 787 words
SKILL.md preview
---
name: process-lifecycle
description: Use when changing subprocess execution, cancellation, process-tree cleanup, orphan reaping, or Windows child hardening.
user-invocable: false
metadata:
internal: true
---
**Context, Concurrency, and Processes**
- Thread `context.Context` through long-running, subprocess, and networked work; prefer `exec.CommandContext`; use derived contexts and timeouts for cleanup and HTTP calls.
- Route every long-lived subprocess spawned for a cancellable step or agent invocation through the appropriate `shellenv` lifecycle configurator. Agents and other subprocesses use `ConfigureShellCommand`: it creates a process-tree boundary and installs `cmd.Cancel` to kill the whole tree, so grandchildren (test workers, build watchers) cannot outlive cancellation and hold the next run's worktree locked. Repository `commands.*` and custom gates use `ConfigureCooperativeShellCommand`: on Windows it sends targeted `CTRL_BREAK`, preserves up to a three-second cleanup window, then retains the same forced Job Object fallback. Regressions: `TestConfigureCooperativeShellCommandCancelAllowsCleanup`, `TestConfigureCooperativeShellCommandCancelForcesNonCooperatingTree`.
- `cmd.Cancel` covers only cancellation; on clean exit or error the group is not reaped, and leaked grandchildren accumulate until the OS OOM-kills the daemon (surfacing as `daemon crashed during execution` with no stack trace). Use `shellenv.RunShellCommand` / `OutputShellCommand` / `CombinedOutputShellCommand` for one-shot commands, or `StartShellCommand` plus `TerminateShellCommandGroup` when handling pipes manually; the helper doc comments in `internal/shellenv` own the details. `ConfigureShellCommand` also installs a 5s `cmd.WaitDelay` backstop so a grandchild holding an inherited pipe cannot wedge `cmd.Wait` forever. For Claude, Codex, and Pi, a cleanly exited agent's completed result remains usable when that backstop closes an inherited pipe; without a completed result, the parse failure is retained and reports whether a result event arrived. Claude also stops a process still open `claudeResultGrace` after its completed result (background work holds print mode open); a `RequireCompletedChildren` turn fails there and never counts that result. Regressions: `TestClaudeAgent_BackgroundWorkAfterResult`, `TestNativeAgents_FinishedResultSurvivesEscapedStdoutHolder`, `TestNativeAgents_UnfinishedRunKeepsParseErrorOverWaitDelay`, `TestCodexEmptyResultEventIsReportedAsReceived`, `TestCodexAgent_Run_ReapsLeakedGrandchildOnCleanExit`, `TestRunShellCommandWithEnv_ReapsGrandchildOnCleanExit`, `TestTerminateShellCommandGroup_*`.
- A process group is a lineage container, not a sandbox: a descendant that calls `setsid(2)`/`setpgid(2)` (agent CLIs sandboxing their tool runners, any daemonizing worker script) leaves the group, and after its parent exits nothing lineage-based can name it again - it burns CPU and holds a deleted worktree's cwd forever. `internal/procreap` is the identity-based backstop: it matches a process by the run worktree its **cwd** resolves under (deliberately never argv, which a legitimate `git worktree remove` also carries), never touches pid<=1/itself/its ancestors, spares worktrees whose run is still pending or running, and escalates SIGTERM to SIGKILL only after a grace period. Reach is `<NM_HOME>/worktrees` by path shape plus exactly the run worktrees a caller names from run records (`Options.Worktrees`), never a configured worktree root by shape - an operator's own directory is unmatchable unless a run row names it. Every site that removes a run worktree sweeps it first through `procreap.SweepRunWorktree(s)` (run cleanup and setup failure via `RunManager.removeRunWorktree`, startup cleanup, eject), scoped and therefore without age floor or run-active check; the unscoped startup sweep in `recoverOnStartup` keeps the `orphanProcessMinAge` floor. All best effort. Windows needs none of this - job objects contain the whole tree - so the platform layer reports an empty table. Regressions: `internal/procreap`, `TestSweepOrphanRunProcessesReapsFinishedRunAndSparesActiveOne`, `TestSweepRunWorktreeProcessesReapsLeakedChildAtRunCleanup`, `TestTerminateShellCommandGroup_AsksBeforeKilling`, `TestTerminateShellCommandGroup_EscalatesWhenSIGTERMIsIgnored`.
- On Windows the daemon runs console-less (#1653). The managed task launches `no-mistakes.exe daemon run --root <root>` directly, and the binary embeds an application manifest with `consoleAllocationPolicy=detached`, so Windows 11 24H2 / Server 2025 (build 26100) and later allocate no console when there is none to inherit, while a terminal, hook, or agent still shares its console. The manifest is owned by `internal/winres`, which renders `cmd/no-mistakes/rsrc_windows_{amd64,arm64}.syso` (`make winres`; `make lint` and a go test fail on drift); never commit an object from another tool. Older builds ignore the manifest, so `daemon.PrepareRunStdio`, the first thing `daemon run` does (and only `daemon run`, never another entry point such as the log-sink or a CLI sharing a hook's or agent's console), frees a console only this process is attached to (a terminal's shared console stays) and points stdout/stderr without a usable handle (NULL under the manifest start, or the released console) at the bootstrap log, as the detached start path does. The policy also overrides `CREATE_NEW_CONSOLE`, so the cooperative-command helper (the same binary) allocates its private console itself, without a window, before starting its target (`ensureWindowsCooperativeConsole`), or `CTRL_BREAK` never reaches the target. Keep the task's process the daemon itself: a launcher or `conhost --headless` wrapper breaks `schtasks /End`, `inspectWindowsManagedDaemon`, and the argv scans in `collision.go`. Regressions: `internal/winres` (`TestObjectCarriesOnlyTheManifest`, `TestCommittedObjectsMatchGenerator`, `TestNoMistakesExecutableCarriesExactlyTheManifest`, `TestNoMistakesGetsNoConsoleFromAConsolelessParent`), `TestConfigureCooperativeShellCommandCancelAllowsCleanupWithShippedHelper`, `TestReleaseSoleConsoleFreesOnlyAConsoleOfItsOwn`, `TestPrepareRunStdio*`, `TestRunPreparesDaemonStdioBeforeTheDaemonRuns`, `TestOnlyDaemonRunPreparesDaemonStdio`, `TestRenderWindowsTaskXMLScopesLogonTriggerToInstallingUser`.
- A console-less process - the daemon, or a CLI started without a console (`Start-Process` without `-NoNewWindow`, a double-click) - gives every console child a window of its own, so route every console child through `winproc.Harden(cmd)` (no-op elsewhere, idempotent, preserves existing creation flags) or a console window flashes per child (#287). `shellenv.ConfigureShellCommand` already calls it; one-shot commands built directly must call it themselves. Regressions: `TestHarden*` in `internal/winproc`.
- Protect shared mutable state with the standard sync/atomic tools, and be explicit about ownership and cleanup of goroutines, worktrees, temp dirs, and channels.
Versions
| Repository | Score | Licence |
|---|---|---|
| This page · AnalystTom/robots-no-mistakes | 82 | MIT |
| sallaumen/elixir-agent-kit | 100 | MIT |
| kunchenguid/no-mistakes | 82 | MIT |
Database snapshot: 13.11.2026 · package version 51a078cabc31 (SHA-256 digest of the entire package)
Downloads in the last 30 days: 0 · ranking
Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.
Similar skills
- 100shell-subprocess-safety
Shell subprocess safety patterns - execFileSync over execSync, array arguments, shell feature replacements, static analysis guards. Use when spawning child processes, running git/docker/system commands, or reviewing code that calls execSync. - 90windows-child-process-lifecycle
Prevent and recover orphaned child processes, concurrent writers, and post-timeout output corruption on Windows. Use when a PowerShell harness launches long-running Python, Node, benchmark, model, build, or test processes; when a tool timeout or terminal close may kill only the… - 90core-platform
Use when changing FlClash Core integration, lifecycle/process ownership, Go event delivery, Android services, desktop IPC, platform managers, build hooks, system proxy, tray, VPN/TUN, or the Windows or Linux Helper. - 82testing-conventions
Use when adding or changing tests, the e2e harness, fake CLIs in pipeline-step tests, test process isolation, or CI test sharding. - 89wk-process-notifications
Use when a driver must observe or veto process creation and exit. Covers PsSetCreateProcessNotifyRoutineEx and Ex2, PS_CREATE_NOTIFY_INFO fields, blocking a process through CreationStatus, the PASSIVE/APC-disabled callback contract, a bounded non-paged event queue, delivery to… - 100process-supervision
Use when spawning, monitoring, restarting, or shutting down external processes in VoxLocal: llama-server, whisper-cli, the Kokoro worker, port allocation, health checks, stderr capture, zombie prevention, cancellation, and cross-platform process cleanup (tokio and std).