| name | process-monitoring |
| description | Patterns for managing and monitoring long-running processes (builds, tests, servers, etc.) via terminalcp |
Process Monitoring with terminalcp
This skill provides comprehensive patterns for managing long-running processes using terminalcp MCP. It enables AI agents to start, monitor, control, and analyze processes without blocking execution.
Overview
terminalcp enables:
- Non-blocking process execution and monitoring
- Real-time log streaming and analysis
- Process lifecycle management (start, stop, restart)
- Parallel process coordination
- Persistent sessions across disconnections
The MCP server runs via npx @mariozechner/terminalcp@latest --mcp and maintains background processes independently.
Basic Process Management
Starting a Long-Running Process
{
"action": "start",
"command": "npm run dev",
"name": "dev-server"
}
Returns a session ID for future reference.
Checking Process Status
{
"action": "list"
}
Returns all active sessions with their names and IDs.
Stopping a Process
{
"action": "stop",
"id": "dev-server"
}
Terminates the process gracefully.
Build Process Monitoring
Running a Build
{
"action": "start",
"command": "npm run build",
"name": "build-process"
}
{
"action": "stream",
"id": "build-process",
"since_last": true
}
{
"action": "stdout",
"id": "build-process"
}
Monitoring Compiler Output
{
"action": "start",
"command": "tsc --watch",
"name": "tsc-watch"
}
{
"action": "stream",
"id": "tsc-watch",
"since_last": true
}
Parallel Build Monitoring
{
"action": "start",
"command": "npm run build:frontend",
"name": "frontend-build"
}
{
"action": "start",
"command": "npm run build:backend",
"name": "backend-build"
}
{
"action": "stream",
"id": "frontend-build",
"since_last": true
}
{
"action": "stream",
"id": "backend-build",
"since_last": true
}
{
"action": "list"
}
Test Process Management
Running Test Suites
{
"action": "start",
"command": "pytest tests/ -v",
"name": "test-run"
}
{
"action": "stream",
"id": "test-run",
"since_last": true
}
{
"action": "stdout",
"id": "test-run"
}
Watch Mode Testing
{
"action": "start",
"command": "npm test -- --watch",
"name": "test-watch"
}
{
"action": "stream",
"id": "test-watch",
"since_last": true
}
Continuous Integration Monitoring
{
"action": "start",
"command": "make ci",
"name": "ci-pipeline"
}
{
"action": "stream",
"id": "ci-pipeline",
"since_last": true
}
Development Server Management
Starting Development Servers
{
"action": "start",
"command": "uvicorn app:app --reload",
"name": "backend-server"
}
{
"action": "start",
"command": "npm run dev",
"name": "frontend-server"
}
{
"action": "start",
"command": "docker-compose up postgres",
"name": "database"
}
Monitoring Server Startup
{
"action": "stream",
"id": "backend-server",
"since_last": true
}
Server Log Analysis
{
"action": "stream",
"id": "backend-server",
"since_last": true
}
Restarting Servers
{
"action": "stop",
"id": "backend-server"
}
{
"action": "start",
"command": "uvicorn app:app --reload",
"name": "backend-server"
}
{
"action": "stream",
"id": "backend-server",
"since_last": true
}
Docker Container Management
Starting Docker Containers
{
"action": "start",
"command": "docker-compose up",
"name": "docker-services"
}
{
"action": "stream",
"id": "docker-services",
"since_last": true
}
Following Container Logs
{
"action": "start",
"command": "docker logs -f mycontainer",
"name": "container-logs"
}
{
"action": "stream",
"id": "container-logs",
"since_last": true
}
Docker Build Monitoring
{
"action": "start",
"command": "docker build -t myimage:latest .",
"name": "docker-build"
}
{
"action": "stream",
"id": "docker-build",
"since_last": true
}
Database Operations
Running Database Migrations
{
"action": "start",
"command": "alembic upgrade head",
"name": "db-migration"
}
{
"action": "stream",
"id": "db-migration",
"since_last": true
}
{
"action": "stdout",
"id": "db-migration"
}
Database Seeding
{
"action": "start",
"command": "python seed_database.py",
"name": "db-seed"
}
{
"action": "stream",
"id": "db-seed",
"since_last": true
}
Advanced Patterns
Automated Deployment Pipeline
{
"action": "start",
"command": "pytest",
"name": "deploy-test"
}
{
"action": "stream",
"id": "deploy-test",
"since_last": true
}
{
"action": "start",
"command": "npm run build",
"name": "deploy-build"
}
{
"action": "stream",
"id": "deploy-build",
"since_last": true
}
{
"action": "start",
"command": "npm run deploy",
"name": "deploy-push"
}
{
"action": "stream",
"id": "deploy-push",
"since_last": true
}
{
"action": "stop",
"id": "deploy-test"
}
{
"action": "stop",
"id": "deploy-build"
}
{
"action": "stop",
"id": "deploy-push"
}
Multi-Service Health Monitoring
{
"action": "start",
"command": "docker-compose up",
"name": "services"
}
{
"action": "stream",
"id": "services",
"since_last": true
}
{
"action": "stdout",
"id": "services"
}
Progressive Log Analysis
{
"action": "start",
"command": "node server.js",
"name": "app-server"
}
{
"action": "stream",
"id": "app-server",
"since_last": true
}
Parallel Test Execution
{
"action": "start",
"command": "pytest tests/unit -v",
"name": "unit-tests"
}
{
"action": "start",
"command": "pytest tests/integration -v",
"name": "integration-tests"
}
{
"action": "start",
"command": "npm run test:e2e",
"name": "e2e-tests"
}
{
"action": "stream",
"id": "unit-tests",
"since_last": true
}
{
"action": "stream",
"id": "integration-tests",
"since_last": true
}
{
"action": "stream",
"id": "e2e-tests",
"since_last": true
}
Development Environment Bootstrap
{
"action": "start",
"command": "docker-compose up postgres",
"name": "dev-db"
}
{
"action": "stream",
"id": "dev-db",
"since_last": true
}
{
"action": "start",
"command": "alembic upgrade head",
"name": "dev-migrations"
}
{
"action": "stdout",
"id": "dev-migrations"
}
{
"action": "start",
"command": "python seed.py",
"name": "dev-seed"
}
{
"action": "start",
"command": "uvicorn app:app --reload",
"name": "dev-backend"
}
{
"action": "start",
"command": "npm run dev",
"name": "dev-frontend"
}
{
"action": "list"
}
Graceful Shutdown Orchestration
{
"action": "list"
}
{
"action": "stop",
"id": "dev-frontend"
}
{
"action": "stop",
"id": "dev-backend"
}
{
"action": "stop",
"id": "dev-db"
}
{
"action": "list"
}
Log Parsing Patterns
Error Detection
error_patterns = [
r"error:",
r"ERROR",
r"Exception:",
r"Traceback",
r"failed",
r"\[ERROR\]",
r"FAIL:",
r"✗"
]
for line in output.split('\n'):
for pattern in error_patterns:
if re.search(pattern, line, re.IGNORECASE):
Progress Tracking
progress_patterns = [
r"(\d+)%",
r"(\d+)/(\d+)",
r"Step (\d+) of (\d+)",
r"✓",
r"Running (\d+) tests?",
]
Performance Metrics
timing_patterns = [
r"Time: (\d+\.?\d*)s",
r"Elapsed: (\d+:\d+)",
r"Duration: (\d+)ms",
r"in (\d+\.?\d*)s",
]
Service Readiness
readiness_patterns = [
r"Application startup complete",
r"Listening on .+:\d+",
r"Server running at",
r"Ready in (\d+)ms",
r"Uvicorn running on",
r"Started server on",
]
Best Practices
Monitoring Strategy
- Use stream mode for active monitoring: Get incremental output without blocking
- Use stdout for final results: Capture complete output when process completes
- Set monitoring intervals: Don't poll too frequently (30s-60s is often sufficient)
- Parse incrementally: Analyze each stream chunk as it arrives
Process Naming
- Use descriptive names:
frontend-build, not build1
- Include purpose:
test-integration, db-migration-prod
- Use consistent naming conventions across workflows
Resource Management
{
"action": "stop",
"id": "completed-process"
}
{
"action": "list"
}
Error Handling
{
"action": "stream",
"id": "new-process",
"since_last": false
}
{
"action": "stop",
"id": "new-process"
}
Timeout Handling
- Set expectations for process duration
- Check for hangs via repeated stream calls with no new output
- Implement timeout logic in monitoring loops
- Force stop if process exceeds expected duration
Log Retention
- Capture full stdout when process completes
- Store logs for analysis
- Parse and extract key metrics
- Clean up session after capturing logs
Common Workflows
CI/CD Pipeline Execution
- Start all CI stages (lint, test, build)
- Monitor each stage with stream
- Parse for success/failure
- Proceed to next stage or abort
- Capture final results
- Clean up sessions
Development Environment
- Start required services (DB, cache, etc.)
- Wait for services to be ready
- Start application servers
- Monitor startup logs
- Keep running, periodic health checks
- Graceful shutdown on exit
Performance Testing
- Start application under test
- Start load generator
- Monitor both processes
- Parse metrics from load generator
- Detect performance degradation
- Stop both processes
- Analyze results
Automated Testing
- Start test suite
- Stream test results in real-time
- Parse for failures
- Stop on first failure if needed
- Capture full test report
- Clean up
This skill provides comprehensive patterns for process management and monitoring using terminalcp's persistent session capabilities.