Skip to content
Gordon T Watts edited this page Jan 26, 2026 · 3 revisions

MAINFRAME

The AI-Native Bash Runtime

AI agents control computers through bash. MAINFRAME makes that safe, accurate, and efficient.

License: MIT Bash 4.0+ Pure Bash


What is MAINFRAME?

MAINFRAME is the runtime layer between AI agents and the operating system. It provides:

Capability Description
2,000+ Pure Bash Functions Complete standard library with zero external dependencies
Safe Execution Validation before action, guardrails against damage
Structured Output (USOP) JSON envelopes for every operation
First-Time Correctness Clear errors, predictable behavior, no trial-and-error
Token Efficiency 71% fewer tokens per bash task

Why MAINFRAME Exists

AI agents—whether Claude Code, GPT-4, Cursor, or custom LLM-powered tools—interact with computers primarily through bash. They write shell commands to:

  • Navigate filesystems
  • Manipulate data
  • Manage processes
  • Orchestrate system operations

The problem: Bash is hostile territory for AI.

  • Commands fail silently or with cryptic errors
  • Output is unstructured and unparseable
  • Security vulnerabilities are one typo away
  • Edge cases cause cascading failures
  • Retries waste tokens and time

MAINFRAME solves this by providing a safe, predictable runtime with structured output that AI agents can reliably parse and act upon.

Quick Start

# Install MAINFRAME
git clone https://github.com/gtwatts/mainframe.git ~/.mainframe
echo 'export MAINFRAME_ROOT="$HOME/.mainframe"' >> ~/.bashrc
echo 'source "$MAINFRAME_ROOT/lib/common.sh"' >> ~/.bashrc
source ~/.bashrc

# Verify installation
mainframe version
# MAINFRAME v5.0 - 2,000+ functions | 77 libraries | Pure Bash

See the full Installation Guide for detailed instructions.


Documentation

Getting Started

Page Description
Installation Complete installation guide with all methods
Quick Start Get productive in 5 minutes
Troubleshooting Common issues and solutions
FAQ Frequently asked questions

Core Concepts

Page Description
Library Reference Overview of all 77 libraries
USOP Protocol Universal Structured Output Protocol
Configuration Environment variables and settings

AI Agent Development

Page Description
AI Agent Integration Integration patterns for autonomous systems
Agent Safety Safe command execution library
Agent Communication Multi-agent coordination
Idempotent Operations Retry-safe functions
Security Best Practices Secure agent development

AI Coding Assistants

Page Description
AI Coding Assistant Setup Setup for Claude Code, Cursor, Aider, etc.

Library Categories

MAINFRAME provides 77 libraries organized into categories:

Data Processing

json.sh · csv.sh · pure-string.sh · pure-array.sh · template.sh

System Operations

pure-file.sh · proc.sh · env.sh · path.sh · docker.sh · k8s.sh

Network & Crypto

http.sh · crypto.sh · git.sh · datetime.sh

Safety Layer

validation.sh · guard.sh · error.sh · safe.sh

AI Agent Optimized

output.sh · agent_safety.sh · agent_comm.sh · idempotent.sh · atomic.sh · observe.sh

Language Analysis

typescript.sh · python.sh

UI & CLI

ansi.sh · tui.sh · cli.sh · log.sh

See the Library Reference for complete documentation.


Community


Resources


MAINFRAME · The AI-Native Bash Runtime

"Knowing Your Shell is half the battle."

Install Now · Quick Start · Report Issues

Clone this wiki locally