Saltearse al contenido

CLI Overview

Esta página aún no está disponible en tu idioma.

The Contextia CLI (contextia) is the human-facing interface for managing context architecture in your project. It shares the same core logic as the MCP server, so every operation you perform via the CLI produces identical results to what an AI agent sees through the MCP tools.

Terminal window
# Install with uv (recommended)
uv tool install contextia
# Or run directly without installing
uvx contextia --help
contextia [OPTIONS] COMMAND [ARGS]
OptionShortDescription
--format <fmt>-fOutput format: human (default), json, context
--json-jShorthand for --format json
--no-colorDisable colored output (also respects NO_COLOR env var)
--root <path>-rOverride project root (default: auto-detected)
--verbose-vPrint additional diagnostic information to stderr
--help-hShow help and exit
--versionShow version and exit

Every command supports three output formats, controlled by --format:

human (default) — Colored, tabular output designed for terminal use.

Terminal window
$ contextia list --type spec
ID Title Status
SPEC-AUTH-001 Authentication Flow approved
SPEC-API-002 REST API Conventions draft
SPEC-DB-003 Database Migration Strategy approved

json — Machine-parseable JSON, suitable for piping to jq or other tools.

Terminal window
$ contextia list --type spec --json | jq '.[].id'
"SPEC-AUTH-001"
"SPEC-API-002"
"SPEC-DB-003"

context — Compact, ANSI-free output optimized for LLM consumption. Used internally by the MCP server.

Terminal window
$ contextia show SPEC-AUTH-001 --format context
[SPEC-AUTH-001] Authentication Flow (approved)
paths: src/auth/**, src/middleware/auth.py
links: DEC-002, NORM-SEC-001
---
Users authenticate via OAuth 2.0 with PKCE. The auth module handles...

Contextia locates your project root by walking up from the current working directory, searching for .contextia/config.yaml. This is the same mechanism used by git to find .git/:

/home/user/project/src/auth/ # you are here
/home/user/project/src/ # no .contextia/config.yaml
/home/user/project/ # .contextia/config.yaml found -> project root

You can override this with --root:

Terminal window
contextia --root /path/to/project list --type spec

The CLI and MCP server are thin wrappers around the same core library. The core functions know nothing about output formatting or transport:

CLI (cyclopts) -> core.find_specs(root, query=...) -> format for terminal
MCP (FastMCP) -> core.find_specs(root, query=...) -> format for agent

This means every bug fix or feature added to the core is automatically available in both interfaces. The CLI is for humans running commands in a terminal; the MCP server is for AI agents calling tools programmatically.

CommandDescription
initCreate a new .contextia/ directory
newScaffold a new artifact (spec, task, decision, norm)
showDisplay a single artifact by ID
searchFree-text search across artifacts
listList all artifacts with filtering
traceReverse lookup: file path to governing specs/norms
contextAssemble full context for a task
checkValidate integrity of the context architecture
taskManage task lifecycle
logRead and write session logs
VariableDescription
NO_COLORDisable colored output (any value)
CONTEXTIA_ROOTOverride project root discovery
CONTEXTIA_FORMATDefault output format (human, json, context)
CodeMeaning
0Success
1Error (broken refs, missing files, invalid input)
2Usage error (invalid arguments)