Skip to main content

Quark

PyPI

Lightning-fast micro-agent. A stripped-down alternative to heavy AI agents, executing tasks with minimal prompt overhead.

Quark is a minimal CLI agent loop: send a message, let the model call tools (read/edit/write files, list directories, search file names/contents, optionally run shell commands), and get an answer back — with conversation history persisted to disk between runs. It talks to any LLM provider through a small abstraction layer (Anthropic, OpenAI, and Ollama/any OpenAI-compatible endpoint included) instead of depending on a heavy vendor SDK.

Two things it optimizes for on purpose:

  • Lightweight: no framework, no heavy SDKs (just httpx), a short default system prompt, and an edit_file tool so the model can make targeted changes instead of re-sending whole files.
  • Productive by default, secure by default: file tools are confined to a workspace directory (symlink escapes included), run_shell is off unless you opt in, and if a QUARK.md/AGENTS.md file exists it's folded into the system prompt automatically so the agent already knows about your project.

Coming from pi or Claude Code

If you've used another terminal coding agent, most of what you know carries over directly — Quark just makes different defaults and keeps a smaller footprint:

  • From pi: same idea (a small, dependency-light agent loop instead of a framework), but Quark adds a few things pi doesn't: a terminal UI (quark tui) alongside the one-shot/REPL modes, session branching (/fork) and forkable session storage, a live status bar (context/cost), --shell-sandbox (bubblewrap write-confinement for run_shell), and a typed Python plugin system (~/.quark/plugins/) in addition to skills and MCP. Startup is in the same ballpark — see scripts/bench_startup.py for real numbers instead of marketing ones.
  • From Claude Code: QUARK.md/AGENTS.md plays the role of CLAUDE.md (auto-loaded project context); .agents/skills/ and .agents/commands/ work the same way as Claude Code's SKILL.md skills and custom slash commands (Quark reads both its own folders and Claude Code's/Cursor's, so nothing needs converting); spawn_agent is the rough equivalent of subagents; ~/.quark/mcp.json is Claude Code's MCP config, same shape. The main differences: Quark isn't tied to one provider (Anthropic, OpenAI, Ollama, Gemini, OpenRouter, or any OpenAI-compatible endpoint), ships no bundled subscription/billing, and is meant to be read end-to-end — the whole agent loop is a few thousand lines, not a black box.

Install

Requires Python 3.10+. Works anywhere Python does, including WSL2 — nothing platform-specific.

From PyPI:

pip install quark-ai

