std::slop is a C++ monorepo for agentic tooling. It provides the std_slop interactive coding agent, the sl command-line tool, MCP client and server libraries with examples, and a Markdown parser and terminal renderer.
| Component | Purpose | Guide |
|---|---|---|
std::slop coding agent (std_slop) |
Run interactive terminal sessions or batch prompts. | Agent walkthrough |
sl command-line tool |
Run prompts and inspect agent state from scripts. | CLI guide |
| MCP client library and examples | Connect C++ applications to Streamable HTTP or modern local stdio MCP servers. | Client API |
| MCP server library and example | Expose explicitly registered tools over stdio. | Server API |
| Agent database and schema | Manage sessions, tools, model calls, and patch review state. | Runtime data model |
| Markdown library | Parse Markdown and render styled terminal output using Tree-sitter. | Parser and renderer |
A few MCP servers are implemented and documented:
- Echo server: a small stdio MCP example. See the echo server guide.
- Local workspace MCP: a bundled stdio server for worktree-aware file and shell tools. Shell commands are not sandboxed. See the local workspace tool guide.
- run_js gateway: bounded JavaScript composition of downstream MCP tools. See the gateway guide.
- Decision API MCP: typed
noul,choice, andscoreevaluations for SystemOne models such as Jev from TypeSafe; OpenRouter is the default backend. See the Decision API guide.
Build both interfaces:
bazel build //:std_slop //:slAfter model authentication and configuration, start the terminal UI or run a scripted prompt:
bazel-bin/app/std_slop
bazel-bin/app/sl --prompt "Summarize the repository structure"Use the walkthrough for interactive sessions and the sl guide for scripts. Batch mode, configuration, and workflow details follow below.
Build the MCP client examples:
bazel build //mcp/client:list_tools_example //mcp/client:call_tool_exampleSee the client guide for HTTP authorization, modern stdio connections, and argv configuration.
Build and test the stdio echo server:
bazel build //mcp/server:echo_server
bazel test //mcp/server:echo_server_testSee the server guide for requests, framing limits, and tool registration.
Build the Markdown parser and terminal renderer:
bazel build //markdown:parser //markdown:rendererSee the Markdown guide for parser and terminal renderer APIs.
- The Markdown library and echo server do not need a model, API key, or agent database. The echo integration test needs Python 3.
- MCP clients support Streamable HTTP and modern MCP
2026-07-28over local stdio. The inbound server package supports stdio only. Agent runtimes start enabled stdio commands as child processes; they do not use an HTTP wrapper or background daemon. - The server does not automatically expose agent tools. Applications must register tools and enforce their own access policy.
- SQLite sessions, model authentication, personas, and mail workflows belong to the coding-agent runtime. They are not requirements for every library.
- The Markdown renderer produces terminal output with ANSI styling. It is not an HTML renderer.
The agents provide schema-validated tools for repository inspection, exact edits, unified patches, shell validation, database access, and scratchpad state. Tool operations are explicit and individually reviewable. Mail workflow tools enforce staging, review, approval, and finalization protections server-side. Small patches keep their rationale and can be checked independently or used for git bisection.
- Personas and skills: Define global agent instructions via
AGENTS.mdand extend capabilities using modular, on-demandSKILL.mdfiles. - SQLite ledger: Interactions and tool calls are stored in SQLite. Interactive sessions and
sluse persistent storage; batch mode can use an in-memory database. - Session scratchpad: Maintain a per-session planning buffer with
/scratchpad edit,/scratchpad save, andread_scratchpad/write_scratchpadtools. - Context control: SQL-backed, per-session accordion history preserves an append-only prompt prefix between resets, so sessions can grow independently while retaining cache-friendly context.
- Accordion context: Use
/context <retain_groups> [watermark_tokens]to grow a cache-friendly prompt prefix, then reset to complete recent groups after the latest actual prompt usage reaches the watermark (defaults:2,350000). Tool results remain full fidelity up to their configured per-result limit. - Mail workflows: Use docs/mail_mode.md for a review-first patch workflow. Careful code review remains the authority while each small, discrete patch stays independently reviewable, verifiable, and suitable for git bisection.
- Models: Supports OpenAI-compatible Responses endpoints and ChatGPT Plus/Pro OAuth. Routers such as OpenRouter can provide access to other models through compatible endpoints.
- Hotwords: Activate a skill for one turn with
hey <skill> <query>.
The project ships Linux x86-64 and macOS binaries every release. You can directly use them.
- C++17 compiler (Clang/GCC)
- Bazel (Bazelisk recommended)
- Git is needed for repository and mail workflows. Initialize the target repository and create an initial commit before using Git mutation tools; it is not needed to use the Markdown library or echo server.
# Build both agent interfaces
bazel build //:std_slop //:sl
# Optional: add them to your PATH
cp ./bazel-bin/app/std_slop ./bazel-bin/app/sl /usr/local/bin/std::slop works best when it can track a specific project. Initialize a git repository and run it from the root:
mkdir my-project && cd my-project
git init
std_slopFor quick one-off tasks, you can use Batch Mode:
std_slop --prompt "Refactor main.cpp to remove all unused includes"Batch mode accepts exactly one instruction source, and optional piped stdin is prepended as context:
std_slop --prompt_file task.md
ls *.cc | std_slop --prompt "sort these files in alphabetical order"Use exactly one instruction source: --prompt or --prompt_file. Piped stdin is optional context. Batch mode uses an in-memory database unless --prompt_db is set.
For scripts, --output=json writes run metadata:
std_slop --prompt_file task.md --output=json | jq -r .assistant_messageThe JSON object contains ok, session, model, active_skills, assistant_message, structured_output, error, and duration_ms.
Use --format or --format_file to require a JSON Schema-constrained final value. The raw validated value is the only stdout payload, so structured output cannot be combined with --output=json:
std_slop --prompt "Extract the name" \
--format '{"type":"object","properties":{"name":{"type":"string"}},"required":["name"],"additionalProperties":false}'
cat incident.log | std_slop \
--prompt_file summarize_incident.md \
--format_file incident_summary.schema.json \
--model gpt-5.4-mini:high \
--session incident-2026-07-19 \
--prompt_db /tmp/slop-incident.dbThe supported schema subset is a root object plus nested object, array, string, number, integer, boolean, and null types; properties, required, boolean additionalProperties, items, and non-empty enum arrays.
sl runs non-interactive prompts and state subcommands. It keeps a persistent database by default; use --ephemeral for an in-memory run.
sl --prompt "Review the authentication flow"
cat build.log | sl --prompt "Explain this failure"
sl session list --jsonSee the CLI guide for database selection, JSON and schema output, and state subcommands. sl uses --json and --schema; std_slop batch mode uses --output=json and --format or --format_file.
Read the Walkthrough first for the recommended getting-started flow, authentication setup paths, config.ini setup, docs-folder navigation, and llm_query subquery/persona configuration. Then use docs/README.md as the docs index for deeper reference material.
- OpenAI-compatible API key: set
OPENAI_API_KEY, optionally combine with--openai_base_url, or put both inconfig.ini - OpenAI OAuth (Responses API): run
std_slop --fetch_openai_oauth_tokenorstd_slop --fetch_openai_oauth_device_token, then start with--openai_oauth
Both agent interfaces use environment variables or a configuration file.
The agent looks for a configuration file at ~/.config/slop/config.ini. You can also specify a custom path using the --config flag.
Keep slop.db outside the codebase, or ignore it and its SQLite sidecars (slop.db-wal and slop.db-shm) in Git. The database stores the context ledger and can contain sensitive data from prompts, tool output, or environment variables.
For a getting-started walkthrough that covers config methods end-to-end, see docs/WALKTHROUGH.md.
[slop]
model = your-model-name
# OR
openai_api_key = sk-...
openai_base_url = https://api.openai.com/v1
# openai_oauth = true # optional: use OpenAI OAuth token + Responses API
# openai_oauth_token_path = /custom/path/chatgpt_plus_token.jsonSee docs/example_config.ini for a full list of options.
You can define config-based llm_query specializations as first-class tools. This
is useful for role-focused delegation (for example: code review, repo exploration)
without rewriting prompts each time.
Add one INI section per specialization using the llm_tool_ prefix:
[llm_tool_code_review_llm]
system_prompt_patch = You are a strict code reviewer focused on correctness and regressions.
session_id = code_review
skill = code_reviewer
context_window = 8After startup, call the specialized tool directly by name (for example
llm_tool_code_review_llm) with a query argument.
For a complete multi-specialization example, see docs/example_subqueries.ini. Detailed behavior and policy constraints are documented in docs/impl/subqueries.md.
SLOP_DEBUG_HTTP=1: Log HTTP headers and bodies for debugging. These logs can contain credentials and other sensitive data.
Use a C++17 compiler and Bazel (Bazelisk is recommended). Build and test the monorepo:
bazel build //...
bazel test //...The library quick starts above build selected components. Model credentials are needed for live agent/model calls, not for the library builds or local echo test.
- C++ Standard: C++17.
- Style: Google C++ Style Guide.
- Exceptions: Disabled (-fno-exceptions).
- Memory: RAII and std::unique_ptr exclusively.
- Error Handling: absl::Status and absl::StatusOr.
- Changes must remain ASan- and TSan-clean.
-
std::slop Coding Agent: Interactive setup, configuration, and first sessions.
-
sl Command-line Tool: Scripted prompts, state commands, and MCP configuration.
-
MCP Client API: C++ HTTP client, bearer tokens, and OAuth helpers.
-
MCP Server API: Stdio server, inline echo example, limits, and security scope.
-
Agent Database and Schema: The SQLite-backed agent runtime and its data model.
-
Markdown: Parser and terminal renderer APIs and examples.
-
Personas & Skills: Understanding global context injection and modular skills.
-
Documentation Guide: Entry point and reading order for the documentation set.
-
Sessions: How context isolation and management work.
-
Context Management: The history and strategy for managing model memory.
-
MCP User Guide: How
std_slopregisters, authenticates, discovers, and exposes MCP tools. -
Subquery Implementation Notes: Design and policy notes for INI-configured
llm_queryspecializations. -
Fuzzing: FuzzTest targets, invariants, and how to run/extend the fuzz suite.
-
Contributing: Code style, formatting, and linting guidelines.
| Package | Role |
|---|---|
markdown/ |
Markdown parsing, syntax highlighting, and ANSI terminal rendering. |
mcp/client/ |
Outbound HTTP MCP client, authorization helpers, and examples. |
mcp/server/ |
Inbound stdio MCP server, dispatcher, and echo example. |
mcp/ |
Shared MCP types, JSON-RPC helpers, and schema validation. |
app/ |
Entry points for std_slop and sl. |
interface/ |
Interactive UI and application control. |
core/ |
Agent model orchestration, SQLite state, HTTP, and shell support. |
tools/ |
Agent tool implementations and argument validation. |
docs/, site/, scripts/build_pages.py |
Documentation sources and generated website. |
The shared agent runtime includes:
database.h: Manages the SQLite-backed ledger. Handles persistence for messages, tools, skills, sessions, and usage data.tool_dispatcher.h: Implements a thread-safe execution engine. It dispatches multiple tool calls concurrently while ensuring results are returned in the proper order for the LLM.cancellation.h: Provides a mechanism for interrupting tasks. It supports registering callbacks to kill shell processes or abort HTTP requests.orchestrator.h: high-level interface for model interaction. The Responses API orchestrator manages history windowing and response parsing.shell_util.h: Executes shell commands in a separate process group, with support for live output polling and termination on cancellation.http_client.h: A cancellation-aware HTTP client used for model API calls.
interface/: Implements the terminal UI with readline input, ANSI colors, and terminal control sequences.markdown/: Uses Tree-sitter for Markdown parsing and code highlighting (C++, Python, Go, JavaScript, Rust, Bash). The agent UI uses it to render responses; C++ callers can use the library separately.app/main.cpp: The primary event loop. Coordinates between the Orchestrator, ToolDispatcher, and UI.
