Skip to content

Ensure Intent in the Code (Semantic Rule Checking)

Vibe-coding AI agents and busy developers can easily implement against architectural decisions. While standard CI tools catch formatting and linting errors, they don’t catch deviations from architectural intent. IntentWeave bridges this gap by turning your Architectural Decision Records (ADRs) and conventions into enforceable code constraints—without requiring Neo4j or LLMs in your CI pipeline.

Translate intent from plain-text markdown and check it in CI milliseconds later.

Use an LLM provider to extract explicit architectural constraints from a plain-text ADR document and save them locally to .iw/rules.yaml:

Terminal window
# LLM-assisted: Extract architectural constraints from an ADR into .iw/rules.yaml
iw index rules-extract docs/ADR-003.md --provider openai --output .iw/rules.yaml

Key Options:

  • --provider <name>: LLM provider to use (e.g. openai).
  • --output <path>: Where to save the output rules (defaults to .iw/rules.yaml).

Validate if the codebase violates any of the extracted architectural rules in milliseconds, perfectly suited for incremental CI workflows:

Terminal window
# CI Validation: Check if the codebase violates any architectural rules
iw index rules-check --changed src/auth.ts --severity high --format text

Key Options:

  • --changed <files>: Comma-separated list of changed files (incremental CI mode).
  • --severity <level>: Minimum severity to report: high, medium, or low (default: low).
  • --rule-id <id>: Only check a specific rule by its ID.
  • --config <path>: Path to rules.yaml (default: .iw/rules.yaml).
  • --limit <n>: Maximum violations to report.
  • --format <format>: Output format: text or json.

Let the diagram be the specification. Extract component flows directly from Mermaid or ASCII diagrams in your markdown files and validate them against actual code imports.

Terminal window
# Validate AST imports against flows found in diagrams directly
iw index arch-check --from-scan docs/ARCHITECTURE.md --provider openai --strict

Key Options:

  • --from-scan <paths>: Scan markdown files for diagrams and interpret via LLM directly (no prior enrichment needed).
  • --provider <name>: LLM provider for --from-scan (openai or smart-mock).
  • --strict: Fail on undocumented flows. Exits with code 1 even if there are no violation matches but flows exist in code that are missing from the diagram.
  • --refresh: Re-run the LLM scan even if a valid cache exists.
  • --config <path>: Path to a manual architecture.yaml definition if skipping diagrams.

If you are already running Layer 2 Semantic Enrichment (iw index enrich), you can skip the LLM call entirely during the checks:

Terminal window
# Validate using pre-extracted diagram triples hidden inside your local index.db
iw index arch-check --from-diagrams

3. Built-in Intent Enforcements (Zero Config)

Section titled “3. Built-in Intent Enforcements (Zero Config)”

No LLM or config file is required for these commands. These built-in rules run via lightning-fast AST queries natively against the code index database.

Find active components ignoring @deprecated signals so you can finally delete old code safely.

Terminal window
iw index deprecated-callers --limit 50

Enforce @internal and _ prefix visibility across package boundaries in monorepos. Prevent hidden coupling.

Terminal window
iw index internal-violations --changed src/ --no-underscore
  • --no-jsdoc: Skip JSDoc enforcement.
  • --no-underscore: Skip _prefix convention enforcement.

Track down as any casts and double-casts specifically in files with high downstream dependency (high fan-in risk).

Terminal window
iw index type-assertions --kind as_any --risk-sort
  • --kind <kind>: Filter by as_any, double_cast, angle_cast, or as_cast.
  • --risk-sort: Sort by file fan-in (highest risk files appear first!).

Catch test suites that have drifted from reality by detecting when their descriptions refer to code symbols that no longer exist or have been renamed.

Terminal window
iw index test-intent --format json

All enforcement commands are exposed via IntentWeave’s MCP server (packages/cli/src/mcp/server.ts) so Copilot can interact with them while you code:

MCP ToolCLI EquivalentWhat Copilot Can Do
cari_arch_checkiw index arch-checkValidate that new flows you’re adding match the architecture diagram
cari_rules_checkiw index rules-checkGuard open files against ADR violations before you commit
cari_deprecated_callersiw index deprecated-callersAutomatically find and clean up callers of deprecated symbols
cari_internal_violationsiw index internal-violationsPrevent hidden coupling across package boundaries
cari_test_intentiw index test-intentDetect test suites drifted from the functions they describe

To enable this, add IntentWeave to your MCP configuration (see MCP Setup). Once connected, you can ask Copilot questions like:

@workspace Does this change violate any ADRs?
@workspace Are there deprecated callers I should fix in src/auth/?
@workspace Does the new flow in auth.ts match the architecture diagram?