This installs the quark command (the PyPI distribution name doesn't have to match the console script it installs), including the terminal UI (textual) — see Terminal UI below.

On Debian/Ubuntu (including most current WSL2 distros), a bare pip install is blocked by default with externally-managed-environment (PEP 668). Use pipx instead — it installs CLI tools like Quark in their own isolated environment and puts them on your PATH:

sudo apt install pipx
pipx ensurepath
# open a new terminal (or: source ~/.bashrc)
pipx install quark-ai

For local development, clone the repo instead:

./install.sh

Creates .venv, installs Quark editable with dev deps, and copies .env.example to .env if you don't already have one. Safe to re-run (reuses the venv, never overwrites an existing .env).

Or by hand:

python3 -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"

Configure

The first time you run quark chat or quark tui, if nothing has been configured yet, Quark asks a short series of questions — provider, model (for Ollama it detects your locally pulled models and lets you pick one), workspace, tool mode, whether to allow run_shell — and saves your answers to ~/.quark/config.json so you never have to repeat the same flags again. Entirely local: this wizard never contacts a model or sends any context anywhere, except one optional ping to your own Ollama server to list its models.

quark chat "hola"   # first run only: asks a few questions, then answers
quark chat "qué hora es"   # every run after: no questions, uses what you picked

Re-run it anytime with quark init, or edit ~/.quark/config.json directly. Any --flag or env var still overrides a saved value for a single run — saved config is just the fallback default. If an API key is entered during setup, it's saved to ~/.quark/.env (chmod 600), never into config.json.

Skipped automatically for non-interactive use (piped input, CI, no tty) so it can never hang waiting on a prompt that can't arrive.

Manual configuration

Alternatively, copy .env.example to .env (done automatically by install.sh) and fill in the key(s) for the provider(s) you want to use:

cp .env.example .env
ANTHROPIC_API_KEY=sk-ant-...
OPENAI_API_KEY=sk-...
GEMINI_API_KEY=...
OPENROUTER_API_KEY=sk-or-...
QUARK_PROVIDER=anthropic

.env is loaded automatically from the current working directory, then ~/.quark/.env as a fallback. You can also export the variables directly, or pass --api-key on the command line.

Because the current directory can be a repository you didn't write, its .env is restricted: it may set API keys (*_API_KEY), QUARK_PROVIDER, QUARK_COMPACT_THRESHOLD, QUARK_CONTEXT_WINDOW, QUARK_MINIMAL_TOOLS and QUARK_PROGRESSIVE_TOOLS, and nothing else. Any other QUARK_* setting in it (QUARK_SHELL_MODE, QUARK_MCP_MODE, QUARK_SKILLS_MODE, QUARK_SUBAGENTS_MODE, QUARK_PLUGINS_MODE, QUARK_READ_DIRS, QUARK_BASE_URL, ...) is ignored with a warning, since those grant capabilities or decide where your API key is sent. Put them in ~/.quark/.env, ~/.quark/config.json or the real environment, which are always trusted. A real environment variable always wins over either file.

Usage

# One-shot message, prints the reply and exits
quark chat "list the files in this directory"

# Interactive REPL (Ctrl+D or 'exit' to quit)
quark chat

# Choose a provider/model
quark --provider openai --model gpt-4o chat "what's in README.md?"
quark --provider gemini chat "what's in README.md?"
quark --provider openrouter --model anthropic/claude-sonnet-4.5 chat "what's in README.md?"

# Run fully locally against Ollama (ollama serve + ollama pull llama3.2 first) — no API key needed
quark --provider ollama chat "what's in README.md?"

# Named sessions keep separate histories on disk
quark --session project-a chat "remember that we're using Postgres"
quark --session project-a chat "what database are we using?"

# Confine file tools to a specific directory (default: cwd)
quark --workspace ./my-project chat "list the files here"

# Opt in to the run_shell tool (off by default), approving each command
quark --allow-shell chat "run the test suite"

# Let the model delegate bounded sub-tasks to a short-lived side agent (off by default)
quark --subagents-mode ask chat "add docstrings to every function in utils.py"

# Load your own Python plugins from ~/.quark/plugins/ or ./.agents/plugins/ (off by default)
quark --plugins-mode ask chat "use the word_count tool on README.md"

# Let run_shell run commands without asking (e.g. for scripts or CI)
quark --shell-mode auto chat "run the test suite"

# Read-only mode: only read_file + list_dir, smallest tool-schema footprint, no escape hatch
quark --minimal-tools chat "what does this project do?"

# Progressive mode: starts like --minimal-tools, but the model can unlock
# write_file/edit_file/delete_file itself the moment it actually needs them
quark --progressive-tools chat "fix the typo in README.md"

# Plan mode: read, list and search only; the model proposes changes instead of making them
quark --plan chat "how would you add a --verbose flag?"

# Print the full reply at once instead of streaming it token by token
quark --no-stream chat "what's in README.md?"

# Lower the threshold for auto-summarizing older turns (in estimated tokens)
quark --compact-threshold 4000 chat "..."

# Redo the interactive setup, or set it up for the first time without waiting for a prompt
quark init

# Manage sessions
quark sessions list
quark sessions clear project-a

# Branch a session: 'branch' starts as a copy of 'project-a', independent from here on
quark sessions fork project-a branch
quark sessions fork project-a branch --at 5   # only the first 5 messages

# Token usage and an estimated cost for a session, from the provider's own reported counts
quark usage project-a
quark usage --all

Sessions belong to the workspace: they're stored as JSON under ~/.quark/sessions/<folder>-<hash>/<name>.json, so default in one project never mixes with default in another. Files are written atomically and readable only by you (600); a damaged file is set aside as <name>.corrupt.json instead of crashing. Session names may use letters, digits, ., _ and -. Sessions saved by older versions stay in ~/.quark/sessions/ and are no longer listed.

quark sessions fork <name> <new-name> copies a session's messages and usage totals into a new, independent one — the two don't affect each other afterward. --at N keeps only the first N messages, for going back to an earlier point in the conversation and branching from there instead of continuing where it left off; without it, the whole history is copied. --force overwrites <new-name> if it's already a session. The same thing is available mid-conversation as /fork <name> [messages-back] in quark tui/quark chat — see Terminal UI.

Each session also keeps a running total of the input/output tokens the provider reported for it, per provider/model (switching models with /model keeps both totals). quark usage [name] prints it with an estimated dollar cost, from a small, hand-maintained price table (quark/pricing.py) that only covers well-known Anthropic/OpenAI models and will drift out of date — treat the number as a ballpark, not a bill. Ollama and other unlisted models show the token counts with no guessed cost. quark usage --all covers every saved session in the workspace.

Terminal UI

quark

Running quark with no subcommand launches the terminal UI by default — a scrollable chat with rendered markdown (real tables, not raw | pipes |), colored bubbles per role, a fixed input box, and streaming replies — the same way running bare claude does. You can also ask for it explicitly with quark tui. All the usual flags apply (--provider, --model, --session, --workspace, etc.):

quark --provider ollama --model qwen3.5-4b-coder-128k:latest

It's a thin view on top of the same Agent used everywhere else — no separate request/tool/session logic, so anything that works in quark chat works in the TUI. textual is a core dependency, so pip install quark-ai pulls it in automatically; if it's somehow missing, bare quark falls back to the plain quark chat REPL instead of erroring out.

  • Modes: Tab switches between Build and Plan (see Build and Plan modes); the header shows the mode, provider/model, and a live status readout: context tokens (~ while estimated; once the provider reports usage, the real count), the percentage of the compaction threshold that represents, and this session's estimated cost so far (when the model's price is known — see quark usage above). It updates after every tool call and at the end of each reply, not just once per turn.
  • Input: Enter sends, Ctrl+J adds a line (pasted text keeps its lines), ↑/↓ on the first/last line browse what you sent before. While a reply is running you can keep typing: messages are queued and sent in order, each in the mode (Build/Plan) it was sent in; the header shows Running: Plan when the running reply's mode differs from the selected one (Esc stops the reply and drops the queue). /plan, /build, /read-dir, /model and /exit also work during a reply. Typing / suggests a command (→ accepts it).
  • Reasoning: if the model streams its reasoning (reasoning_content on OpenAI-compatible endpoints, thinking on Anthropic), it shows in gray above the answer. It is display only and isn't kept in the history.
  • Tool calls: each one appears inside the reply as it runs (▸ read_file(path='README.md')), then with its outcome (✓ 1,234 chars or ✗ and the error).
  • Stopping: Esc stops the reply that's streaming; any partial answer is kept in the conversation and you can send a correction.
  • Attaching files: type @ and part of a file name to open a dropdown of fuzzy matches, ranked by how well each workspace path fits what you typed (↑/↓ to pick one, Enter or → to accept, Esc to dismiss). On sending, each @path that names a workspace file gets its contents attached, up to 8 files, through read_file (so the same limits apply and the file counts as read for later edits). This also works in the quark chat REPL, which completes to the single best match instead of listing them. The file index for suggestions is built locally on first use, capped at 10,000 entries, and never sent to the model.
  • Images: @shot.png, or an image path written as is (also an absolute path outside the workspace, e.g. dragged into the terminal), is sent as an image to models that accept them: png, jpg, gif, webp, up to 5 MB, 4 per message. For a text-only model, use --no-images (or QUARK_IMAGES=0, or "images": false in the config); it then says so instead of attaching it. Only images can come from outside the workspace this way; the model still can't read outside text files. Images cost about 1,500 tokens each in the estimate.
  • Models: /model opens a selector with what the provider's /models endpoint offers (↑/↓ and Enter to switch, Esc to close); in the quark chat REPL it prints a numbered list. /model NUMBER or /model NAME switches directly. When the catalog reports a context window or image support (Anthropic, OpenRouter-style endpoints), compaction and image handling adapt; otherwise the configured values stay and it says so. Switching to a text-only model is refused while the conversation has images (/new first).
  • Commands: /model [number|name], /compact [focus], /new, /fork <name> [messages-back], /plan, /build, /init [focus], /read-dir [add|remove PATH], /exit.
  • Shell approval: in ask mode each run_shell command opens a dialog (y runs it, n/Esc rejects it).

