Skip to content

CLI Reference

Terminal window
npm install -g @intentweave/cli
iw --version

Or with npx:

Terminal window
npx @intentweave/cli <command>

Initialize an IntentWeave workspace.

Terminal window
iw init [directory]

Creates a .iw/ directory with config, cache, and index storage.

Build the CARI index.

Terminal window
iw index build [options]
OptionDefaultDescription
--depth <mode>structuredstructured or full (body text + IDF)
--include <glob>Only index matching files
--exclude <glob>Skip matching files
-v, --verboseoffShow per-stage progress

Ranked file retrieval.

Terminal window
iw index retrieve <query> [options]
OptionDefaultDescription
--limit <n>10Maximum results
--scope <type>allcode, docs, or all

Cross-layer connection discovery.

Terminal window
iw index connections <entity> [options]
OptionDefaultDescription
--limit <n>15Maximum connections
--include <type>alldoc_cooc, co_change, code_import

CI drift detection.

Terminal window
iw index check [options]
OptionDefaultDescription
--changed <files...>Changed files
--severity <level>infoinfo, warning, critical
-f, --formattexttext, json, github

Corpus-wide health dashboard.

Terminal window
iw index report

Incremental index update.

Terminal window
iw index update [-v]

All analysis queries are available as iw index subcommands:

CommandPurpose
iw index clonesExact clone detection (identical body hash)
iw index structural-clonesType 2 clones (same control flow, different identifiers)
iw index circular-importsImport cycle detection
iw index unused-exportsExported symbols never imported
iw index hotspot-priorityHigh-churn low-doc files ranked by urgency
iw index todosTODO/FIXME/HACK/XXX inventory
iw index module-coverageDocumentation coverage % per directory
iw index orphaned-sectionsDoc sections with all-ungrounded mentions
iw index doc-completenessPer-doc completeness vs. referenced exports
iw index cross-group-driftCross-group entity coverage conflicts
iw index mentions-of <id>Find doc mentions of a code or external entity
iw index annotations-for <path>List all annotations for a documentation file
iw index register-entities <file>Register external entities from JSON file
iw index test-coverageMap test files to source files, find untested exports
iw index hubsGod-node / hub analysis (degree centrality)
iw index communitiesCommunity detection (structural / semantic / temporal)
iw index surprisesSurprising connection ranking (composite score)
iw index rationaleWHY/NOTE/IMPORTANT/DESIGN rationale inventory
iw index terminologyTerminology inconsistency detection
iw index dep-depthTransitive import depth + fan-in/fan-out risk
iw index boundary-violationsCross-package internal import detection
iw index layers-inferAuto-infer architectural layers from import graph
iw index layers-checkValidate imports against layer boundaries
iw index layers-check --compareAs-is vs. as-should layer comparison
iw index conformanceInterface conformance drift detection
iw index dead-featuresDead feature detection (unused + undocumented + stale)
iw index api-surfaceAPI surface changelog (additions, removals, sig changes)
iw index focus <target>Focused architecture view around a target entity
iw index callsQuery the call graph (all edges)
iw index calls --caller-fileCalls from a specific file
iw index calls --callee-nameAll callers of a function
iw index trace --entryBFS call-path trace from entry-point file
iw index rule-coveragePackages with zero behavioral rules
iw index export --bookInsights Book (15+ chapters, primary deliverable)
iw index export --html§10.1 interactive standalone HTML architecture report
iw index export --focus <t>Focused Graphviz SVG architecture report
iw intent checkCheck all intent domains (structural/behavioral/documentary)
iw intent check --domainTarget one domain: structural, behavioral, documentary, all
iw intent check --baselineRegression gating: fail only if violations increased
iw intent extractExtract rules from an ADR via LLM
iw intent livingLiving documentation health (documentary domain)
iw intent scoreComposite living documentation score (A–F, 4 dimensions)

All subcommands support --db <path> and -f, --format <text|json>. Some also accept -n, --limit or --kind.

These queries are also available as MCP tools (e.g., cari_clones) and via the @intentweave/index programmatic API.

Auto-infer architectural layers from your import graph topology.

Terminal window
iw index layers-infer [options]
OptionDefaultDescription
--db <path>.iw/index.dbPath to CARI index
-f, --formattexttext or json

Uses topological sort of the import DAG to assign depth ranks, then buckets files into layers (foundation at 0, entry points at the top). Outputs layer definitions with file assignments.

Validate all imports against inferred or configured layer boundaries.

Terminal window
iw index layers-check [options]
OptionDefaultDescription
--db <path>.iw/index.dbPath to CARI index
--allow-skip-layeroffDon’t flag skip-layer imports
--compareoffShow as-is vs. as-should delta view
-f, --formattexttext or json

