Salta ai contenuti

contextia init

Questi contenuti non sono ancora disponibili nella tua lingua.

contextia init creates the .contextia/ directory structure in the current project, generating the configuration file, identity document, and all required subdirectories.

contextia init [OPTIONS]
OptionShortDescription
--name <name>-nProject name (default: auto-detected)
--format <fmt>-fOutput format: human, json, context
--json-jShorthand for --format json
--help-hShow help and exit

When --name is not provided, Contextia detects the project name from the first available source:

  1. pyproject.toml — reads [project].name
  2. package.json — reads name
  3. Cargo.toml — reads [package].name
  4. .git directory — reads the repository directory name
  5. Current directory name as fallback

Running contextia init in a Python project creates:

.contextia/
├── config.yaml
├── system/
│ ├── identity.md
│ ├── specs/
│ ├── norms/
│ └── rationale/
└── work/
├── tasks/
└── logs/

The generated configuration includes auto-detected language settings:

version: "1.0"
project:
name: my-api
languages:
- python
paths:
system: system
work: work
cache: .cache
annotations:
prefix: "@"
comment_syntax:
python: "#"

A starter identity document with YAML frontmatter:

---
project: my-api
version: "0.1.0"
---
# my-api
Describe your project here. This document is loaded by AI agents
as always-on context. Keep it concise: what the project is, its
primary purpose, and key architectural choices.

Initialize with auto-detection:

Terminal window
$ contextia init
Detected project: my-api (from pyproject.toml)
Detected language: python
Created .contextia/config.yaml
Created .contextia/system/identity.md
Created .contextia/system/specs/
Created .contextia/system/norms/
Created .contextia/system/rationale/
Created .contextia/work/tasks/
Created .contextia/work/logs/
Initialized contextia in /home/user/my-api

Initialize with an explicit name:

Terminal window
$ contextia init --name billing-service
Created .contextia/config.yaml
Initialized contextia project: billing-service

JSON output (for scripting):

Terminal window
$ contextia init --json
{
"project": "my-api",
"root": "/home/user/my-api",
"created": [
".contextia/config.yaml",
".contextia/system/identity.md",
".contextia/system/specs/",
".contextia/system/norms/",
".contextia/system/rationale/",
".contextia/work/tasks/",
".contextia/work/logs/"
]
}
  • If .contextia/ already exists, the command exits with an error and does not overwrite existing files.
  • The command writes status messages to stderr and the result to stdout, allowing clean piping with --json.
  • Language detection inspects the presence of pyproject.toml, package.json, Cargo.toml, go.mod, and common file extensions in the project root.

After initializing, write your identity.md and create your first spec:

Terminal window
$EDITOR .contextia/system/identity.md
contextia new spec --title "Authentication Flow"