quark sessions list/clear has no TUI equivalent; use the regular CLI for those. /fork (also in the quark chat REPL) does: /fork <name> saves the conversation so far into a new session called <name> and switches to it, so you can keep going in a different direction without losing the original; /fork <name> 2 does the same but first drops the last 2 messages, for going back to an earlier point before branching. Either way the session you forked from is left exactly as it was.

Local models, Gemini, OpenRouter (any OpenAI-compatible endpoint)

ollama serve                 # if not already running
ollama pull llama3.2         # or whatever model you want
quark --provider ollama chat "hola"

--provider ollama, --provider gemini and --provider openrouter are all the same OpenAIProvider pointed at that service's own OpenAI-compatible endpoint (Ollama's local one, Google's generativelanguage.googleapis.com/v1beta/openai, OpenRouter's openrouter.ai/api/v1) — no provider-specific code, so anything that works against OpenAI works against them too, including /model's model listing. ollama needs no API key, just a running server; gemini and openrouter need GEMINI_API_KEY/OPENROUTER_API_KEY like any other provider. Override any of their endpoints with --base-url (also QUARK_BASE_URL) — useful for a proxy, or any other OpenAI-compatible server (vLLM, LM Studio, etc.) under a provider name that fits closest. Tool-calling quality with a local Ollama model depends entirely on that model: not every one supports it well, so results with write_file/edit_file/etc. will vary more than with Claude, GPT or Gemini.

Project context

If a QUARK.md or AGENTS.md file exists at the workspace root, its contents (up to 64KB) are appended to the system prompt automatically — a cheap way to give the agent standing context (stack, conventions, gotchas) without repeating it every session. It's reread before every request, so edits apply from the next message.

/init [focus] (in quark tui and the quark chat REPL) writes that guide for you. The model investigates the workspace with read_file, list_dir, and search_files only (each call is shown), then Quark saves its answer to the existing QUARK.md, else the existing AGENTS.md, else a new QUARK.md. Nothing is saved if the model read no files, produced nothing usable, was stopped with Esc, or the guide changed on disk meanwhile. An empty workspace gets a minimal guide. /init isn't available in Plan mode, since it writes a file. (quark init, the command, is the setup wizard, unrelated.)

Build and Plan modes

Quark starts in Build mode with every tool you enabled. In Plan mode the model only gets read_file, list_dir, and search_files, plus an instruction to investigate and propose changes (steps, affected files, interfaces, expected behavior) rather than write full implementations. Any other tool the model calls in Plan mode is refused before it runs, even one outside the catalog it was shown.

Switch with Tab in quark tui, or /plan and /build in quark tui and the quark chat REPL; --plan starts in Plan mode. Both modes share the conversation, so a plan made in Plan mode is there to implement after switching to Build. A switch during a reply applies to the next message.

Read-only directories

The file tools only see the workspace. To let the model also read files elsewhere on your computer without being able to change them, add read-only directories:

quark --read-dir ~/Documents --read-dir ~/notes tui

