superagent
An interactive, terminal-based AI coding assistant featuring a cyberpunk style terminal UI, context token tracking, and subagent orchestration.
An interactive, terminal-based AI coding assistant featuring a cyberpunk style terminal UI, context token tracking, and subagent orchestration.
An interactive, terminal-based AI coding assistant featuring a cyberpunk style terminal UI, context token tracking, and subagent orchestration.
Superagent is an interactive, terminal-based AI coding assistant designed to facilitate the cycle of development, testing, debugging, and application optimization directly from your workspace.
It features a cyberpunk-styled terminal user interface built with terminal UI components, automatic tracking of model context token limits, a robust security permission layer, a 3-tier multi-agent orchestration system (Master Agent → Superagent → Subagent), and persistent integration with local terminal shells.

In modern software development, developers frequently switch context between writing code, running terminal commands, inspecting system logs, searching documentation, and interacting with Large Language Models (LLMs).
Superagent bridges this gap by providing an integrated terminal environment that understands your project's context automatically using a project specification file (agents.md), automates execution of independent tasks through secondary agents (subagents), and tracks LLM context window limits in real-time. Security is a primary design goal: every file modification, tool invocation, and shell command execution requires explicit user authorization.
Unlike standard headless execution bots or basic shell wrappers, Superagent is designed from the ground up as a fully interactive developer workspace companion:
/compact now to force compaction on demand, /pin to protect important messages from being compacted, and /compaction-history to audit all compaction events./knowledge to browse and search pinned knowledge across ALL sessions and projects. AI agents can access this via search_pinned_knowledge and load_pinned_session tools, enabling them to learn from previous sessions' decisions and context./checkpoint). If an experimental approach fails, you can revert back instantly to a previous checkpoint, restoring the entire session timeline.superagent --multi. Note: Multi-agent mode is currently experimental./terminal, Superagent spawns a real, popped-up host emulator terminal window. This is perfect for running interactive servers, watch scripts, and commands that require manual inputs..env or log files cluttering your project codebase. All API keys, environment settings, and session logs are kept safe and clean in your user's global directory (~/.superagent-r/).~/.superagent-r/workspace-caches/ to bypass redundant scans. It dynamically monitors and updates the cache when workspace changes occur in the agent loop. Additionally, git worktree directories created for Superagents (~/.superagent-r/worktrees/<name>) are automatically configured as trusted (safe.directory) in git to prevent "dubious ownership" warnings and errors.ask_question tool at every decision point — choosing implementations, resolving ambiguity, or selecting approaches — ensuring the AI never guesses or assumes on the user's behalf./terminal init wizard.D:\images\screenshot.png) directly into the prompt to auto-attach it. Press Ctrl+V to automatically capture image binary data from your system clipboard (cross-platform support for Windows, macOS, and Linux). Attached images are rendered in a sleek visual queue above the prompt and transmitted as high-fidelity multimodal inputs to vision-capable models (e.g. Claude 3.5 Sonnet, GPT-4o), with automatic token tracking.internal-hooks/<name>/ with a hook.json schema definition and an index.js entrypoint. Hooks are auto-discovered on startup and registered as first-class agent tools. Use /ih init <name> to scaffold the project, /ih dev <name> to run and test it locally, and /ih active to pick which hooks are active via an interactive multi-select checkbox dialog. Active selections are persisted per-project in ~/.superagent-r/model-config.json.Superagent is built on modern Node.js technologies for high performance and modular architecture:
ai, @ai-sdk/openai, @ai-sdk/anthropic) for structured and streaming interactions.superagent/
├── src/
│ ├── cli.tsx # Main entrypoint; routes --multi flag to masterAgent
│ ├── app.tsx # React UI wrapper and command handling logic
│ ├── core/
│ │ ├── agent.ts # Core cognitive loop and instruction runner
│ │ ├── masterAgent.ts # Master Agent orchestrator (3-tier entry point)
│ │ ├── config.ts # Environment variable and global config management
│ │ ├── checkpoints.ts # Conversation state checkpoint save/load logic
│ │ ├── slash-commands.ts # Interactive command definitions
│ │ └── tools/
│ │ ├── types.ts # Shared types: AgentTier, SubagentInstance, ToolSet
│ │ ├── toolsets.ts # ToolSet definitions per tier (master/super/sub)
│ │ ├── prompts.ts # System prompts per tier with dynamic context
│ │ ├── state.ts # Shared subagent registry and event emitters
│ │ ├── shellTools.ts # Command execution and background task control
│ │ ├── systemTools.ts # File operations, directory creation, port checks
│ │ ├── subagentTools.ts # Subagent instantiation (superagent tier)
│ │ ├── superagentTools.ts # Superagent orchestration tools (master tier)
│ │ ├── dynamicHooks.ts # Internal hook discovery, loading, and active state
│ │ └── networkTools.ts # Web content fetch and browser integration
│ └── components/ # React Ink components (visual stats, wizards)
├── bin/ # Portable Python and setup scripts
├── tests/ # Unit test suites using Vitest
└── package.json # Project manifest and scripts
A rich terminal interface showing live statistics on active prompt sizes, completion token counts, token cost summaries, active models, remaining context windows, and real-time model generation speed (tokens per second).
Allows developers to save the current state of a coding conversation and restore it at any point using /checkpoint save <name> and /checkpoint restore <id>. This allows you to safely experiment with different implementations. Checkpoints can be browsed, restored, or deleted via an interactive wizard (launched by /checkpoint, /checkpoint list, or Ctrl+P in multi-agent mode). Use the --resume or -r flag to continue where you left off. Multi-agent sessions are fully serialized, ensuring smooth restore and resume of running tasks and interactive prompts. Auto-checkpointing creates snapshots automatically on every user message and before destructive tool operations, with a cooldown to prevent excessive saves — ensuring you always have a safe rollback point.
--multi) (Experimental)[!WARNING] Multi-agent mode (
--multi) is currently experimental and not recommended for production environments.
Launch with superagent --multi to activate the full 3-tier hierarchy:
superagent --multi
│
Master Agent (orchestrator tier)
Tools: invoke_superagent, await_superagents, merge_superagents, manage_superagents, define_superagent, send_message_to_superagent, manage_subagents, git_worktree
Spawns Superagents with git worktree isolation
│
Superagent (per-feature coordinator/lead)
Tools: shell + file tools, invoke_subagent, manage_subagents, git_worktree
Isolated in its own git worktree
Can spawn Subagents for atomic ops
│
Subagent (atomic operation tier)
Tools: file tools only (read/write/search)
Ephemeral, single-purpose execution
Tier Responsibilities:
Advanced Orchestration Features:
├── and └── connectors) mapping active relationships between the Master Agent, spawned Superagents, and running subagents/tasks.ViolationRecord event is emitted with severity levels (warning or critical). These violations automatically propagate up the agent hierarchy (Subagent → Superagent → Master Agent), enabling parent agents to track, log, and take corrective action — including halting or redirecting the offending agent.ask_question tool at every decision point. Agents must present multiple-choice options to the user rather than guessing, assuming, or making unilateral decisions about implementation approaches, file selections, or design trade-offs.Standard subagent roles (single-agent mode):
/terminal)Runs development servers, local builds, or test watchers in popped-up, visible OS terminal windows (Windows cmd, macOS Terminal, Linux x-terminal). It includes an AI-assisted preset initializer (/terminal init) to auto-configure workspace command presets.
For complex changes, the Master Agent enforces structured planning and execution boundaries:
constraints (files or logic NOT to modify) and acceptanceCriteria (a checklist of specific test cases to satisfy).implementation_plan.md and requires explicit user review and approval before any execution begins, guaranteeing complete oversight.The merge system uses a safe-by-default strategy that prevents file corruption:
<<<<<<< in files)mode: 'patch'): Lightweight mode that skips worktree creation and operates directly in the parent's working directory. Ideal for small, targeted fixes (1-2 lines). Much faster than spawning a full Superagent. Includes safety warnings if the parent worktree has uncommitted changes.baseBranch: 'feat/...'): When a Superagent needs to build on top of another feature branch instead of the current HEAD, specify baseBranch to create the worktree from that branch. Useful for dependent features or building on top of in-progress work.Example:
invoke_superagent({
role: 'fix-html-corrupt',
task: 'Fix duplicate closing tags in Toolbar component',
branch: 'fix/toolbar-html',
baseBranch: 'feat/separate-compressor-menu', // Build on top of this branch
mode: 'patch' // Quick fix, no worktree needed
})
All agent operations, including single-agent and 3-tier multi-agent processes, are dynamically logged to a central log file in the user's home directory (~/.superagent-r/superagent.log). The log maintains tier-aware indentation to cleanly trace parallel execution branches.
Beyond manual /checkpoint commands, Superagent creates checkpoints automatically:
In multi-agent mode, the permission layer emits structured ViolationRecord events whenever a child agent attempts a blocked operation. These violations include:
"warning" for soft blocks (e.g., scope creep attempts) and "critical" for hard policy violations (e.g., unauthorized file modifications).Superagent features several robust subsystems that ensure stability, execution safety, and a seamless developer workflow:
androidSetup.ts)Superagent proactively audits and prepares your local machine's developer environment:
ripgrep (rg for high-speed workspace indexing) or curl (on Windows) is missing on your host machine, Superagent automatically downloads, extracts, and places the binaries locally in ~/.superagent-r/bin/.install.cmd for Windows) and Shell (install.sh for macOS/Linux) scripts.masterAgent.ts, superagentTools.ts, subagentTools.ts)For parallel feature development, Superagent implements a 3-tier hierarchy:
~/.superagent-r/worktrees/<name>), preventing file conflicts between concurrent agents.node_modules into the worktree using platform-specific symlinks (or directory junctions on Windows) instead of re-installing dependencies.define_superagent with custom system prompts, enabling domain-specific behaviors.send_message_to_superagent, permitting real-time collaboration. Multi-agent sessions are fully serialized, allowing dynamic resumption and routing of paused instances.manage_superagents with kill or kill_all actions) robustly cleans up and removes their corresponding Git worktrees, avoiding disk clutter.agentLocalStorage to track and isolate concurrent task logging paths, preventing environment variable clashes during parallel execution.~/.superagent-r/superagent.log.permissions.ts)A dedicated validation layer inspects all terminal execution commands before they are executed. It immediately blocks destructive command invocations, including:
rm -rf /, rmdir /s /q C:\, etc.)Format-Volume, Initialize-Disk, mkfs)shutdown, reboot, Stop-Computer)curl/wget | sh, Invoke-Expression/iex)schedule)Superagent implements a background scheduler supporting:
wait: true) showing a real-time countdown indicator directly on the stdout terminal.5m or 1h).Built into the core agent loop (agent.ts), the auto-checkpoint system:
AUTO_CHECKPOINT_COOLDOWN_MS) prevents excessive checkpoint creation during rapid interactions.checkpoint_auto) appears in the terminal UI.Model configuration (model-config.json) uses atomic write operations to prevent file corruption. If the process is interrupted (e.g., Ctrl+C), the config file remains intact — writes are first written to a temporary file and then atomically renamed, ensuring zero risk of partial/corrupt state.
[!WARNING] The Chrome Extension integration and local server are currently experimental features.
Superagent features a built-in REST API and Server-Sent Events (SSE) server (server.ts) that enables two-way integration with the browser via a Chrome Extension SidePanel:
superagent --server, starting an HTTP server on port 7888 (or custom port). The CLI automatically trust-checks the workspace directory initialized by the browser client.Clone and navigate into the repository:
git clone <repository-url>
cd superagent
Install dependencies: Using npm:
npm install
Or using Bun:
bun install
Make Superagent Executable Globally:
To install the superagent command globally on your system so you can invoke it from any directory, build the project and register it:
Using npm:
npm run build
npm link
Or using Bun:
bun run build
bun link
This compiles the TypeScript files to JavaScript and registers a global symlink pointing to your local repository build. Now, you can start the assistant from any directory simply by typing:
superagent
(To uninstall the global symlink, run npm unlink inside this directory).
If you want to use the local development version of Superagent inside another project using Bun:
In the superagent repository root directory, register the package:
bun link
In your target project's root directory, link the registered package:
bun link superagent
Start the assistant in your target project using bunx with the --bun flag (to run it fully under the Bun runtime instead of Node.js):
bunx --bun superagent
Alternatively, you can add a script in your target project's package.json:
"scripts": {
"superagent": "superagent"
}
And run it using:
bun run superagent
Configure Global API Credentials:
Superagent stores all configuration — provider credentials, model settings, rate limits, and system settings — in a centralized JSON config file at ~/.superagent-r/model-config.json. The easiest way to configure everything is through the interactive slash commands:
superagent
# Then inside the terminal UI:
/login # Add API keys and configure providers
/model # Set active AI models per tier
/settings # Configure rate limits, concurrency, streaming, etc.
Alternatively, you can create a .env file in ~/.superagent-r/ for optional runtime overrides:
# Global model override (format: "provider:model" or just "model")
# MODEL=openai:gpt-4o
# Enable multi-agent mode via flag (or set SUPERAGENT_MULTI=true)
# SUPERAGENT_MULTI=false
Superagent natively supports configuring multiple API providers concurrently. All provider profiles, API keys, and model settings are stored in ~/.superagent-r/model-config.json and managed through slash commands:
/login — Add or update provider profiles with API keys./model — Set active models per agent tier (Master, Superagent, Subagent)./settings — Configure rate limits, concurrency, streaming, context window, and max iterations.Custom providers (e.g., self-hosted Claude API proxies, Ollama, vLLM) are supported via /login custom <base_url> <key>. Anthropic-compatible endpoints are automatically detected and run with the Anthropic driver.
To dynamically switch your active API provider or model at runtime, use the /login or /model slash commands. Changes take effect immediately without restarting the assistant.
[!WARNING] The Chrome Extension is currently experimental and may contain bugs or incomplete features.
Superagent includes a developer Chrome Extension that provides a cyberpunk-themed sidepanel interface to interact with your agent workspace directly inside the browser.
chrome://extensions/.chrome-extension folder located at the root of your cloned Superagent repository.superagent --server 7888
Run the following scripts during development:
Start Development Mode: Using npm:
npm run dev
Or using Bun:
bun run dev
Start Multi-Agent Mode (3-tier orchestration): Using npm:
npm run dev -- --multi
Or using Bun:
bun run dev --multi
(Or globally: superagent --multi)
Start Chrome Extension API Server: Using npm:
npm run dev -- --server [port]
Or using Bun:
bun run dev --server [port]
(Or globally: superagent --server [port])
Resume Last Session: Using npm:
npm run dev -- --resume
Or using Bun:
bun run dev --resume
Compile TypeScript: Using npm:
npm run build
Or using Bun:
bun run build
Run Production Build: Using npm:
npm start
Or using Bun:
bun start
Run Unit Tests: Using npm:
npm test
Or using Bun:
bun test
Superagent supports a wide range of slash commands within the terminal chat to manage session state, configure the assistant, and run commands.
/new: Starts a fresh conversation session. Wipes the chat history, resets agent states, and deletes temporary checkpoints./resume: Opens an interactive visual wizard listing previous session histories, allowing you to select and resume any past conversation./clear: Wipes the visual logs and terminal chat screen while maintaining the current conversation history./compact: Shows the current ContextManager status including compaction count, total tokens saved, current state, and last compaction strategy used./compact now: Forces manual compaction on demand. Displays tokens before/after, tokens saved, and the strategy used (truncation, summarization, or semantic)./pin: Pin important messages to prevent them from being removed during compaction. Pinned messages store full content, agent tags, and sync to the global knowledge store. Subcommands: /pin list (view pinned messages with metadata), /pin last (pin the last user message), /pin unpin <id> (remove a pin), /pin view <index> (view full pinned content), /pin tag <index> <label> (tag a pinned message), /pin list-messages (show all messages with indexes)./knowledge (alias: /k): Browse and search the global pinned knowledge store — important messages pinned across ALL sessions and projects. Subcommands: /knowledge (list all entries), /knowledge <query> (search), /knowledge projects (list projects with pins)./search-history <query> (alias: /sh): Search conversation history. Add --all flag to search across ALL sessions and projects (e.g., /search-history auth login --all). Add --debug flag to display step-by-step logs of the AI semantic matching and summary generation process (e.g., /search-history auth login --debug)./compaction-history (alias: /ch): View the full audit trail of compaction events with timestamps, strategies used, tokens saved, and messages preserved./quit or /exit: Safely exits the application./checkpoint (or /checkpoint <name>): Saves a snapshot of your current conversation history, active model state, and planning states./checkpoint list (or /checkpoint with no args): Opens an interactive wizard listing all saved checkpoints with relative timestamps, message counts, and Git commit tags. From the wizard, you can restore or delete any checkpoint./checkpoint restore <id>: Restores a checkpoint by its ID. If no ID is provided, opens a pre-filtered restore wizard. Automatically terminates running subagents/tasks and reverts the agent's internal state to the checkpoint./checkpoint delete <id>: Deletes a specific checkpoint by its ID. If no ID is provided, opens a pre-filtered delete wizard for interactive selection.Ctrl+P to open the interactive checkpoint browser wizard./goal <description>: Activates Goal Mode. The assistant enters a persistent, autonomous loop (up to 200 iterations) to accomplish the goal (e.g., /goal write a full suite of unit tests for auth.ts)./init: Runs a system audit. Checks OS info, Node.js version, Git repository status, active model configuration, and auto-generates the agents.md specification file./agents: Lists all active subagents and details about the preconfigured types (researcher, coder, reviewer)./processes (or /procs): Displays active background processes managed by the agent, along with a visual progress bar and a checklist parsed from the current task.md./terminal <command>: Spawns a visible, popped-up terminal window executing the specified command./terminal preset <name> (or /terminal <preset_name>): Executes a command preset defined in your terminal-presets.json or .superagent-r/terminal-presets.json./terminal init: Launches an interactive, AI-guided wizard that scans your workspace files (like package.json, Cargo.toml, etc.), suggests relevant run commands, and writes them to .superagent-r/terminal-presets.json./skills: Displays a visual wizard containing all currently installed automation templates and guidelines./install <owner/repo>: Installs new automated developer skills directly from remote repositories via npx skills add./ih init <name> (alias: /internal-hooks init <name>): Scaffolds a new internal hook project workspace under internal-hooks/<name>/, creating hook.json (tool schema), package.json, index.js (entrypoint), and test-payload.json (dev test fixture). The new hook is automatically activated and hot-reloaded into the agent's toolset./ih dev <name>: Runs the hook's dev script (from package.json) or falls back to the command field in hook.json, piping test-payload.json as stdin. Ideal for rapid local iteration./ih active: Opens an interactive multi-select checkbox dialog listing all discovered hooks. Space to check/uncheck, Enter to confirm. The selected set is saved per-project in ~/.superagent-r/model-config.json and takes effect immediately./login: Opens a visual wizard to add API credentials, switch active providers, or list configured providers. You can also log in directly via /login <key> or /login custom <base_url> <key>./model <name>: Switches the active Large Language Model (e.g., /model openai/gpt-4o or /model google/gemini-2.5-flash). Running without arguments prints the active model name.Developed and maintained by:
For guidelines on how to contribute to features and bug fixes, please see CONTRIBUTING.md.
This project is licensed under the MIT License - see the LICENSE file for details.
Copyright (c) 2026 Rudy H. hrudy715@gmail.com