| name | cortex |
| description | CLI for managing the Cortex email automation pipeline. Use this skill when the user wants to query emails, check queue status, trigger backfills, view classifications, or manage the email triage system. Triggers on keywords like "cortex", "email pipeline", "queue status", "classification", "backfill", "triage". |
| license | MIT (see LICENSE.txt) |
| metadata | {"version":"0.1.0","author":"Devon Jones","repository":"https://github.com/devonjones/cortex-utils"} |
Cortex Gateway CLI
Command-line interface for managing the Cortex email automation pipeline.
Prerequisites
Note: This skill documentation lives in the cortex-utils repository but describes the cortex CLI tool provided by the separate cortex-gateway project. The gateway provides a unified REST API for Cortex services, and the CLI is the command-line interface to that API.
The cortex CLI is installed from the cortex-gateway package:
uv pip install git+https://github.com/devonjones/cortex-gateway.git
cd ~/Projects/cortex/gateway && uv pip install -e .
Configuration
Set the gateway URL via environment variable or CLI flag:
export CORTEX_GATEWAY_URL=http://localhost:8097
cortex --url http://custom-host:8097 <command>
Command Reference
Global Options
| Option | Description |
|---|
--url | Gateway URL (env: CORTEX_GATEWAY_URL) |
-j, --json-output | Output raw JSON instead of formatted tables |
Health Check
cortex health
Email Commands
cortex emails list [-n LIMIT] [--offset N] [-l LABEL_ID]
cortex emails get <gmail_id>
cortex emails body <gmail_id>
cortex emails text <gmail_id>
cortex emails stats
cortex emails by-label <label_id> [-n LIMIT]
cortex emails sender <from_addr>
cortex emails distribution [-n LIMIT]
cortex emails uncategorized [-n LIMIT]
Queue Commands
cortex queue stats
cortex queue failed [-q QUEUE_NAME] [-n LIMIT]
cortex queue retry <job_id>
cortex queue delete <job_id>
cortex queue retry-all <queue_name>
Backfill Commands (Re-enqueue existing emails)
cortex backfill trigger [-q QUEUE] [-d DAYS] [-l LABEL] [-p PRIORITY]
cortex backfill status
cortex backfill cancel <queue_name>
Triage Commands
cortex triage stats
cortex triage rerun [-i GMAIL_ID]... [-l LABEL] [-s SENDER]... [-d DAYS] [-f] [-p PRIORITY]
cortex triage list [-n LIMIT] [-l LABEL]
Sync Commands (Gmail API backfill)
cortex sync backfill [-d DAYS] [-a YYYY-MM-DD]
cortex sync jobs [-n LIMIT] [-s STATUS]
cortex sync job <job_id>
cortex sync cancel <job_id>
Common Workflows
Find missing rules
cortex emails uncategorized -n 20
cortex emails sender notifications@example.com
Debug classification issues
cortex emails distribution -n 100
cortex emails by-label Label_117 -n 50
Re-process emails
cortex triage rerun -l Cortex/Uncategorized -d 7
cortex triage rerun -s "service@paypal.com" -d 7
cortex triage rerun -s "*@substack.com" -d 14
cortex backfill trigger -q triage -l Label_123 -d 30
Monitor queue health
cortex queue stats
cortex queue failed -n 20
cortex queue retry-all labeling
Historical sync from Gmail
cortex sync backfill -d 30
cortex sync jobs
Config Management
Triage rules configuration is managed via the Gateway REST API (not CLI).
Update Config Workflow
-
Edit the rules YAML at ~/cortex-config/rules.yaml on Hades (or locally first)
-
Upload via API:
curl -X PUT http://10.5.2.21:8097/config \
-H "Content-Type: text/plain" \
-H "X-Created-By: your-name@context" \
-H "X-Notes: Description of changes" \
--data-binary @/path/to/rules.yaml
- Reload triage worker:
ssh devon@10.5.2.21 "docker kill -s SIGHUP cortex-triage-worker"
- Verify reload:
ssh devon@10.5.2.21 "docker logs cortex-triage-worker 2>&1 | grep -E 'reload|version' | tail -3"
Config API Endpoints
| Endpoint | Method | Description |
|---|
/config | GET | Download active config as YAML |
/config | PUT/POST | Upload new config version |
/config/validate | POST | Validate YAML without saving |
/config/versions | GET | List all config versions |
/config/versions/<n> | GET | Download specific version |
/config/rollback/<n> | POST | Rollback to version N |
/config/diff/<v1>/<v2> | GET | Compare two versions |
Validate Before Upload
curl -X POST http://10.5.2.21:8097/config/validate \
-H "Content-Type: text/plain" \
--data-binary @/path/to/rules.yaml
Returns {"valid": true, "stats": {...}} or {"valid": false, "errors": [...]}.
Output Formats
By default, commands output formatted tables. Use -j for JSON:
cortex emails uncategorized -n 5
cortex -j emails uncategorized -n 5