Also QUARK_READ_DIRS (separated like PATH) or "read_dirs": [...] in ~/.quark/config.json. In quark tui and the quark chat REPL, /read-dir lists them, /read-dir add PATH adds one and /read-dir remove PATH removes it, for the current session, from the next message on.

  • read_file, list_dir, search_files and @file attachments work in them, given an absolute (or ~) path; relative paths still mean the workspace. The model is told which directories it may read.
  • write_file, edit_file and delete_file never reach them, and symlinks inside them that point elsewhere are refused.
  • run_shell isn't limited by them: with the shell enabled, commands can read whatever your account can.

Shell permissions

--shell-mode (also QUARK_SHELL_MODE, or shell_mode in ~/.quark/config.json) decides what run_shell may do:

Mode Behavior
off (default) run_shell isn't offered to the model at all.
ask Each command needs your approval: a [y/N] prompt in quark chat, a dialog in quark tui. Without a terminal to ask (piped input, CI), commands are rejected.
auto Commands run without asking. Only for prompts and providers you trust.

--allow-shell, QUARK_ALLOW_SHELL=1, and allowing the shell in quark init all mean ask.

Sandboxing run_shell

--shell-sandbox (also QUARK_SHELL_SANDBOX=1, or shell_sandbox in ~/.quark/config.json) confines what run_shell commands can write. On Linux, with bubblewrap (bwrap) installed, each command runs with the whole filesystem bound read-only and only the workspace re-bound read-write — the command can still read anything it could before (so pip, git, curl etc. keep working, and network access is unaffected), but a write anywhere outside the workspace fails instead of landing on $HOME, /etc, or another project. It's defense-in-depth on top of approval and the workspace-as-cwd default, not a replacement for either: a command you approve can still read broadly and do anything network-reachable. If bwrap isn't installed, or you're not on Linux, Quark warns once and runs commands unsandboxed, same as without this flag.

Skills

Skills are folders of instructions the model can load when a task matches them. With --skills-mode ask or auto (also QUARK_SKILLS_MODE, or skills_mode in ~/.quark/config.json; default off), Quark looks for <name>/SKILL.md in ~/.quark/skills/, then the workspace's skills/, then .agents/skills/ (the first skill with a given name wins, up to 24):

---
name: release
description: Steps to cut a release of this project
---
1. Bump the version in pyproject.toml ...

The model sees only the names and descriptions (each shortened to 160 characters, 8KB in all), inside the description of one load_skill tool. It calls load_skill(name) for the instructions (up to 64KB) or load_skill(name, path) for a file bundled in the skill's folder (up to 32KB, never outside it). In ask mode each load needs your approval, in auto it doesn't, and off skips discovery so the tool doesn't exist. Plan mode never loads skills. A skill is text the model will follow, so only enable skills from sources you trust: a workspace's skills/ folder comes with the repository.

This is the same SKILL.md shape used by Agent Skills (Claude Code, claude.ai, Claude Cowork plugins): a folder with a SKILL.md whose frontmatter has name and description, plus whatever bundled files it references. A skill written for one of those drops straight into ~/.quark/skills/<name>/ or the workspace's skills/ — no conversion needed — and one written for Quark works there too.

MCP servers

With --mcp-mode ask or auto (also QUARK_MCP_MODE, or mcp_mode in ~/.quark/config.json; default off), Quark starts the servers listed in ~/.quark/mcp.json and offers their tools to the model as mcp__<server>__<tool>. Local servers use stdio, remote ones Streamable HTTP:

{
  "mcpServers": {
    "project-tools": {"command": "node", "args": ["/path/to/server.mjs"], "cwd": "/path/to/project", "env": {}},
    "remote-tools": {"url": "http://127.0.0.1:3000/mcp", "headers": {}}
  }
}
  • ask approves each call (a [y/N] prompt, or a dialog in the TUI); auto runs them directly; off starts nothing.
  • A server that fails to start is skipped with a warning. At most 32 tools are offered; a tool whose input schema is over 8KB is skipped, all definitions together are capped at 64KB, and server instructions (folded into the system prompt) at 8KB.
  • Results keep their text (up to 48,000 characters, beginning and end); images and audio are noted but not passed on, since Quark sends text only.
  • An executed MCP call forgets what the model had read (like run_shell), since a server may change files. Plan mode never calls MCP tools, and --minimal-tools doesn't load them.
  • MCP servers run with your account's permissions; only configure servers you trust.
  • Servers start in parallel. They don't inherit your provider API keys (*_API_KEY) or anything loaded from a .env file; give a server the keys it needs in its env.

With many MCP servers configured, sending a full JSON-schema tool definition per remote tool on every turn adds up. --mcp-code-mode (also QUARK_MCP_CODE_MODE, or mcp_code_mode in the saved config; default off) replaces that with a single run_mcp_code tool: its description lists every available call as mcp.<server>.<tool>(...) with a one-line summary, and the model writes a short Python script that calls them as plain functions (print(mcp.project_tools.search(query="..."))) instead of one tool call per MCP call. The script runs with no imports, no file or network access, and no builtins beyond basic types and control flow — the only thing it can do is call the listed mcp.* functions, each of which still goes through --mcp-mode's own per-call approval exactly as if the model had called it directly.

Side agents