Detects:

  • Reverse imports — lower layer importing from higher layer
  • Skip-layer imports — layer N importing from layer N+2 (skipping N+1)

Each violation includes source file, target file, source layer, target layer, and a human-readable reason.

Generate a standalone interactive HTML architecture report.

Terminal window
iw index export --html [options]
OptionDefaultDescription
-o, --output <path>architecture.htmlOutput file path
--db <path>.iw/index.dbPath to CARI index
-m, --mode <mode>structuralCommunity mode: structural, semantic, temporal
--provider <name>LLM provider for layer naming (openai)
--model <name>gpt-4o-miniModel for LLM naming
--api-key <key>$OPENAI_API_KEYOpenAI API key (if not env var)

The report combines data from layers, communities, dependencies, and boundary violations into three interactive views:

  • Layers — tiered layout with import edges (violations in red)
  • Communities — force-directed layout coloured by community, with switchable modes (structural, semantic, temporal) and vertical slice highlighting
  • Dependencies — root-focused tree for any selected file

Features: directory aggregation, zoom/pan, edge filtering, search, hover tooltips with per-file metrics, and optional LLM-generated names for layers and directories.

Detect interface conformance drift — when a class claims to implement an interface but method signatures have diverged.

Terminal window
iw index conformance [options]
OptionDefaultDescription
--db <path>.iw/index.dbPath to CARI index
-f, --formattexttext or json

Reports: missing methods, missing properties, and signature mismatches.

Combine three signals to surface likely dead features.

Terminal window
iw index dead-features [options]
OptionDefaultDescription
--db <path>.iw/index.dbPath to CARI index
--min-signals <n>2Minimum signals to report (1–3)
--staleness <months>6Months since last modification
-n, --limit <n>100Maximum results
-f, --formattexttext or json

Signals: (a) unused export, (b) undocumented symbol, (c) stale file (no commits in N months).

Track exported symbols over time via git history. Detects additions, removals, and signature changes per release.

Terminal window
iw index api-surface [options]
OptionDefaultDescription
--db <path>.iw/index.dbPath to CARI index
--baseline <ref>latest git tagGit ref to compare against
-f, --formattexttext or json

Example output: “+40 added, −14 removed, ~1 signature changed across 28 files”.

Focused architecture view around a target file or symbol.

Terminal window
iw index focus <target> [options]
OptionDefaultDescription
--db <path>.iw/index.dbPath to CARI index
--hops <n>2Expansion depth from target
--max-nodes <n>20Maximum nodes in the view
-f, --formattexttext or json

Generate a focused Graphviz SVG architecture report.

Terminal window
iw index export --focus <target> [options]
OptionDefaultDescription
--hops <n>2Expansion depth
--max-nodes <n>20Maximum nodes
-o, --outputfocus.htmlOutput file path

KG queries are available via the MCP server (iw mcp) using GitHub Copilot tools (kg_query, kg_context, kg_entities, kg_impact, kg_doc_health, kg_schema). Set NEO4J_URI, NEO4J_USER, and NEO4J_PASSWORD environment variables before starting the MCP server.

Documentation freshness analysis. Three modes (least → most infrastructure):

  1. --lite — Zero-infra keyword scan (no index needed)
  2. (default) — CARI-backed analysis from .iw/index.db (no Neo4j)
  3. --neo4j — Full KG-based analysis (requires Neo4j + persisted KWG)
Terminal window
iw intent living [files...] [options]
OptionDefaultDescription
--db <path>.iw/index.dbPath to CARI index (default mode)
--neo4joffFull KG mode — requires Neo4j
-s, --sessionSession ID (required for --neo4j only)
--onlyallSpecific detectors: doc-code,temporal,deps,doc-doc
--liteoffLightweight keyword-only mode
-f, --formatmarkdownOutput format: markdown | json
-o, --outputWrite to file
-v, --verboseoffShow progress

Removed. Persisting to Neo4j via CLI is no longer supported. Use the kg_* MCP tools from GitHub Copilot to query an existing Neo4j instance.

Removed. Cross-layer code linking is now handled automatically during iw index build.

Start MCP server for GitHub Copilot.

Terminal window
iw mcp [options]
OptionDefaultDescription
-s, --sessionDefault session
-v, --verboseoffLog invocations

VariableDefaultDescription
NEO4J_URIbolt://localhost:7687Neo4j URI
NEO4J_USERNAMEneo4jNeo4j user
NEO4J_PASSWORD(required for KG)Neo4j password
NEO4J_DATABASEneo4jNeo4j database
IW_SESSIONdefaultDefault session ID
OPENAI_API_KEY(optional)For --provider openai + NL queries
IW_LLM_MODELgpt-4o-miniLLM model