### Install CQ Go SDK Source: https://github.com/mozilla-ai/cq/blob/main/sdk/go/README.md Install the CQ Go SDK using the go get command. ```bash go get github.com/mozilla-ai/cq/sdk/go ``` -------------------------------- ### Initial Project Setup Source: https://github.com/mozilla-ai/cq/blob/main/DEVELOPMENT.md Clone the repository and run the initial setup script. ```bash git clone https://github.com/mozilla-ai/cq.git cd cq make setup ``` -------------------------------- ### Install cq CLI with Go Source: https://github.com/mozilla-ai/cq/blob/main/cli/README.md Install the cq CLI using the Go programming language's install command. ```bash # Go install. go install github.com/mozilla-ai/cq/cli@latest ``` -------------------------------- ### Install Pi Source: https://github.com/mozilla-ai/cq/blob/main/DEVELOPMENT.md Install the Pi component. For a specific project, use `PROJECT=/path/to/your/project`. ```bash make install-pi ``` ```bash make install-pi PROJECT=/path/to/your/project ``` -------------------------------- ### Install CQ SDK with pip Source: https://github.com/mozilla-ai/cq/blob/main/sdk/python/README.md Install the CQ SDK using pip. ```bash pip install cq-sdk ``` -------------------------------- ### Install Windsurf Source: https://github.com/mozilla-ai/cq/blob/main/DEVELOPMENT.md Install the Windsurf component. This is a global install only. ```bash make install-windsurf ``` ```bash make uninstall-windsurf ``` -------------------------------- ### Install Cursor Source: https://github.com/mozilla-ai/cq/blob/main/DEVELOPMENT.md Install the Cursor component. For a specific project, use `PROJECT=/path/to/your/project`. ```bash make install-cursor ``` ```bash make uninstall-cursor PROJECT=/path/to/your/project ``` -------------------------------- ### Install OpenCode Source: https://github.com/mozilla-ai/cq/blob/main/DEVELOPMENT.md Install the OpenCode component. For a specific project, use `PROJECT=/path/to/your/project`. ```bash make install-opencode ``` ```bash make install-opencode PROJECT=/path/to/your/project ``` -------------------------------- ### Install CQ SDK with uv Source: https://github.com/mozilla-ai/cq/blob/main/sdk/python/README.md Install the CQ SDK using the uv package manager. ```bash uv add cq-sdk ``` -------------------------------- ### Install Cursor using Direct Installer Source: https://github.com/mozilla-ai/cq/blob/main/DEVELOPMENT.md Invoke the installer directly to install the Cursor component globally on Windows. ```bash cd scripts\install uv run python -m cq_install install --target cursor --global ``` -------------------------------- ### cq CLI MCP Server Start Source: https://github.com/mozilla-ai/cq/blob/main/cli/README.md Start the MCP server on standard input/output. ```bash # Start the MCP server on stdio. cq mcp ``` -------------------------------- ### Clone Repository and Setup Go SDK Source: https://github.com/mozilla-ai/cq/blob/main/sdk/go/DEVELOPMENT.md Clone the CQ repository and navigate to the Go SDK directory. Run 'make sync-prompts' to copy canonical prompts. ```bash git clone https://github.com/mozilla-ai/cq.git cd cq/sdk/go make sync-prompts ``` -------------------------------- ### Clone Repository and Setup Environment Source: https://github.com/mozilla-ai/cq/blob/main/sdk/python/DEVELOPMENT.md Clone the CQ repository and set up the Python development environment using make. ```bash git clone https://github.com/mozilla-ai/cq.git cd cq/sdk/python make setup ``` -------------------------------- ### Install cq CLI from Source Source: https://github.com/mozilla-ai/cq/blob/main/cli/README.md Clone the cq repository and build the CLI from source. ```bash # From source. git clone https://github.com/mozilla-ai/cq.git cd cq/cli make build ``` -------------------------------- ### Quick Start: CQ Go SDK Usage Source: https://github.com/mozilla-ai/cq/blob/main/sdk/go/README.md Demonstrates basic client creation, querying, proposing, confirming, and flagging knowledge units using the CQ Go SDK. Ensure the context (ctx) is properly managed. ```go import cq "github.com/mozilla-ai/cq/sdk/go" // Create a client (auto-discovers config, falls back to local-only). c, err := cq.NewClient() if err != nil { log.Fatal(err) } defer c.Close() // Query. result, _ := c.Query(ctx, cq.QueryParams{ Domains: []string{"api", "stripe"}, Languages: []string{"go"}, }) // Propose. ku, _ := c.Propose(ctx, cq.ProposeParams{ Summary: "Stripe 402 means card_declined", Detail: "Check error.code, not error.type.", Action: "Handle card_declined explicitly.", Domains: []string{"api", "stripe"}, }) // Confirm / flag. c.Confirm(ctx, ku) c.Flag(ctx, ku, cq.Stale) c.Flag(ctx, ku, cq.Duplicate, cq.WithDuplicateOf("ku_...")) ``` -------------------------------- ### CQ SDK Quick Start Source: https://github.com/mozilla-ai/cq/blob/main/sdk/python/README.md Demonstrates basic usage of the CQ Python SDK including querying, proposing, confirming, and flagging knowledge units, as well as retrieving agent prompts. ```python from cq import Client, FlagReason cq = Client() # Auto-discovers config; falls back to local-only. # Query. results = cq.query(domains=["api", "stripe"], language="python") # Propose. ku = cq.propose( summary="Stripe 402 means card_declined", detail="Check error.code, not error.type.", action="Handle card_declined explicitly.", domains=["api", "stripe"], ) # Confirm / flag. cq.confirm(ku.id) cq.flag(ku.id, reason=FlagReason.STALE) # Get the canonical agent prompts. from cq import prompts skill_prompt = prompts.skill() reflect_prompt = prompts.reflect() ``` -------------------------------- ### Install CQ via Python Installer Source: https://github.com/mozilla-ai/cq/blob/main/docs/architecture.md Use this command to install CQ on non-Claude-Code hosts. It resolves the target directory, writes MCP config, and installs shared skill commons. ```bash python -m cq_install install --target ``` -------------------------------- ### Install cq CLI with Homebrew Source: https://github.com/mozilla-ai/cq/blob/main/cli/README.md Install the cq CLI using the Homebrew package manager. ```bash # Homebrew. brew install --cask mozilla-ai/tap/cq ``` -------------------------------- ### Install Development Dependencies Source: https://github.com/mozilla-ai/cq/blob/main/sdk/python/README.md Install development dependencies using uv sync with the dev group. ```bash uv sync --group dev ``` -------------------------------- ### Install cq CLI with Scoop Source: https://github.com/mozilla-ai/cq/blob/main/cli/README.md Install the cq CLI using the Scoop package manager. ```bash # Scoop. scoop install cq ``` -------------------------------- ### Install OpenCode using PowerShell Source: https://github.com/mozilla-ai/cq/blob/main/DEVELOPMENT.md Install the OpenCode component globally on Windows using the PowerShell wrapper script. ```powershell .\scripts\install.ps1 install --target opencode --global ``` -------------------------------- ### Start Local CQ Server with Docker Compose Source: https://github.com/mozilla-ai/cq/blob/main/README.md Use these commands to quickly set up a local CQ server environment using Docker Compose and seed initial users. ```bash make compose-up make seed-users USER=demo PASS=demo123 ``` -------------------------------- ### Install Windsurf using PowerShell Source: https://github.com/mozilla-ai/cq/blob/main/DEVELOPMENT.md Install the Windsurf component globally on Windows using the PowerShell wrapper script. ```powershell .\scripts\install.ps1 install --target windsurf --global ``` -------------------------------- ### Install OpenCode Plugin Source: https://github.com/mozilla-ai/cq/blob/main/README.md Installs the OpenCode plugin for CQ. This command is part of the Makefile targets and requires the project to be cloned locally. ```bash make install-opencode ``` -------------------------------- ### Install Cursor using PowerShell Source: https://github.com/mozilla-ai/cq/blob/main/DEVELOPMENT.md Install the Cursor component globally on Windows using the PowerShell wrapper script. ```powershell .\scripts\install.ps1 install --target cursor --global ``` -------------------------------- ### Install CQ Claude Plugin Source: https://github.com/mozilla-ai/cq/blob/main/README.md Installs the CQ plugin for Claude using the plugin marketplace. Requires uv and Python 3.11+. ```bash claude plugin marketplace add mozilla-ai/cq claude plugin install cq ``` -------------------------------- ### Run Local Development Services Source: https://github.com/mozilla-ai/cq/blob/main/DEVELOPMENT.md Start all services using Docker Compose and seed the database with sample data. The remote API will be available at http://localhost:3000. ```bash export CQ_JWT_SECRET=dev-secret make compose-up ``` ```bash make seed-all USER=demo PASS=demo123 ``` -------------------------------- ### Node Discovery Document Example (Reverse Proxy) Source: https://github.com/mozilla-ai/cq/blob/main/docs/node-discovery-protocol.md This example shows a discovery document when a reverse proxy strips path prefixes. The api_base_url points to the public-facing URL, and the proxy handles the internal routing. ```json { "version": 1, "api_base_url": "https://api.example.com", "api_version": "v1" } ``` -------------------------------- ### Install cq Plugin for Claude Code Source: https://github.com/mozilla-ai/cq/blob/main/docs/CQ-Proposal.md This command installs the cq plugin for Claude Code. The plugin bundles all necessary components for agent integration. ```bash /plugin install cq@mozilla-ai-plugins ``` -------------------------------- ### Node Discovery Document Example (Split Origin) Source: https://github.com/mozilla-ai/cq/blob/main/docs/node-discovery-protocol.md This JSON document is served at /.well-known/cq-node.json for split-origin deployments. It specifies the full API base URL and protocol version. ```json { "version": 1, "api_base_url": "https://api.example.com/api/v1", "api_version": "v1", "node_name": "example" } ``` -------------------------------- ### Common CQ CLI Development Tasks Source: https://github.com/mozilla-ai/cq/blob/main/cli/DEVELOPMENT.md A list of common make targets for development. Use these for linting, testing, building, installing, cleaning artifacts, or viewing help. ```bash make test # Lint + test. make build # Build the cq binary. make lint # Run golangci-lint. make install # Copy binary to /usr/local/bin. make clean # Remove build artifacts. make help # Show all available targets. ``` -------------------------------- ### Install Claude Code Source: https://github.com/mozilla-ai/cq/blob/main/DEVELOPMENT.md Install the Claude Code component. To uninstall, use `make uninstall-claude`. ```bash make install-claude ``` -------------------------------- ### Configure CQ Client with Options Source: https://github.com/mozilla-ai/cq/blob/main/sdk/go/README.md Instantiate the CQ client with specific configuration options for remote address and local database path. ```go c, err := cq.NewClient( cq.WithAddr("http://localhost:3000"), cq.WithLocalDBPath("~/.local/share/cq/local.db"), ) ``` -------------------------------- ### Server Backend Development Commands Source: https://github.com/mozilla-ai/cq/blob/main/server/backend/README.md Run these commands from the repository root to set up, develop, test, and lint the server backend. ```bash make setup-server-backend # uv sync make dev-api # run against a local SQLite DB make test-server-backend # pytest make lint-server-backend # pre-commit (ruff, ty, uv lock check) ``` -------------------------------- ### Configure CQ Client Directly Source: https://github.com/mozilla-ai/cq/blob/main/sdk/python/README.md Instantiate the CQ client by passing configuration parameters directly. ```python from pathlib import Path cq = Client( addr="http://localhost:3000", local_db_path=Path("~/.local/share/cq/local.db").expanduser(), ) ``` -------------------------------- ### Clone CQ Repository and Download Go Modules Source: https://github.com/mozilla-ai/cq/blob/main/cli/DEVELOPMENT.md Clone the CQ repository and navigate to the CLI directory. Download the Go module dependencies required for development. ```bash git clone https://github.com/mozilla-ai/cq.git cd cq/cli go mod download ``` -------------------------------- ### Webpack 5 Node.js Polyfill Fallback Configuration Source: https://github.com/mozilla-ai/cq/blob/main/plugins/cq/skills/cq/SKILL.md Example configuration for webpack 5 to add Node.js polyfills, specifically for the 'stream' module, when they are no longer built-in. ```javascript resolve.fallback: { stream: require.resolve("stream-browserify") } ``` -------------------------------- ### Load and Use CQ Schemas and Constants Source: https://github.com/mozilla-ai/cq/blob/main/schema/python/README.md Demonstrates how to import and use parsed constants like DOMAIN_WEIGHT, INITIAL_CONFIDENCE, and CONFIRMATION_BOOST. It also shows how to load raw schema documents (as Python dict or bytes) for use with external validation libraries like jsonschema. ```python import json import jsonschema from cq_schema import ( CONFIRMATION_BOOST, DOMAIN_WEIGHT, INITIAL_CONFIDENCE, load_schema, load_schema_bytes, ) # Parsed constants (immutable; treat as read-only). print(DOMAIN_WEIGHT, INITIAL_CONFIDENCE, CONFIRMATION_BOOST) # Raw schema documents. schema = load_schema("knowledge_unit") jsonschema.validate(instance=my_unit, schema=schema) # Or as bytes if your validator prefers. raw = load_schema_bytes("scoring") ``` -------------------------------- ### Confirming a Knowledge Unit Source: https://github.com/mozilla-ai/cq/blob/main/sdk/python/src/cq/prompts/SKILL.md Call `confirm` with the knowledge unit's ID after verifying its behavior. This is typically done after a successful integration or fix guided by a knowledge unit. ```python confirm(knowledge_unit_id="ku_a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4") ``` -------------------------------- ### Querying Before API Integration Source: https://github.com/mozilla-ai/cq/blob/main/plugins/cq/skills/cq/SKILL.md Use this pattern when integrating external APIs. Call `query` with relevant domain and language tags before starting the integration to retrieve potential knowledge units. ```text query with domains: ["api", "payments", "stripe"] and languages: ["python"] ``` -------------------------------- ### Sync Canonical Prompts for Go SDK Source: https://github.com/mozilla-ai/cq/blob/main/cli/DEVELOPMENT.md Navigate to the Go SDK directory and sync the canonical prompts. This is a prerequisite for building the CLI due to a `replace` directive in `go.mod`. ```bash cd ../sdk/go && make sync-prompts ``` -------------------------------- ### Run Linting Source: https://github.com/mozilla-ai/cq/blob/main/sdk/python/README.md Perform linting on the project using the make lint command. ```bash make lint ``` -------------------------------- ### Accessing Agent Prompts Source: https://github.com/mozilla-ai/cq/blob/main/sdk/go/README.md Import and access predefined agent prompts like Skill and Reflect using the prompts package. ```go import "github.com/mozilla-ai/cq/sdk/go/prompts" skillPrompt := prompts.Skill() reflectPrompt := prompts.Reflect() ``` -------------------------------- ### Display cq Knowledge Store Statistics Source: https://github.com/mozilla-ai/cq/blob/main/plugins/cq/commands/status.md Call the status MCP tool to get a summary of the cq knowledge store. This includes tier counts, domains, recent local additions, and confidence distribution. ```bash mcp cq:status ``` -------------------------------- ### Configure CQ Client with Environment Variables Source: https://github.com/mozilla-ai/cq/blob/main/sdk/python/README.md The client reads configuration from environment variables. Default values are provided for each variable. ```bash # Environment variables: # CQ_ADDR: Remote cq API address (Default: None (local-only)) # CQ_API_KEY: API key (Default: None) # CQ_LOCAL_DB_PATH: Local SQLite path (Default: ~/.local/share/cq/local.db) ``` -------------------------------- ### Knowledge Unit Schema Example Source: https://github.com/mozilla-ai/cq/blob/main/docs/CQ-Proposal.md Defines the structured format for knowledge units, ensuring interoperability between agents. This schema includes fields for ID, version, domain, insight summary/detail/action, context (language, frameworks, environment, pattern), and evidence. ```json { "$schema": "https://cq.mozilla.ai/schemas/knowledge-unit/v1.json", "id": "ku_a1b2c3d4e5f6", "version": "1.0.0", "domain": ["api", "payments", "error-handling"], "insight": { "summary": "Stripe API v2024-12 returns HTTP 200 with error body for rate-limited requests instead of 429", "detail": "When rate-limited, the response status is 200 but the JSON body contains an error object. Agents should check the response body for an error field regardless of HTTP status code.", "action": "Always parse response body for error field before treating 2xx as success" }, "context": { "language": ["typescript", "python", "go"], "frameworks": [], "environment": "server-side", "pattern": "api-integration" }, "evidence": { "type": "object", "properties": { "page_title": { "type": "string", "description": "Concise title for the documentation page" }, "page_description": { "type": "string", "description": "Brief description of the page content" }, "page_summary": { "type": "string", "description": "Summary of the main concepts covered" }, "codeSnippets": [ { "title": "string", "description": "string", "language": "string", "codeList": [ { "language": "string", "code": "string" } ] } ] }, "required": [ "page_title", "page_description", "page_summary", "codeSnippets" ] } } ``` -------------------------------- ### Run Tests Source: https://github.com/mozilla-ai/cq/blob/main/sdk/python/README.md Execute tests for the project using the make test command. ```bash make test ``` -------------------------------- ### Add CQ Skill to Agent Source: https://github.com/mozilla-ai/cq/blob/main/docs/CQ-Proposal.md Installs the cq skill and MCP server configuration for agents that support skills but not the full plugin format. This enables agents to query knowledge commons before executing unfamiliar API calls and propose new learnings. ```bash npx skills add mozilla-ai/cq --skill cq ```