With --subagents-mode ask or auto (also QUARK_SUBAGENTS_MODE, or subagents_mode in ~/.quark/config.json; default off), Quark offers a spawn_agent tool so the model can delegate a bounded, self-contained sub-task — "add docstrings to every function in utils.py", "write unit tests for parser.py" — to a short-lived side agent instead of doing it inline.

The side agent never sees this conversation and works alone in its own isolated copy of the workspace: a git worktree on a throwaway quark-agent-<id> branch when the workspace is a git repository, or a plain directory copy under your temp directory otherwise. It gets the same provider/model and the default (non-minimal) file tools, but no shell, no skills, no MCP servers, and no spawn_agent of its own — one level of delegation only — plus a lower tool-call budget (12 rounds) than a normal session, since it's meant for one sub-task, not an open-ended conversation.

Nothing it does reaches your real workspace by itself. spawn_agent returns its final answer plus, if anything changed, where to find the isolated copy and the git diff/merge commands to review it (or to discard it); if a git worktree ends up with no changes, Quark removes it and its branch for you. A plain directory copy (no git) is left for you to inspect and clean up yourself. ask approves each spawn (a [y/N] prompt, or a dialog in the TUI); auto runs it directly; off doesn't offer the tool at all.

Plugins

With --plugins-mode ask or auto (also QUARK_PLUGINS_MODE, or plugins_mode in ~/.quark/config.json; default off), Quark loads Python plugins: *.py files directly under ~/.quark/plugins/ or the workspace's .agents/plugins/ (first match per filename wins), each defining a module-level PLUGIN = MyPlugin() that contributes its own Tool subclasses — for when a skill (text) or an MCP server (a separate process) isn't enough and you're willing to write Python that runs inside Quark itself:

# ~/.quark/plugins/word_count.py
from quark.plugins import Plugin
from quark.tools.base import Tool

class WordCountTool(Tool):
    name = "word_count"
    description = "Count words in a string."
    parameters = {"type": "object", "properties": {"text": {"type": "string"}}, "required": ["text"]}

    def run(self, text: str) -> str:
        return str(len(text.split()))

class WordCountPlugin(Plugin):
    name = "word-count"

    def tools(self, workspace):
        return [WordCountTool()]

PLUGIN = WordCountPlugin()

A plugin's code runs in Quark's own process with its full permissions the instant the file is imported — unlike a skill or an MCP call, there's no per-call approval the model can be asked for, since importing is running it. ask mode only lists candidate files by name (nothing is imported yet) and asks once before importing any of them; auto imports them directly; off doesn't even look. Only enable this for plugins you wrote yourself or fully trust. A plugin that fails to import, or doesn't define a valid PLUGIN, is skipped with a warning instead of stopping Quark; at most 16 plugin files are loaded.

quark plugin init <name> scaffolds a starter file like the one above (into ./.agents/plugins/, or ~/.quark/plugins/ with --user) so you don't start from a blank file; --force overwrites one that's already there. PLUGINS.md is a plain index of plugins people have written, to find and copy from — Quark doesn't load anything from it itself.

Standard MCP servers from a built-in catalog

Hand-writing ~/.quark/mcp.json entries works, but quark mcp list and quark mcp add <name> [path] make the common case — one of the official reference MCP servers — a one-liner: quark mcp add fetch, or quark mcp add filesystem ~/code for one that needs a directory/repository path. It writes the same mcpServers entry you'd otherwise type by hand; starting it is still --mcp-mode ask/auto as usual. --force overwrites an entry that's already configured under that name; without it, mcp add leaves an existing entry alone.

Importing MCP servers from another tool

~/.quark/mcp.json's {"mcpServers": {...}} shape is the same one Claude Desktop, Claude Code (.mcp.json) and Cursor (.cursor/mcp.json) use, and close enough to VS Code's .vscode/mcp.json (which calls the table servers instead) that quark mcp import <path> reads either: quark mcp import ~/.cursor/mcp.json merges every entry that has a command or url into ~/.quark/mcp.json, leaving entries already configured under the same name alone unless you pass --force. Nothing is started by importing it — that's still --mcp-mode ask/auto.

Custom slash commands

A <name>.md file under .agents/commands/ (workspace), .claude/commands/ (Claude Code), .cursor/commands/ (Cursor) or ~/.quark/commands/ (user-wide) becomes a /<name> command in quark chat and quark tui — no mode flag, no opt-in; it's just a stored prompt, same as typing it out by hand:

---
description: Review the current diff for security issues
---
Review the current diff for security issues, focusing on: $ARGUMENTS

Typing /security-review auth,payments sends that body to the model as the next message, with $ARGUMENTS replaced by everything after the command name and $1, $2, ... by its whitespace-split parts (quote to keep one together: /review "the auth module" → $1 is the auth module). A file in a subdirectory is namespaced with : to match Claude Code — review/security.md becomes /review:security. The four directories are searched in that order, first match per name wins, and this is the same file Claude Code or Cursor already run, so a command written for either works here unchanged, and one written for Quark works there too.

Progressive tool disclosure

--progressive-tools (also QUARK_PROGRESSIVE_TOOLS=1) starts a turn with just read_file, list_dir, and one cheap extra tool, request_more_tools (no parameters). Its description tells the model to call it if it needs to write, edit, or delete files. If the model calls it, Quark registers write_file/edit_file/delete_file on the spot, drops request_more_tools (no longer needed), and the same agent.step() call retries with the expanded set — so the model still gets everything it needs, in the same turn, it just asks first.

This is deliberately not a heuristic: matching intent from text (keywords, embeddings, a classifier) always trades accuracy for cost and can silently withhold a tool the model actually needed on some phrasing you didn't anticipate. Letting the model itself request more tools can't misfire that way — the only cost is one extra round trip, and only on turns that actually mutate something. run_shell stays independently gated behind --shell-mode; progressive mode never unlocks it.

--minimal-tools is the stricter sibling: same starting set, but with no request_more_tools escape hatch at all, for when you want a hard read-only guarantee. Passing both flags together, --minimal-tools wins.

Tool limits

  • read_file: up to 500 lines or 64 KB per call with offset to continue; a single line longer than that is shown in pieces with column. Files over 10 MiB are refused, and a file that changes while being read is reported instead of returned.
  • list_dir: 500 entries by default (limit up to 10,000); symlinks are shown as l and never followed.
  • search_files: 100 results by default (limit up to 500), content hits as path:line:column, files up to 10 MiB, 64 MiB read in total and 15 seconds per search; Esc stops it and keeps the partial results. Binary and unreadable files are skipped and counted.

Loop limits

A single reply may request at most 16 tool calls; a response asking for more gets an error for every call and none of them run. A turn may take at most 32 rounds of tool calls. Tool calls whose arguments aren't a valid JSON object are never run: the model gets an error and can resend them, and the turn stops after two such corrections. Calling the same tool with the same arguments and getting the same result is flagged to the model on the second time and stops the turn on the third.

Timeouts

Quark waits up to one hour for the model's next bytes (--request-timeout, also QUARK_REQUEST_TIMEOUT, or request_timeout in ~/.quark/config.json; connecting still gives up after 30 seconds), because a local model can take minutes to read a long prompt before its first token. Overloaded, rate-limited and dropped requests (408, 409, 429, 5xx, connection errors) are retried up to four times with backoff, honouring retry-after, but only while nothing has been shown yet; an error in the middle of a reply is reported instead of being saved as the answer.

Replies may use up to 32,000 output tokens on Anthropic (--max-tokens, also QUARK_MAX_TOKENS or max_tokens in ~/.quark/config.json; OpenAI-compatible servers use their own default unless set). A reply cut off by that limit is marked, and tool calls it contained are not run, so a half-written file never lands on disk. With Ollama, Quark reads the context size the server actually loaded and compacts earlier if it is smaller than expected, with a hint to raise OLLAMA_CONTEXT_LENGTH. run_shell commands time out after 120 seconds by default (the model can ask for more) and don't see your provider API keys or anything loaded from a .env file. On a timeout, or when you press Esc, the command and every process it started are killed, not just the shell; Esc also stops a command that is still running.

Token counts

The provider's own usage report (prompt_tokens/input_tokens plus output) replaces the character-based estimate once a reply has come back, and the estimate only covers messages added since. Compaction decisions still use the estimate, which is deliberately conservative.

Streaming

Replies print as the model generates them — both providers use stream: true and parse server-sent events, calling back into the CLI for each text chunk. Tool calls are accumulated silently (their JSON arguments arrive fragmented) and only run once complete; nothing changes about tool behavior, just how text reaches your terminal. Pass --no-stream to wait for the full reply and print it in one shot instead (e.g. for piping output into another program).

Context compaction

Quark estimates the session's token count (a len(text) // 4 heuristic — no tokenizer dependency) plus the system prompt and tool schemas sent with every request. Once history is over the budget, it asks the model for a summary of the older turns (file paths, decisions, your preferences, unfinished work, and what was verified) and folds it into the oldest turn it keeps. It only ever cuts at a turn boundary — right after a completed assistant reply, never mid-tool-call — so this can't break the strict user/assistant alternation Anthropic's API requires. It keeps up to the last three turns, fewer if they're bigger than ~20,000 tokens (or a quarter of the budget), but always the last one.

  • Budget: set --context-window (also QUARK_CONTEXT_WINDOW, or context_window in ~/.quark/config.json) to your model's real context limit and the budget becomes that window minus room for the reply (16,384 tokens or a quarter of the window, whichever is smaller). Without it, the budget is --compact-threshold (default 20000, also QUARK_COMPACT_THRESHOLD), which also overrides the window when both are set. --compact-threshold 0 disables compaction.
  • Within a turn: once the budget is exceeded, Quark first looks for a cheaper, semantic cut before resorting to blind trimming: an older read_file or list_dir result for a path the model has since read or listed again is replaced outright with a one-line note, since the file could have changed in between and the newer call is what's actually current — this also runs before the LLM is asked to summarize anything, so a session full of re-reads never has to pay for summarizing them. Only then are any remaining older tool results shortened to their beginning and end. Either way, the latest round's results and the pairing of calls and results are kept.
  • Long outputs: any single tool result over 64,000 characters keeps its beginning and end, with the omission marked. The transcript sent for summarizing shortens each tool result the same way.
  • What survives: which files the model has read in their current state (tracked separately, per path, since write_file/edit_file/delete_file only touch files read that way) isn't part of the history, so compaction doesn't make it reread files.
  • In the TUI: /compact [focus] summarizes the whole conversation on demand, optionally steering the summary, and reports history and total context before and after. The header shows the current estimate.

