agent-contracts

CLI

The CLI expects your modules or files to register nodes (typically via get_node_registry()).

If a module defines register_all_nodes(registry=None) but does not register nodes at import time, the CLI calls it automatically after importing the module.

Set AGENT_CONTRACTS_DEBUG=1 to print debug logs to stderr (module loading, graph loading/compilation, Mermaid rendering).

Validate

agent-contracts validate --module myapp.nodes --strict
agent-contracts validate --file ./nodes.py --known-service db_service

Exit code: 0 on success, 1 when errors exist.

Visualize

agent-contracts visualize --module myapp.nodes --output ARCHITECTURE.md
agent-contracts visualize --file ./nodes.py --output -
agent-contracts visualize --module myapp.nodes --graph-module myapp.graph --graph-func get_graph --output -

Diff

agent-contracts diff --from-module myapp.v1.nodes --to-module myapp.v2.nodes
agent-contracts diff --from-file ./old_nodes.py --to-file ./new_nodes.py

Exit code: 2 when breaking changes are detected, otherwise 0.