JSON stdout contract
Every successful command prints exactly one line of JSON to stdout and exits0, except the explicit docs --agent and get --format text modes.
code field is a stable machine-readable string (see Exit codes below). Scripts should check both the exit code and stderr — never rely on parsing the error message text, which may change between versions.
Composing with jq
Because stdout is always valid JSON, you can pipe directly intojq with no intermediate parsing step.
Extract IDs from a search:
Shell script example
The following script gathers rich context for a given note: it fetches the note’s metadata, resolves one level of outgoing links, and prints a compact context block suitable for inclusion in an LLM prompt.Install the agent skill
smolbren ships a ready-made Agent Skill that teaches coding agents the full CLI workflow: the JSON output contract, exit codes, the explore-the-ontology-before-Cypher pattern, note-id semantics, and common gotchas. Install it with the skills CLI:docs --agent output are byte-for-byte identical in CI,
so agent documentation cannot silently drift from the release that emitted it.
AI agent integration
smolbren works as a tool definition in agent frameworks (LangChain, OpenAI function calling, Anthropic tool use, custom scaffolding, etc.). Register the CLI commands you need as individual tools. Recommended tool surface:
Below is a conceptual tool definition in generic JSON schema format, suitable for adaptation to any framework:
search_vault to find candidate IDs, then query_graph to traverse their relationships, then get_note with --body to load the full text of the most relevant result.
Exit codes for error handling
Scripts should check the exit code before attempting to parse stdout. smolbren uses a fixed set of non-overlapping codes:
Example defensive pattern: