Development
Prerequisites
Python 3.11+
Docker and Docker Compose
Go 1.26.1+ (CLI, Go SDK)
Repository Structure
cli
CLI (with MCP server)
Go, Cobra, mcp-go
sdk/go
Go SDK
Go
sdk/python
Python SDK
Python
plugins/cq
Agent plugin (skills, commands, hooks)
Markdown, Python
schema
JSON Schema definitions
JSON Schema, Python
server
Remote knowledge server
Python, FastAPI, TypeScript, React
Initial Setup
git clone https://github.com/mozilla-ai/cq.git
cd cq
make setupInstalling into a Coding Agent
See Install into your coding agent for installing cq into Claude, Codex, Copilot, Cursor, Devin Desktop, OpenCode, or Pi — including per-host config paths and how to point an agent at a remote server.
Go SDK
Go CLI
See cli/README.md for Homebrew, GitHub Releases, and from-source install instructions.
Running Locally
The quickest way to run everything is with Docker Compose.
Export the required secret first:
Start all services (runs in the foreground):
In a separate terminal, create a user and load sample knowledge units:
The remote API is available at http://localhost:3000.
For isolated component testing outside Docker, use make dev-api (remote API) and make dev-ui (dashboard).
These run against server/backend/dev.db, which is a separate database from the one Docker Compose uses — users seeded with make seed-users do not exist there. Seed the local database with the dev- equivalents:
To point an installed agent at this local server, set CQ_ADDR to http://localhost:3000 — see Connect to a remote cq server for the per-host configuration.
Configuration
cq works out of the box in local-only mode with no configuration. Set environment variables to customize the local store path or connect to a remote API.
CQ_LOCAL_DB_PATH
No
~/.local/share/cq/local.db
Path to the local SQLite database (follows XDG Base Directory spec; respects $XDG_DATA_HOME)
CQ_ADDR
No
(disabled)
Remote API URL. Set to enable remote sync (e.g. http://localhost:3000)
CQ_API_KEY
When remote configured
—
API key for remote API write operations (propose, confirm, flag)
Self-hosted server
Running the server (see server/) requires:
CQ_JWT_SECRET
Yes
—
Secret used to sign JWTs issued by /auth/login.
CQ_API_KEY_PEPPER
Yes
—
Server-side pepper combined with each API key under HMAC-SHA256.
CQ_DATABASE_URL
No
—
SQLAlchemy URL for the backing database. Currently only sqlite:///<path> is supported; postgresql+psycopg://... is reserved for the upcoming PostgreSQL backend (epic #257) and rejected at startup.
CQ_DB_PATH
No
/data/cq.db
Shortcut for SQLite deployments — wrapped as sqlite:///<path> internally. Used when CQ_DATABASE_URL is unset.
CQ_PORT
No
3000
HTTP listen port.
TOKEN_EMBEDDING_URL
Only for embedding-based queries
-
URL of the embedding encoderfile server.
SEMSEARCH_EMBEDDING_DIM
Only for embedding-based queries
-
Embedding dimension of the encoder used.
To enable embeddings, download a suitable encoderfile, set it up in a serve configuration, and then set the appropriate environment variables before starting the CQ server, as detailed below:
API keys are created per user from the web UI: log in, open API Keys, give the key a name, choose a TTL, and copy the plaintext token when it is shown. The token is displayed exactly once. Set it as CQ_API_KEY on each client (plugin, SDK, CLI) that should authenticate against this server.
The data-plane write routes require a valid API key:
— POST /api/v1/knowledge
POST /api/v1/knowledge/{id}/confirmationsPOST /api/v1/knowledge/{id}/flags
Data-plane reads remain open:
GET /api/v1/knowledgeGET /api/v1/knowledge/statsGET /api/v1/health
Docker Compose
make compose-up
Build and start services
make compose-down
Stop services
make compose-reset
Stop services and wipe database
make seed-users USER=demo PASS=demo123
Create a user
make seed-kus USER=demo PASS=demo123
Load sample knowledge units
make seed-all USER=demo PASS=demo123
Create user and load sample KUs
Validation
make lint
Format, lint, and type-check all components
make test
Type checks and tests across plugin server and server backend
Status
Exploratory — this is a 0.x.x project. Expect breaking changes to the database format and SDK interfaces before v1. We'll provide migration scripts where possible so your knowledge units survive upgrades.
See the proposal and architecture overview for the design.
Migrating from earlier releases
The local SQLite database format changed during the 0.x cycle (enum values, field names, ID format). If you have knowledge units from an earlier version, run the migration script to bring them up to date:
The script is idempotent — safe to run multiple times, on any 0.x database. It creates a backup before modifying anything. See the script header for full details.
Windows
Install the cq binary via Scoop:
Then use cq install --target <host> the same as on macOS/Linux.
Environment Variable Reference
Install
OPENCODE_CONFIG_DIR
cq install --target opencode
~/.config/opencode
Overrides OpenCode global config target directory
CQ_INSTALL_BINARY
cq install (all targets)
Auto-detected via os.Executable()
Dev/test override for the binary path written into host config
Last updated