Saltearse al contenido

contextia context

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

contextia context is the core command of Contextia. Given a task ID, it assembles a complete context bundle by following explicit links: task references specs, specs reference decisions and norms, and all linked documents are collected into a single output. No semantic search, no guessing — just deterministic link traversal.

contextia context <task-id> [OPTIONS]
ArgumentDescription
task-idTask identifier (e.g., TASK-007)
OptionShortDescription
--depth <level>-dDetail level: meta, summary, full (default: full)
--budget <tokens>-bApproximate token budget for the output
--include-identityPrepend identity.md to the context (default: true)
--no-identityExclude identity.md from the context
--format <fmt>-fOutput format: human, json, context
--json-jShorthand for --format json
--help-hShow help and exit

The context assembly follows a deterministic chain:

TASK-007
└── specs: [SPEC-AUTH-001]
├── links: [DEC-002, NORM-SEC-001]
│ ├── DEC-002 (decision)
│ └── NORM-SEC-001 (norm)
└── paths: [src/auth/**]
└── (file listing, not content)

The output is ordered: identity (if included), then the task, then specs, then decisions, then norms. Each section is clearly delimited.

The --depth and --budget options control how much content is included:

  • --depth meta: Only frontmatter for all linked artifacts. Minimal token usage.
  • --depth summary: Frontmatter plus the first section of each artifact.
  • --depth full: Complete content of all linked artifacts.
  • --budget N: Automatically adjusts depth per-artifact to fit within approximately N tokens. Prioritizes task and specs over decisions and norms.

Assemble full context for a task:

Terminal window
$ contextia context TASK-007
═══ Context for TASK-007: Implement OAuth login ═══
── identity ──
my-api: A REST API for the billing platform...
── task ──
TASK-007: Implement OAuth login (feature, active)
specs: SPEC-AUTH-001
## Objective
Implement OAuth 2.0 with PKCE for user authentication...
── spec ──
SPEC-AUTH-001: Authentication Flow (approved)
paths: src/auth/**, src/middleware/auth.py
links: DEC-002, NORM-SEC-001
## Overview
Users authenticate via OAuth 2.0 with PKCE...
── decision ──
DEC-002: OAuth 2.0 with PKCE over API keys (accepted)
## Context
We need an authentication mechanism...
── norm ──
NORM-SEC-001: No secrets in source code (active)
scope: **/*
## Rule
All secrets must be loaded from environment variables...
═══ 4 artifacts, ~1,240 tokens ═══

Context with a token budget:

Terminal window
$ contextia context TASK-007 --budget 500
═══ Context for TASK-007: Implement OAuth login ═══
── identity ──
my-api: A REST API for the billing platform.
── task ──
TASK-007: Implement OAuth login (feature, active)
specs: SPEC-AUTH-001
── spec ──
SPEC-AUTH-001: Authentication Flow (approved)
Users authenticate via OAuth 2.0 with PKCE...
── decision ──
DEC-002: OAuth 2.0 with PKCE over API keys (accepted)
── norm ──
NORM-SEC-001: No secrets in source code (active)
═══ 4 artifacts, ~480 tokens (budget: 500) ═══

Meta-only context for quick orientation:

Terminal window
$ contextia context TASK-007 --depth meta
═══ Context for TASK-007 (meta) ═══
task: TASK-007 Implement OAuth login (feature, active)
spec: SPEC-AUTH-001 Authentication Flow (approved)
decision: DEC-002 OAuth 2.0 with PKCE (accepted)
norm: NORM-SEC-001 No secrets in source code (active)
═══ 4 artifacts ═══

JSON output:

Terminal window
$ contextia context TASK-007 --json
{
"task": { "id": "TASK-007", "title": "Implement OAuth login", "status": "active" },
"specs": [
{ "id": "SPEC-AUTH-001", "title": "Authentication Flow", "status": "approved" }
],
"decisions": [
{ "id": "DEC-002", "title": "OAuth 2.0 with PKCE over API keys", "status": "accepted" }
],
"norms": [
{ "id": "NORM-SEC-001", "title": "No secrets in source code", "status": "active" }
],
"token_estimate": 1240
}
  • If a linked artifact does not exist (broken reference), a warning is printed to stderr and the missing artifact is noted in the output.
  • Identity is included by default. Use --no-identity to exclude it when the agent already has it loaded as an MCP resource.
  • Token estimates are approximate, based on a simple character-to-token ratio (roughly 4 characters per token).
  • The command exits with code 0 even if some links are broken, but prints warnings to stderr.