session-execution
Utility for handling shell state, command execution, and streaming process outputs in AI coding environments.
Install
mkdir -p .claude/skills/session-execution && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/1690" && unzip -o skill.zip -d .claude/skills/session-execution && rm skill.zipInstalls to .claude/skills/session-execution
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Use when working on or reviewing session execution, command handling, shell state, FIFO-based streaming, or stdout/stderr separation. Relevant for session.ts, command handlers, exec/execStream, or anything involving shell process management. (project)Key capabilities
- →Manage shell state and command execution
- →Separate stdout and stderr streams using binary prefixes
- →Execute commands in foreground or background modes
- →Handle atomic exit code writing
- →Coordinate FIFO-based streaming for background processes
How it works
The skill manages terminal sessions by using a mutex for serialization and specific binary prefixes to reconstruct output streams from foreground temp files or background FIFOs.
Inputs & outputs
When to use session-execution
- →Debug issues with shell command execution
- →Optimize stdout/stderr streaming in agent tasks
- →Review session state handling
About this skill
Session Execution
Read docs/SESSION_EXECUTION.md before working in this area. It explains the architecture for reliable command execution with stdout/stderr separation.
Key Concepts
Two execution modes:
- Foreground (exec): Runs in main shell, state persists. Uses temp files for output capture.
- Background (execStream/startProcess): Runs in subshell via FIFOs. Labelers prefix output in background.
Binary prefix contract:
- Stdout:
\x01\x01\x01prefix per line - Stderr:
\x02\x02\x02prefix per line - Log parser reconstructs streams from these prefixes
Completion signaling:
- Exit code written to
<id>.exitfile via atomictmp+mv - Hybrid fs.watch + polling detects completion (robust on tmpfs/overlayfs)
- Background mode uses
labelers.donemarker to ensure output is fully captured
When Developing
- Understand why foreground uses temp files (bash waits for redirects to complete)
- Understand why background uses FIFOs (concurrent streaming without blocking shell)
- Test silent commands (cd, variable assignment) - these historically caused hangs
- Test large output - buffering issues can cause incomplete logs
When Reviewing
Correctness checks:
- Verify exit code handling is atomic (write to .tmp then mv)
- Check FIFO cleanup in error paths
- Ensure labelers.done is awaited before reading final output (background mode)
Race condition analysis:
Session execution has a mutex that serializes command execution per session. Before flagging race conditions:
- Check if operations happen within the same session (mutex protects)
- Check if operations are per-session vs cross-session (cross-session races are real)
- Refer to
docs/CONCURRENCY.mdfor the full concurrency model
Common false positives:
- "Concurrent reads/writes to session state" - mutex serializes these
- "FIFO operations might race" - labelers are per-command, not shared
Actual concerns to watch for:
- Cross-session operations without proper isolation
- Cleanup operations that might affect still-running commands
- File operations outside the mutex-protected section
Key Files
packages/sandbox-container/src/session.ts- Session class with exec/execStreampackages/sandbox-container/src/managers/SessionManager.ts- Mutex and lifecyclepackages/sandbox/src/clients/CommandClient.ts- SDK interface to session commands
When not to use it
- →Operations requiring cross-session isolation without proper handling
- →File operations outside the mutex-protected section
Prerequisites
Limitations
- →Requires adherence to the mutex-protected execution model
- →Buffering issues may occur with large output
- →Requires labelers.done to be awaited in background mode
How it compares
This method provides a structured architecture for reliable stream separation and process management compared to standard shell execution.
Compared to similar skills
session-execution side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| session-execution (this skill) | 3 | 3mo | No flags | Advanced |
| applescript | 28 | 8mo | Review | Advanced |
| bazel-build-optimization | 14 | 2mo | No flags | Advanced |
| home-assistant-manager | 9 | 8mo | Review | Advanced |
Try saying
Example prompts that trigger this skill in your AI assistant.
More by cloudflare
View all by cloudflare →You might also like
applescript
martinholovsky
Expert in AppleScript and JavaScript for Automation (JXA) for macOS system scripting. Specializes in secure script execution, application automation, and system integration. HIGH-RISK skill due to shell command execution and system-wide control capabilities.
bazel-build-optimization
wshobson
Optimize Bazel builds for large-scale monorepos. Use when configuring Bazel, implementing remote execution, or optimizing build performance for enterprise codebases.
home-assistant-manager
komal-SkyNET
Expert-level Home Assistant configuration management with efficient deployment workflows (git and rapid scp iteration), remote CLI access via SSH and hass-cli, automation verification protocols, log analysis, reload vs restart optimization, and comprehensive Lovelace dashboard management for tablet-optimized UIs. Includes template patterns, card types, debugging strategies, and real-world examples.
swarm-advanced
ruvnet
Advanced swarm orchestration patterns for research, development, testing, and complex distributed workflows
windows-expert
jackspace
Expert guidance for Windows, PowerShell, WSL interop, and cross-platform development
bash-linux
davila7
Bash/Linux terminal patterns. Critical commands, piping, error handling, scripting. Use when working on macOS or Linux systems.