Startup time

No network call, no API key, just importing Quark's own modules — measured by scripts/bench_startup.py (median of 7 runs, on the machine these docs were written on; your numbers will differ but should land in the same order of magnitude):

Stage Median
python3 -c 'pass' (interpreter baseline) ~13 ms
import httpx (Quark's only hard dependency) ~85 ms
import quark.cli (quark chat's cold-start cost) ~105 ms
import quark.tui (quark tui's cold-start cost, pulls in textual) ~330 ms

Almost all of quark chat's own startup cost is httpx's import, not Quark's code; quark tui costs more because of textual. Run python scripts/bench_startup.py yourself to reproduce these (it also prints the default system prompt's token count, see below).

Token overhead

On the first turn (empty session), before the model generates anything, Quark sends the system prompt plus the JSON schema of every registered tool. The default system prompt itself is about 30 tokens; tool schemas are the rest. Rough token counts (tiktoken cl100k_base, an approximation — Claude's real tokenizer isn't public — but the right order of magnitude either way):

Mode Tools registered Tool-schema tokens Total (system + tools + a short message)
default read_file, list_dir, search_files, write_file, edit_file, delete_file, delete_directory ~600 ~635
--minimal-tools read_file, list_dir, search_files ~290 ~325
--progressive-tools, before unlocking read_file, list_dir, search_files, request_more_tools ~335 ~370
--progressive-tools, after unlocking same as default ~545 ~580
default + --allow-shell + run_shell ~545 + ~90 ~670

--minimal-tools is cheapest but can never write/edit/delete. --progressive-tools costs a little more than minimal on read-only turns (~370 vs ~325) but is capability-equivalent to the default the moment it's actually needed — it only pays the full ~580 on turns that mutate something. search_files is in every mode, including minimal, since searching never mutates anything. Every subsequent turn in a session also carries the accumulated conversation history on top of these numbers.

Architecture

quark/
  message.py       Internal Message/ToolCall representation
  session.py        Persistent, named conversation history, and its cumulative token usage
  pricing.py          Per-model $/1M-token table backing `quark usage`'s cost estimate
  agent.py           The chat + tool-calling loop
  compact.py          History summarization: semantic collapse of stale re-reads, then token-threshold trimming and LLM summary
  providers/          Provider abstraction (unified request/response shape)
    base.py
    anthropic.py       Anthropic Messages API, streamed (SSE)
    openai.py           OpenAI Chat Completions API, streamed (SSE) — also backs --provider ollama
  tools/               Built-in tools the agent can call
    base.py             Tool + ToolRegistry
    workspace.py         Path confinement (resolve_within)
    evidence.py          What the model has read, required before edits
    fs.py                read_file / write_file / edit_file / delete_file / delete_directory / list_dir
    search.py            search_files (literal filename/content search)
    shell.py             run_shell (opt-in)
    meta.py              request_more_tools (--progressive-tools)
    approval.py          Approval prompts shared by run_shell, skills, MCP and side agents
    skills.py            Skill discovery and load_skill
    mcp.py               MCP client (stdio and Streamable HTTP) and MCP tools
    subagent.py          spawn_agent: isolated git worktree / copy, and the side Agent run in it
  plugins.py           Typed Python plugins (*.py under ~/.quark/plugins or ./.agents/plugins), plus `quark plugin init` scaffolding
  mcp_catalog.py       Built-in catalog of standard MCP servers, backing `quark mcp list`/`add`/`import`
  user_commands.py     Markdown slash command discovery (.claude/commands, .cursor/commands, ...) and $ARGUMENTS/$N rendering
  cli.py               argparse-based entry point
  onboarding.py        Interactive first-run setup (quark init)
  attachments.py       @file attachments and the local index for @ suggestions
  commands.py          /read-dir, shared by the TUI and the REPL
  init_project.py      /init: investigate the workspace and write QUARK.md
  evaluation.py        Live model evaluation tasks (quark eval --live)
  tui.py               Textual UI (default bare `quark` invocation, also `quark tui`)

Adding a provider means implementing Provider.complete() in quark/providers/ and registering it in quark/providers/__init__.py. Adding a tool means subclassing Tool in quark/tools/ and adding it to default_registry().

Security note

  • read_file, write_file, edit_file, delete_file, and list_dir are confined to --workspace (default: the current directory); paths that escape it, including via symlinks, are rejected. Read-only directories you add with --read-dir or /read-dir extend only what can be read, listed and searched.
  • run_shell executes arbitrary shell commands and is off by default. --allow-shell enables it with approval for every command; --shell-mode auto skips approval and should only be used when you trust the prompts/provider you're running against. See Shell permissions.
  • write_file, edit_file, and delete_file only touch existing files the model has read in their current state, and every write is atomic (temp file + rename) and verified on disk. Symlinks, special files and files with other hard links are refused, delete_directory deletes non-empty folders only after every file inside was read in its current state, and API keys/tokens are masked in search results and tool-output previews. They still mutate the filesystem inside the workspace without asking for confirmation, and run_shell commands can change files regardless of these checks. Only point Quark at trusted providers/prompts, and run it in an environment you're comfortable with an autonomous agent touching.
  • If you enter an API key during quark init, it's written in plaintext to ~/.quark/.env (permissions set to 600, readable only by you) — never to ~/.quark/config.json, which holds only non-secret preferences (provider, model, workspace, tool mode).

Development

pip install -e ".[dev]"
pytest

Tests mock the HTTP layer (httpx.stream), so the suite runs offline with no API keys required. The TUI test uses Textual's headless run_test() (via pytest-asyncio, a dev-only dependency) and sticks to a smoke check — mount, type, submit, see the bubble — since asserting on the agent's actual reply would mean waiting on a background worker thread from the test, which is a source of flaky CI. Agent.step() itself already has non-flaky coverage in tests/test_agent.py and tests/test_compact.py.

scripts/bench_startup.py backs the Startup time numbers above; also offline, no API key needed.

Live model evaluation

quark eval --live runs five tasks against the configured provider and model (the usual --provider/--model/--base-url/--api-key apply), each in its own temporary workspace and a session that isn't saved:

Task Passes when
targeted_edit settings.py changes only the port.
read_continuation The model finds a word on line 650 of a 700-line file, which needs read_file's offset.
plan_boundaries In Plan mode, app.py is unchanged after a request to rename a function. A forbidden attempt is still counted, even though Quark blocks it.
external_edit_recovery The file changes on disk right after the model reads it; the edit must still land on the new content.
init /init's QUARK.md mentions the project and its test command.

It prints JSON with each task's success, elapsed time, requests, tool calls, invalid and repeated calls, read-before-edit refusals, Plan mode violations, and an estimate of input tokens (estimated from text length, not provider-reported usage). It exits non-zero if any task fails. Without --live it only lists the tasks, and --task NAME (repeatable) picks some. These send real API requests; the unit tests never do. Keep the model (and quantization, for local models) fixed when comparing runs: the tasks measure these specific behaviors, not overall model quality.

Publishing to PyPI

Published as quark-ai. .github/workflows/publish.yml publishes to PyPI via Trusted Publishing (OIDC) whenever a GitHub Release is published — no API token stored in the repo. The pending-publisher setup (PyPI project quark-ai, owner rmoya81, repository Quark, workflow publish.yml, environment pypi) is already done. A release is now a single step:

  1. Bump version in pyproject.toml (and add a matching ## [x.y.z] section to CHANGELOG.md) and merge that to main.

.github/workflows/release.yml watches for that change on main: it runs the test suite, tags the new version (vX.Y.Z), cuts a GitHub Release with that version's changelog section as its notes, and triggers publish.yml, which builds and publishes the sdist/wheel. (It triggers publish.yml explicitly via workflow_dispatch rather than relying on the release event firing automatically, since a release/tag created with the workflow's own GITHUB_TOKEN doesn't itself start other workflows — only workflow_dispatch/repository_dispatch are exempt from that rule.) If a tag for that version already exists, it does nothing, so re-running or re-merging is harmless.

(quark and quark-agent were already taken by unrelated projects on PyPI, which is why the distribution name is quark-ai instead — the installed command is still quark.)

Documentation site

The docs site (MkDocs + Material) is this README and CHANGELOG.md rendered as pages (docs/index.md and docs/changelog.md each just --8<-- "README.md"/--8<-- "CHANGELOG.md" via pymdownx.snippets) — there's one source of truth, not a second copy to keep in sync.

pip install -e ".[docs]"
mkdocs serve   # live preview at http://127.0.0.1:8000

.github/workflows/docs.yml rebuilds and pushes the site to the gh-pages branch on every push to main that touches docs/, mkdocs.yml, README.md or CHANGELOG.md (also triggerable by hand via workflow_dispatch). One-time setup, done once in the repo's settings (not by this workflow): after the workflow has run at least once and created gh-pages, go to Settings → Pages, set Source to "Deploy from a branch", pick the gh-pages branch and / (root), and save. The site is then published at https://rmoya81.github.io/Quark/.

Metadata

Release files for quark-ai 0.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for quark-ai 0.6.0
File Size Uploaded Provenance Actions
quark_ai-0.6.0.tar.gz 162.8 kB With provenance Details for quark_ai-0.6.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for quark-ai 0.6.0
File Interpreter ABI Platform Actions
quark_ai-0.6.0-py3-none-any.whl Python 3 none any Details for quark_ai-0.6.0-py3-none-any.whl

Total release size: 272.4 kB

Release files / quark_ai-0.6.0.tar.gz

Download URL quark_ai-0.6.0.tar.gz
Size 162.8 kB
Tags Source
SHA-256 checksum
How to use checksums
21c0ff8dc71788d9a8bf606c50a53d31c51ed72c4bd983d15780a9f7ed117b70
BLAKE2b-256 checksum
How to use checksums
459051a22cb1d12fd48d4cf2d855abb14d073071aedd1a093504e5d98d0ec932
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 3, 2026.

Transparency log

Release files / quark_ai-0.6.0-py3-none-any.whl

Download URL quark_ai-0.6.0-py3-none-any.whl
Size 109.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
76bf0e7d143dcfeea46084633af26dff26f56637384ec51f66ae86b230cab56c
BLAKE2b-256 checksum
How to use checksums
ff5c9be57ab829b2d4ae9ca3ce4ebb0a980007c383a0707ca90c9b8ad75f69ae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 3, 2026.

Transparency log

Security for quark-ai 0.6.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for quark_ai-0.6.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 3, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page