Linux & KernelZero Extra Tools NeededMCP Tool: capture_process

How to REA Process Behavior: Terminal PTY Capture, Filesystem Traces & Exit Codes

Observe command-line tools and background processes dynamically: run targets inside an isolated pseudo-terminal (PTY), capture ANSI terminal escape sequences, record filesystem modifications, and compare execution behavior across inputs.

AI Overview Direct AnswerHow to REA: Process Behavior & PTY Capture Quickstart Summary

In this official REA guide for Process Behavior & PTY Capture, AI coding agents (Claude Code, Cursor, Windsurf) execute 'rea capture-process --command "./cli_tool --verify" --json' to safely extract file layout, symbols, and code logic without launching unverified binaries.

Investigation ScenarioReal-World Objective

The Problem & Target Artifact

CLI application analysis or suspicious tool evaluation: You have a closed-source binary tool or installer that expects terminal input. You need to record its exact terminal screen output, exit status, and dropped files without altering your shell environment.

Target Artifact: Executable binary or command-line script.
AI PromptClaude Code / Cursor / Windsurf

Natural Language Agent Instructions

Copy and paste this prompt directly into your AI coding agent when REA is registered via Model Context Protocol (MCP):

Prompt Template:Select All to Copy
Execute ./cli_tool inside REA's process capture PTY. Feed it test input, capture its terminal output streams, and record any files created in /tmp.
ExecutionTerminal & MCP Tool Call

Run REA Analysis Command

Execute the following command in your terminal or inspect the MCP JSON-RPC call executed by your agent:

CLI Command Execution
rea capture-process --command "./cli_tool --verify" --json

What REA Extracts & Returns

Pseudo-terminal (PTY) raw stream recording with ANSI terminal formatting preserved
Process termination status: Exit code, termination signals (SIGINT, SIGKILL), and execution duration
Filesystem observation: List of files read, written, or deleted during execution
Spawned child processes and subprocess tree tracking

Captured Process Telemetry & PTY Output

The verified findings and synthesized clean-room structures generated from this investigation:

Captured Process Telemetry & PTY Output
{
  "command": "./cli_tool --verify",
  "exit_code": 0,
  "duration_ms": 420,
  "pty_output": "Connecting to server... OK\nLicense verified: ACTIVE\n[+] Initializing sandbox...",
  "filesystem_effects": [
    { "path": "/tmp/cli_tool.lock", "action": "created_and_removed" },
    { "path": "~/.config/cli_tool/cache.db", "action": "written", "bytes": 4096 }
  ]
}
Internal MechanicsProduction Engineering

Isolated Pseudo-Terminal (PTY) Allocation

Many CLI utilities check `isatty(STDIN_FILENO)` and refuse to run or suppress output if piped through standard stdin/stdout. REA allocates a native pseudo-terminal master/slave pair (openpty), simulating a real user terminal session while capturing raw ANSI control sequences into verifiable Evidence ledgers.

Security Guardrails & Analysis Boundary Rules

Enforces strict process timeout ceilings to prevent infinite loops from hanging agents.
Runs with unprivileged user permissions to safeguard host system files.
Compares behavior across different flag combinations to discover hidden undocumented arguments.