Context Platform CLI
Project description
Context Platform CLI
Typer-powered command-line interface for managing Context Platform projects and items.
Note: Both
ctxandctxmecommands are available. They are identical - use whichever you prefer. Examples below usectx.
Installation
From the repo root (uv workspace):
uv sync --all-extras --all-groups
ctx will then be available via uv run ctx ... (or activate .venv and call directly).
Global Options
ctx --version– show the CLI version and exitctx --output json <command>(-o json) – emit errors as a machine-parseable JSON envelope instead of Rich-formatted text. This governs error output only: successful command output stays in the normal text format. To get JSON for successful output, use the per-command--jsonflag (see JSON Output below).ctx --install-completion <shell>/ctx --show-completion <shell>– shell completion setup (see Shell Completion)
Configuration
The CLI stores settings under the platform-specific config directory (see platformdirs). Override
the path in scripts/tests with the CTXME_CONFIG_DIR environment variable.
Key commands:
ctx config --default-project <project>(-p) – set the default project keyctx set-project <project>– set the default project key (same effect asconfig --default-project)ctx current– show the current default project (local only, no API call)ctx status– show local config + auth status (no API call)ctx auth login– device flow sign-in (opens browser, stores API key in keychain). Use--scopes read,write,adminto request specific scopes for the issued key (default:read,write; requests above your role's ceiling are denied at verification)ctx auth status– show stored API key prefix + backend metadatactx auth set-key <key>– manually persist API keys using the OS keychainctx auth logout– remove stored API key
To point the CLI at a different backend, use the environment variables CLI__API_BASE_URL and
CLI__USE_MOCK_CLIENT (see Environment Variables). ctx config also
accepts hidden --api and --mode flags, but these are dev-only options intentionally left
out of --help; they are not a supported configuration surface.
API keys are never written to disk; only stored through keyring.
For local development, you can set CLI__API_KEY to override the keychain without
modifying OS credentials. This value is read from the process environment only
(not from .env files) and is visible in process listings, so use it for local
testing only.
Commands
All commands emit Rich-formatted tables/panels with user-friendly messaging. Most accept
--project/-p to target a project other than the default, and --json for machine-parseable
success output.
Items
Item commands are available at the top level and, identically, under the ctx items group
(ctx list ≡ ctx items list, etc.).
ctx list– list items for the default (set-project) or--projectproject (--folder/-fto filter by folder,--recursive,--all,--limit,--sort,--order,--cursor/--no-limitfor pagination)ctx get <item>– download an item to the current directory (file items use original filename;--stdout/--clipboardonly for text MIME types;--json --stdoutemits one JSON object with metadata + content)ctx read <item>– retrieve text content for AI consumption (writes cache metadata by default;--stdoutprints content only;--json --stdoutemits one JSON object with metadata + content and skips cache writes;--max-charsto limit length)ctx create <item> --data "<text>"– create or update an inline item (--title,--tag,--folder,--mime-typeoptional;--forceto overwrite without prompting)ctx create <item> --src <path>– upload a file as a context itemctx upload <path>– upload a file as an item (equivalent tocreate --src;--key/-kto override the derived item key)ctx update <item>– update item metadata:--title,--mime-type,--folder, and tag operations (--tagreplaces all tags;--add-tag/--remove-tag/--clear-tagsfor incremental changes)ctx delete <item>– delete an item (use--forceto skip confirmation)ctx search <query>– search for items (see Search Modes below;--tagto filter,--all/--limitfor cross-project search)ctx folders– list folder paths and item counts (--parentto list direct children of a folder)ctx mv <item> --folder <path>– move an item to a folder (empty string""moves it to the project root)
Hidden aliases exist for backwards compatibility: ls (alias of list), put (alias of
create), rm (alias of delete), and up (alias of upload). They work but do not appear
in --help; prefer the canonical names.
Projects
ctx projects list– list available projects (ctx projects lsis a hidden alias)ctx projects current– show the current default project (local only)ctx projects create <name>– create a new project (--key/-kfor an explicit project key,--description/-doptional)ctx projects delete <key>– delete a project (--yes/-yto skip the confirmation prompt when deleting the default project)
Auth
ctx auth login– device-flow sign-in (--scopesto request specific key scopes,--no-open-browserto print the verification URL instead of opening it)ctx auth logout– remove the stored API key from the keychainctx auth status– show current authentication statusctx auth set-key <key>– store an API key securely in the OS keychain
Usage
ctx usage llm– list recent LLM invocations for your account (requires an admin-scoped key; seectx auth login --scopes). Filters:--project,--since/--until(ISO-8601),--status,--workload,--model,--limit,--cursor(pagination, requires--json)
# Recent failed LLM calls for one project, as JSON
ctx usage llm --project my-project --status error --json
Wiki
The ctx wiki group manages and queries the generated project wiki:
ctx wiki status– show wiki generation state, staleness, and coveragectx wiki generate– trigger wiki generation or refreshctx wiki list– list wiki pages (--page-type,--include-stale,--limit,--cursor)ctx wiki get <slug>– show a wiki page's content and metadatactx wiki search <query>– search wiki pages (--page-type,--include-stale,--limit)ctx wiki query "<question>"– ask the wiki for a synthesized, cited answer (--file-backfiles novel answers back as new wiki pages, visible to the whole account;--limitcaps retrieved pages)ctx wiki settings– show or change wiki settings (--llm-opt-in/--no-llm-opt-intoggles external LLM processing for the project's wiki)ctx wiki runs– show wiki maintenance run history (--status,--trigger,--limit,--cursor)ctx wiki schema get– print the wiki schema page body (pipe to a file to edit)ctx wiki schema set [file]– replace the wiki schema from a file or stdin (ETag-aware conditional write)
# Generate the wiki, watch progress, then ask it a question
ctx wiki generate
ctx wiki status
ctx wiki query "How does authentication work?"
# Edit the wiki schema
ctx wiki schema get > schema.md
ctx wiki schema set schema.md
Maintenance
ctx update-check– check for newer versions of the CLI (also runs automatically at startup; seeCTXME_UPDATE_CHECKbelow)
JSON Output
There are two distinct JSON mechanisms — they are independent and do not imply each other:
- Per-command
--json– switches a command's successful output to machine-parseable JSON (e.g.ctx list --json,ctx read <item> --json). Supported by most commands; see each command's--help. - Global
--output json(-o json) – switches error output to a machine-parseable JSON envelope. It does not change successful command output;ctx --output json statusstill prints the normal text output. Combine both when scripting:ctx -o json get <item> --json --stdout.
Combined JSON + Stdout for get and read
ctx get <item> --json --stdout returns exactly one JSON document to stdout. It includes
item metadata plus a content field in the same payload.
Example shape for inline items:
{
"project_key": "core",
"item_key": "welcome",
"title": "welcome",
"mime_type": "text/plain",
"tags": [],
"folder": null,
"content_type": "inline",
"content": "..."
}
For file items, payload also includes file_id, size, and original_filename.
content is included only for text-compatible MIME types (text/*, JSON/XML/YAML/JS).
Binary files still follow existing stdout guardrails (for example PDFs without --text):
the command fails instead of emitting partial success JSON. In global JSON mode
(--output json), this uses the standard JSON error envelope.
--json --clipboard remains invalid for get and read, and ctx get --json --dest remains
invalid.
ctx read <item> --json --stdout returns a combined, non-cache schema:
{
"content": "...",
"chars": 123,
"truncated": false,
"project_key": "core",
"item_key": "welcome",
"title": "welcome",
"mime_type": "text/plain",
"tags": [],
"folder": null
}
--max-chars truncation still applies in this mode. Combined-mode read intentionally omits
path; standalone ctx read --json continues to return the cache path schema.
Search Modes
The search command intelligently determines which projects to search based on your configuration:
-
Explicit project search (using
--projectflag):ctx search "machine learning" --project my-research
Searches only the specified project.
-
Default project search (when default project is set):
ctx set-project my-main-project ctx search "API documentation"
Searches only your default project.
-
Implicit all-projects search (no default project configured):
# No default project set ctx search "kubernetes config" # Output: Searching across all projects (no default project set)
Automatically searches all projects with an informational message.
-
Explicit all-projects search (using
--allflag):ctx search "error handling" --all --limit 20
Searches across all projects regardless of default project configuration.
Note: The --project and --all flags are mutually exclusive. Use one or the other, not both.
If you have no projects yet, the search command will prompt you to create one:
ctx search "test"
# Output: No projects found. Create one with: ctx projects create <name>
Unified Context Items
The CLI uses a unified API that handles both inline text and file uploads:
- Inline content: Use
--datato provide text content directly - File uploads: Use
--srcorctx uploadto upload supported files (.txt,.md,.pdf,.docx,.csv,.tsv,.html)
When listing items, you'll see:
content_type: Whether the item isinlinetext or afileprocessing_status:ready(searchable),processing(being indexed), orfailed
Example:
# Create inline item
ctx create my-notes --data "Meeting notes from today"
# Upload a file
ctx create quarterly-report --src ./report.docx
# List items with processing status
ctx list
Polling for Processing Status
When uploading files, extraction and indexing happen asynchronously. You can poll for completion:
# Upload a file (returns processing status)
ctx create my-document --src document.pdf
# Use ctx list to check processing status
ctx list
Alternatively, rerun ctx list until the status shows ready or failed.
Environment Variables
| Variable | Description |
|---|---|
CTXME_DEBUG |
Set to 1 to enable debug output (shows API URL, mode, and full tracebacks on errors) |
CTXME_CONFIG_DIR |
Override the default config directory path |
CTXME_CACHE_DIR |
Override the default cache directory path |
CTXME_UPDATE_CHECK |
Set to 0, false, or no to disable automatic update checks at startup |
CTXME_UPDATE_CHECK_INTERVAL |
Override the update check interval in seconds (default: 86400 / 24 hours) |
CLI__API_BASE_URL |
Override the backend API URL (takes precedence over config file) |
CLI__API_KEY |
Override the API key (process env only; takes precedence over keychain) |
CLI__DEFAULT_PROJECT |
Override the default project (takes precedence over config file) |
CLI__USE_MOCK_CLIENT |
Set to true to use the mock client |
Example: Use CLI__API_KEY for local testing
# Local testing without touching the keychain
export CLI__API_KEY="ctxme_a74558fa64f4a99a5666a47b4954ea99"
export CLI__API_BASE_URL="http://localhost:8000"
uv run ctx list
# Return to keychain-based auth
unset CLI__API_KEY
Example: View full configuration details
CTXME_DEBUG=1 ctx status
# Output:
# API: https://api.example.com
# Mode: live
# Auth: Signed in
# Project: my-project (default)
When ctx get saves to a directory, it sanitizes item keys into safe filenames (no path
separators or ..).
Tests
uv run pytest cli/tests
Tests cover configuration round-trips, keyring helpers (via an in-memory backend), and representative Typer command flows.
Shell Completion
Enable tab completion for commands, subcommands, and flags. Works for both ctx and ctxme.
Installation
Bash:
ctx --install-completion bash
# or: ctxme --install-completion bash
Zsh:
ctx --install-completion zsh
Fish:
ctx --install-completion fish
PowerShell:
ctx --install-completion powershell
Usage
ctx <TAB> # Shows: auth, config, get, list, create, ...
ctx auth <TAB> # Shows: login, logout, status, set-key
ctx get --<TAB> # Shows: --project, --dest, --stdout, --force, ...
Troubleshooting
- Restart shell after installation
- Ensure completion script is sourced in shell config
- Check
ctx --show-completion <shell>for manual setup
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ctxme-0.2.0.tar.gz.
File metadata
- Download URL: ctxme-0.2.0.tar.gz
- Upload date:
- Size: 139.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5dff4c9f27253ad3e4f003fbe09e22bc60f89fce0b610de71bc45d8d100da714
|
|
| MD5 |
4176df586b1f86e3e6b0958e9b0e84e3
|
|
| BLAKE2b-256 |
ba62aca0d0ac161ce7d49105c77eeecc04c19371adcb3712f2eed1b9ed98f4af
|
File details
Details for the file ctxme-0.2.0-py3-none-any.whl.
File metadata
- Download URL: ctxme-0.2.0-py3-none-any.whl
- Upload date:
- Size: 91.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ffdea3dbb6d6fe1f0cb7f3165f4ebee885c5f7bb88ae30ff2222acafc2e5f7a3
|
|
| MD5 |
6fca6d5ec1e9b8b8714512181994e448
|
|
| BLAKE2b-256 |
6f9a915ded92af98ef35e51d2b77c5336d637f9a4e691ef6d0a1696cb70cbb94
|