### Install Clear Your Tools Proxy and Pruners Source: https://github.com/qdrddr/clear-your-tools/blob/main/CONFIG.md Install the 'clear-your-tools' package with all extras using uv. ```bash uv tool install 'clear-your-tools[all]' ``` -------------------------------- ### Copy Environment Example Source: https://github.com/qdrddr/clear-your-tools/blob/main/DEV.md Copies the example environment file to .env. Users should edit this file to add necessary API keys. ```bash cp .env.example .env # Edit .env — at minimum DEEPINFRA_API_KEY (reranker) and OPENROUTER_API_KEY (upstream + optional LLM stage) ``` -------------------------------- ### Install and Build TypeScript SDK Source: https://github.com/qdrddr/clear-your-tools/blob/main/sdk/typescript/README.md Steps to install dependencies, build the TypeScript SDK, and run tests locally. ```bash cd sdk/typescript npm install npm run build npm test ``` -------------------------------- ### Install and Run Proxy with Debugging Source: https://github.com/qdrddr/clear-your-tools/blob/main/debug/README.md Installs the necessary tools and runs the proxy in debug mode. This logs transformed requests to a file and enables full tool JSON in stats. ```bash uv tool install 'clear-your-tools[all]' uv run cyt proxy --debug ``` -------------------------------- ### Install Dependencies with uv Source: https://github.com/qdrddr/clear-your-tools/blob/main/DEV.md Installs all project dependencies, including extras, using the uv package manager. ```bash uv sync --all-extras ``` -------------------------------- ### Setup Proxy Configuration Source: https://github.com/qdrddr/clear-your-tools/blob/main/CONFIG.md Use the interactive wizard to set up the proxy configuration. This command writes to `~/.config/cyt/config.yaml` and optionally `~/.config/cyt/.env`. ```bash cyt setup ``` -------------------------------- ### Install Dependencies and Develop Source: https://github.com/qdrddr/clear-your-tools/blob/main/sdk/python/README.md Navigate to the Python SDK directory, synchronize dependencies using uv, and build the library in development mode with Maturin. ```bash cd sdk/python uv sync uv run maturin develop --release ``` -------------------------------- ### Run Proxy Server from Checkout Source: https://github.com/qdrddr/clear-your-tools/blob/main/DEV.md Starts the Clear Your Tools proxy server from a source checkout using uv. ```bash uv run cyt proxy --port 8834 ``` -------------------------------- ### Install Clear Your Tools Proxy Source: https://github.com/qdrddr/clear-your-tools/blob/main/README.md Installs the Clear Your Tools proxy and pruners from PyPI using the uv tool. Ensure uv is installed before running this command. ```bash uv tool install 'clear-your-tools[all]' ``` -------------------------------- ### Install cyt-indexer CLI Source: https://github.com/qdrddr/clear-your-tools/blob/main/sdk/rust/cyt-indexer/README.md Install the cyt-indexer command-line interface using Cargo. This command makes the `cyt-indexer` executable available in your system's PATH. ```bash cargo install cyt-indexer ``` -------------------------------- ### Install Clear Your Tools from PyPI Source: https://github.com/qdrddr/clear-your-tools/blob/main/DEV.md Installs the Clear Your Tools package with all extras from PyPI, including proxy and pruners. ```bash uv pip install 'clear-your-tools[all]' ``` -------------------------------- ### Run Proxy Server with HTTP/2 and TLS Source: https://github.com/qdrddr/clear-your-tools/blob/main/DEV.md Starts the Clear Your Tools proxy server with HTTP/2 and TLS enabled, using generated certificates. ```bash uv pip install h2 'hypercorn[h2]' cyt proxy --http2-serve \ --ssl-keyfile src/crt/key.pem \ --ssl-certfile src/crt/cert.pem \ --port 8834 ``` -------------------------------- ### Run the Proxy Source: https://github.com/qdrddr/clear-your-tools/blob/main/CONFIG.md Execute the Clear Your Tools proxy using the installed CLI. The default listen port is 8834, configurable via `defaults.yaml` or `~/.config/cyt/config.yaml`. ```bash uv run cyt proxy ``` -------------------------------- ### Configure LLM Pruning Model (OpenAI) Source: https://github.com/qdrddr/clear-your-tools/blob/main/CONFIG.md Example configuration to use an OpenAI LLM model for pruning. Ensure the `OPENAI_API_KEY` environment variable is set. ```yaml defaults: remote: llm_model_nick: gpt-5.4-nano pruning: pipeline: - llm ``` -------------------------------- ### Run Clear Your Tools Proxy (OpenAI) Source: https://github.com/qdrddr/clear-your-tools/blob/main/README.md Starts the Clear Your Tools proxy with OpenAI as the upstream API. The proxy listens on port 8834 by default. ```bash uv run cyt proxy --upstream https://api.openai.com --upstream-kind openai ``` -------------------------------- ### Install zlib for Claude Code Proxy Issues Source: https://github.com/qdrddr/clear-your-tools/blob/main/README.md Install missing zlib using npm or brew if Claude Code reports ZlibError when using the proxy. This error typically occurs when the proxy returns a gzip or deflate encoding header with an already decompressed body. ```bash npm install -g zlib ``` ```bash brew install zlib ``` -------------------------------- ### Run Clear Your Tools Proxy (Anthropic) Source: https://github.com/qdrddr/clear-your-tools/blob/main/README.md Starts the Clear Your Tools proxy with Anthropic as the upstream API. The proxy listens on port 8834 by default. ```bash uv run cyt proxy --upstream https://api.anthropic.com --upstream-kind anthropic ``` -------------------------------- ### Configure LLM Pruning Model (OpenRouter) Source: https://github.com/qdrddr/clear-your-tools/blob/main/CONFIG.md Example configuration to use an OpenRouter LLM model for pruning. Ensure the `OPENROUTER_API_KEY` environment variable is set. ```yaml defaults: remote: llm_model_nick: gpt-oss-120b pruning: pipeline: - llm ``` -------------------------------- ### Run Local End-to-End Tests Source: https://github.com/qdrddr/clear-your-tools/blob/main/sdk/e2e/README.md Execute local end-to-end tests for all targets. This command installs packages from the workspace version. ```bash ./sdk/e2e/scripts/run-local.sh ``` -------------------------------- ### Get Statistics Totals Source: https://github.com/qdrddr/clear-your-tools/blob/main/debug/README.md Displays the overall statistics totals for the proxy, such as token counts. This provides a high-level overview of the proxy's performance. ```bash cyt stats totals ``` -------------------------------- ### View Clear Your Tools Stats Source: https://github.com/qdrddr/clear-your-tools/blob/main/README.md Commands to view pruning statistics. `totals` shows overall savings, `summary` provides a period-based overview, and `events` lists recent pruning events. Running `cyt setup` is recommended before viewing stats. ```bash uv run cyt stats totals ``` ```bash uv run cyt stats summary --period day ``` ```bash uv run cyt stats events --limit 20 ``` -------------------------------- ### Point Claude Code at Proxy Source: https://github.com/qdrddr/clear-your-tools/blob/main/examples/agents/claude/README.MD Set environment variables to direct Claude Code requests to a local proxy. This example uses OpenRouter as the backend provider. ```bash export ANTHROPIC_BASE_URL="http://localhost:8834/anthropic" export OPENROUTER_API_KEY="..." export ANTHROPIC_AUTH_TOKEN="${OPENROUTER_API_KEY}" claude --model haiku 'say hi' -p ``` -------------------------------- ### Update Reranker Model Pricing Source: https://github.com/qdrddr/clear-your-tools/blob/main/CONFIG.md Update pricing for reranker models, such as DeepInfra Qwen3-Reranker-8B, to maintain accurate cost-saving metrics. This example specifies the input cost per token. ```yaml models: rerankers: remote: - nick: rerank-qwen3-8b pricing: input_cost_per_token: 5e-08 # $0.05 / 1M input tokens ``` -------------------------------- ### Get Statistics Events Source: https://github.com/qdrddr/clear-your-tools/blob/main/debug/README.md Lists recent events recorded by the proxy statistics, with a limit of 20 events. This can be used to inspect individual request processing. ```bash cyt stats events --limit 20 ``` -------------------------------- ### Update LLM Model Pricing Source: https://github.com/qdrddr/clear-your-tools/blob/main/CONFIG.md Update input and output costs per token for LLM models to ensure accurate net-savings calculations. This example shows pricing for Claude Sonnet 4.6 on Anthropic/OpenRouter. ```yaml # ~/.config/cyt/config.yaml models: llm: remote: - nick: sonnet name: claude-sonnet-4-6 provider: anthropic key_var_name: ANTHROPIC_API_KEY pricing: input_cost_per_token: 3e-06 # $3 / 1M input tokens output_cost_per_token: 15e-06 # $15 / 1M output tokens ``` -------------------------------- ### Configure Clear Your Tools Proxy Source: https://github.com/qdrddr/clear-your-tools/blob/main/README.md Launches an interactive wizard to configure the Clear Your Tools proxy, saving settings to `~/.config/cyt/config.yaml` and optionally `~/.config/cyt/.env`. This step is optional but recommended for configuring rerank/llm pruners and cost tracking. ```bash uv run cyt setup ``` -------------------------------- ### Build Catalog with CLI Source: https://github.com/qdrddr/clear-your-tools/blob/main/sdk/rust/cyt-indexer/README.md Build a catalog index using the cyt-indexer CLI. This command takes a JSON file containing tools and outputs the catalog to a specified directory. It requires `jq` to extract tools from a file. ```bash jq '.body.tools' debug/full_example.json > /tmp/tools.json cyt-indexer build --tools /tmp/tools.json --output ./.catalog ``` -------------------------------- ### Build Catalog Index with Library Source: https://github.com/qdrddr/clear-your-tools/blob/main/sdk/rust/cyt-indexer/README.md Use the `build_catalog_index` function from the cyt-indexer library to create a catalog index from a list of tools. Requires `serde_json` for JSON manipulation. ```rust use cyt_indexer::{build_catalog_index, CatalogIndex}; use serde_json::json; let tools = vec![/* ... */]; let index = build_catalog_index(&tools, &[]); ``` -------------------------------- ### View CYT Statistics Source: https://github.com/qdrddr/clear-your-tools/blob/main/README.md Run this command to see statistics of actual net savings in input tokens. ```bash uv run cyt stats totals ``` -------------------------------- ### Proxy Workflow Diagram Source: https://github.com/qdrddr/clear-your-tools/blob/main/README.md Illustrates the request flow from an agent through the Clear Your Tools proxy to an upstream provider, detailing the proxy's internal processing steps. ```text Agent (Claude Code, etc.) │ ▼ Clear Your Tools proxy ──► extract user query from messages │ decompose each tool schema │ score / filter with BM25 (default), rerank, or LLM pruning │ recompose pruned tool list ▼ Upstream provider (OpenRouter, Anthropic, Novita, …) ``` -------------------------------- ### Import Core Library Components Source: https://github.com/qdrddr/clear-your-tools/blob/main/DEV.md Imports essential components for catalog indexing, pruning, and proxy creation from the Clear Your Tools library. ```python from cyt.indexer import CatalogIndex, build_catalog_index, load_catalog, retrieve_tools from cyt.pruners import rerank_catalog_dict, llm_catalog_dict from cyt.pruners.policies import configure_policies_from_config from cyt.proxy.reverse import create_app # requires clear-your-tools[proxy] ``` -------------------------------- ### Run All Targets in CI Style Source: https://github.com/qdrddr/clear-your-tools/blob/main/sdk/e2e/README.md Execute all end-to-end test targets in a manner consistent with the CI workflow. This requires setting the release version or tag explicitly. ```bash export CYT_RELEASE_VERSION=0.1.10 # or TAG=v0.1.10 ./sdk/e2e/scripts/run-all.sh ``` -------------------------------- ### Retrieve from Catalog with CLI Source: https://github.com/qdrddr/clear-your-tools/blob/main/sdk/rust/cyt-indexer/README.md Retrieve information from a built catalog using the cyt-indexer CLI. This command allows specifying input data, output file, configuration, and various policy settings for filtering and pruning tools. ```bash cyt-indexer retrieve --catalog ./.catalog --input survivors.json --output out.json \ --config config.json \ --system-policy prune_optional \ --mcp-policy prune_all \ --tool-policy Agent=always_include \ --tool-policy mcp__fff__multi_grep=always_include \ --per-tool per-tool.json ``` -------------------------------- ### Set Environment Variables for Proxy Source: https://github.com/qdrddr/clear-your-tools/blob/main/debug/README.md Configures the necessary environment variables to point Claude Code at the proxy and set API keys. Ensure you replace '...' with your actual API key. ```bash export ANTHROPIC_BASE_URL="http://localhost:8834/anthropic" export OPENROUTER_API_KEY="..." export ANTHROPIC_AUTH_TOKEN="${OPENROUTER_API_KEY}" ``` -------------------------------- ### Import cyt-indexer Functions Source: https://github.com/qdrddr/clear-your-tools/blob/main/sdk/python/README.md Import necessary functions from the cyt_indexer library for catalog building, indexing, and tool preparation. ```python from cyt_indexer import ( build_catalog_from_tools, build_catalog_index, anthropic_tools_to_catalog_entries, prepare_tool_entry, retrieve_tools, ) ``` -------------------------------- ### Add cyt-indexer Dependency Source: https://github.com/qdrddr/clear-your-tools/blob/main/sdk/rust/cyt-indexer/README.md Add the cyt-indexer crate to your Cargo.toml file to include it as a project dependency. ```toml [dependencies] cyt-indexer = "0.1" ``` -------------------------------- ### Set Default Pruning Policies Source: https://github.com/qdrddr/clear-your-tools/blob/main/CONFIG.md Configure default pruning policies for system tools and MCP tools in `config.yaml`. ```yaml defaults: system_tool_policy: prune_optional mcp_tool_policy: prune_all ``` -------------------------------- ### Run Local Tests for a Single Target Source: https://github.com/qdrddr/clear-your-tools/blob/main/sdk/e2e/README.md Execute local end-to-end tests for a specific target (e.g., Python) and optionally skip registry polling if the version is known to be live. ```bash ./sdk/e2e/scripts/run-local.sh --skip-wait python ``` -------------------------------- ### Import SDK Functions Source: https://github.com/qdrddr/clear-your-tools/blob/main/sdk/typescript/README.md Import necessary functions from the cyt-indexer-sdk for use in TypeScript projects. ```typescript import { anthropicToolsToCatalogEntries, buildCatalogFromTools, buildCatalogIndex, retrieveTools, } from "cyt-indexer-sdk"; ``` -------------------------------- ### Configure Per-Tool Pruning Overrides Source: https://github.com/qdrddr/clear-your-tools/blob/main/CONFIG.md Define specific pruning policies for individual tools in `config.yaml`. ```yaml pruning: per_tool: Agent: prune_optional mcp__hedl__hedl_convert_from: prune_optional mcp__hedl__batch: prune_all mcp__fff__multi_grep: always_include ``` -------------------------------- ### Run Local Tests with Explicit Version Source: https://github.com/qdrddr/clear-your-tools/blob/main/sdk/e2e/README.md Execute local end-to-end tests specifying an explicit package version. The packages must already be published to their respective registries. ```bash ./sdk/e2e/scripts/run-local.sh 0.1.10 ``` -------------------------------- ### Set OpenAI API Key Source: https://github.com/qdrddr/clear-your-tools/blob/main/CONFIG.md Export the OpenAI API key as an environment variable. ```bash export OPENAI_API_KEY="..." ``` -------------------------------- ### Pruning Pipeline Configuration Source: https://github.com/qdrddr/clear-your-tools/blob/main/CONFIG.md Configure the pruning pipeline stages and minimum tool thresholds. The 'rerank' stage is enabled by default for a moderate number of tools, while 'llm' can be added for more aggressive filtering. ```yaml models: rerankers: minimum_tools: 50 llm: minimum_tools: 50 pruning: pipeline: - rerank # - llm ``` -------------------------------- ### Run Local Tests for Multiple Targets Source: https://github.com/qdrddr/clear-your-tools/blob/main/sdk/e2e/README.md Execute local end-to-end tests for multiple specified targets (e.g., Rust and TypeScript) and skip registry polling. ```bash ./sdk/e2e/scripts/run-local.sh v0.1.10 rust typescript ``` -------------------------------- ### Check Gzip Header Source: https://github.com/qdrddr/clear-your-tools/blob/main/README.md Verify the header of a file to confirm if it is a gzip file. ```shell head -c 4 /tmp/cyt-msg.body | xxd # should show 1f8b when header says gzip ``` -------------------------------- ### Verify CYT Build After Proxy Fix Source: https://github.com/qdrddr/clear-your-tools/blob/main/README.md After upgrading to a CYT build that streams upstream bytes unchanged, verify the fix by running this curl command. This command sends a raw request to the CYT proxy and saves the response body. ```bash curl --raw -sS -D - -o /tmp/cyt-msg.body \ -H 'Accept-Encoding: gzip' \ ... # your POST to http://127.0.0.1:8834/anthropic/v1/messages ``` -------------------------------- ### Configure LLM Pruning Pipeline Source: https://github.com/qdrddr/clear-your-tools/blob/main/CONFIG.md Set the pruning pipeline to use only the LLM pruner. This configuration is placed in `~/.config/cyt/config.yaml`. ```yaml # ~/.config/cyt/config.yaml pruning: pipeline: - llm # LLM only (no reranker) # - rerank # or: [rerank, llm] for two-stage filtering defaults: remote: llm_model_nick: mercury-2 # must match a nick under models.llm.remote models: llm: minimum_tools: 50 # LLM stage runs when tool count ≥ this (default 50) ``` -------------------------------- ### Extract Tools Accepted JSON from SQLite Source: https://github.com/qdrddr/clear-your-tools/blob/main/debug/README.md Fetches the full tools JSON before pruning for a specific request ID from the SQLite database. This is useful for detailed analysis of the input tools. ```bash ID=019e6c0a-035c-7bd6-ab8b-75492296b553 sqlite3 ~/.config/cyt/stats.db " SELECT tools_accepted_json FROM proxy_request WHERE id = '${ID}' AND tools_accepted_json IS NOT NULL AND length(tools_accepted_json) > 0; " > tools_accepted.json ``` -------------------------------- ### Run Proxy in Dry-Run Mode Source: https://github.com/qdrddr/clear-your-tools/blob/main/debug/README.md Executes the proxy in a dry-run mode, which means it will not make upstream calls. This is useful for testing the proxy's behavior without external dependencies. ```bash uv run cyt proxy --debug-dry-run ``` -------------------------------- ### Check Gzip Encoding with curl Source: https://github.com/qdrddr/clear-your-tools/blob/main/CONFIG.md Use curl to inspect the Content-Encoding header of a response from the CYT proxy. Look for '1f8b' to confirm gzip encoding. ```bash curl --raw -sS -D - -o /tmp/cyt-msg.body ... # POST via http://127.0.0.1:8834/anthropic/... head -c 4 /tmp/cyt-msg.body | xxd # 1f8b when Content-Encoding is gzip ``` -------------------------------- ### Generate Local TLS Certificate Source: https://github.com/qdrddr/clear-your-tools/blob/main/DEV.md Generates a self-signed TLS certificate and private key for local development and testing. ```bash mkdir -p src/crt openssl req -x509 -nodes -days 365 -newkey rsa:4096 \ -keyout src/crt/key.pem \ -out src/crt/cert.pem \ -subj "/CN=localhost" \ -addext "subjectAltName=DNS:localhost,IP:127.0.0.1" ``` -------------------------------- ### Estimate Token Savings Source: https://github.com/qdrddr/clear-your-tools/blob/main/DEV.md Estimates token savings for a given request file using the count_request_tokens.py script. ```bash uv run count_request_tokens.py \ --tool-savings-percent 85 \ --requestfile temp_example_claude_call.json ``` -------------------------------- ### Import Advanced Library Components Source: https://github.com/qdrddr/clear-your-tools/blob/main/DEV.md Imports advanced or submodule components not directly re-exported from the main cyt.indexer module. ```python from cyt.indexer.catalog_io import CatalogBuilder, write_catalog_index from cyt.indexer.tokens import count_tokens, count_json_tokens, compact_json from cyt.indexer.build import collect_enums, prepare_tool_entry, prepare_system_tool_entry from cyt.common.path_constants import DECOMPOSED_PREFIX ``` -------------------------------- ### Access API Key from macOS Keychain Source: https://github.com/qdrddr/clear-your-tools/blob/main/README.md Retrieves a stored API key from the macOS Keychain and exports it as an environment variable. This allows applications to access the key without hardcoding it. ```bash export ANTHROPIC_AUTH_TOKEN="$(security find-generic-password -s "nono" -a "OPENROUTER_API_KEY" -w)" ``` -------------------------------- ### Extract Final Tools JSON from SQLite Source: https://github.com/qdrddr/clear-your-tools/blob/main/debug/README.md Retrieves the full tools JSON after pruning for a specific request ID from the SQLite database. This shows the final set of tools that would be sent to the upstream model. ```bash ID=019e6c0a-035c-7bd6-ab8b-75492296b553 sqlite3 ~/.config/cyt/stats.db " SELECT tools_final_json FROM proxy_request WHERE id = '${ID}' AND tools_final_json IS NOT NULL AND length(tools_final_json) > 0; " > tools_final.json ``` -------------------------------- ### Store API Key in macOS Keychain Source: https://github.com/qdrddr/clear-your-tools/blob/main/examples/agents/claude/README.MD Securely store your API key using the macOS Keychain utility. This avoids exposing the key directly in environment variables or scripts. ```shell # Store key in secure vault security add-generic-password -s "nono" -a "OPENROUTER_API_KEY" -w "sk-..." # macOS # Now you can access the key like this: export ANTHROPIC_AUTH_TOKEN="$(security find-generic-password -s "nono" -a "OPENROUTER_API_KEY" -w)" ``` -------------------------------- ### Query Latest Investigable Rows from SQLite Source: https://github.com/qdrddr/clear-your-tools/blob/main/debug/README.md Retrieves the IDs and timestamps of the last 10 investigable rows from the proxy request SQLite database. These rows contain full tool JSON when debug mode or store_full_tools is enabled. ```bash sqlite3 ~/.config/cyt/stats.db " SELECT id, datetime(ts_ms / 1000, 'unixepoch') AS ts FROM proxy_request WHERE tools_accepted_json IS NOT NULL AND length(tools_accepted_json) > 0 ORDER BY ts_ms DESC LIMIT 10; " ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.