LLM-Assisted Agent Authoring
invowk agent provides coding-agent orientation (invowk agent guide, invowk agent schema, invowk agent audit prompt) alongside headless command and local-module authoring (invowk agent cmd and invowk agent mod).
Agent Orientation and Raw Schemas
Start with invowk agent guide when an external coding agent (such as Claude Code, Codex CLI, or Gemini CLI) needs Invowk's mental model, hard invariants, dynamically discovered top-level CLI tree, and verification workflow without guessing. Pass an optional topic (runtimes, modules, config, security, or cli) or --format json for structured output, inspect verbatim embedded CUE schemas with invowk agent schema [invowkfile|invowkmod|config], and inspect the invowk audit --llm prompt/schema with invowk agent audit prompt.
Prompt for External Agents
Use invowk agent cmd prompt or invowk agent mod prompt when an external tool needs JSON-constrained generator contracts (command_cue, invowkmod_cue/invowkfile_cue), operation-aware rules, and embedded schemas. Single-operation prompts are self-contained; multi-operation catalog output deduplicates schemas into a single shared section (## Schemas in text, top-level schemas in JSON).
# Start here if you are an external coding agent unfamiliar with Invowk
invowk agent guide
invowk agent guide runtimes
invowk agent schema invowkfile
invowk agent audit prompt
# Print operation-aware command prompts for headless generators
invowk agent cmd prompt
invowk agent cmd prompt change --format json
# Print operation-aware module prompts
invowk agent mod prompt
invowk agent mod prompt create --format json
Generate or Change
Use create and change when Invowk should call the configured LLM provider, validate the generated CUE, and patch the bounded target files. Command authoring updates invowkfile.cue; module authoring updates only invowkmod.cue and invowkfile.cue inside the target module.
# With no configured provider, use an OpenAI-compatible local server
invowk agent cmd create docs --llm --llm-url http://localhost:1234/v1 'add a docs build command'
# Configure once, then generate without per-run LLM flags
invowk config set llm.provider codex
invowk agent cmd create lint 'add a lint command that runs golangci-lint'
# Generate and patch invowkfile.cue using the best available provider
invowk agent cmd create test --llm-provider auto 'add a test command'
# Change or remove an existing command
invowk agent cmd change lint --llm-provider claude 'run golangci-lint with --fix support'
invowk agent cmd remove lint --dry-run
# Preview the patch without writing
invowk agent cmd create release --llm-provider codex --dry-run 'add a release command'
# Print only the generated command object
invowk agent cmd create checklist --llm-provider claude --print 'add a release checklist command'
# Create, change, or remove a local module
invowk agent mod create io.example.tools --llm-provider codex 'create portable project tools'
invowk agent mod change io.example.tools --llm-provider codex 'add a formatting command'
invowk agent mod remove io.example.tools --dry-run
LLM-backed authoring commands use the same LLM provider flags as invowk audit: --llm-provider, --llm, --llm-url, --llm-model, --llm-api-key, --llm-timeout, and --llm-concurrency.
Configure llm.provider or llm.api once in config.cue to omit LLM flags on future create/change runs:
invowk config set llm.provider codex
invowk agent cmd create lint 'add a lint command that runs golangci-lint'
See Configuration Options for provider and API examples. Raw API keys should stay in environment variables, referenced with llm.api.api_key_env.
Write Behavior
Command create requires <name> and fails if that command already exists; use agent cmd change <name> to update an existing command. Module create requires <module-id> and fails if <module-id>.invowkmod already exists; use agent mod change <module-id-or-path> to update an existing local module. Use --dry-run to preview patches and --print to print generated output without writing. --verify validates the written module or resolves a written command with a dry-run execution plan. Before it writes, agent mod change takes the same project lock as the module commands (Concurrent Module Commands), so it may print • Waiting for another invowk module command on this project (lock: <path>); when the module's invowkmod.cue or invowkfile.cue changed while the change was generated, it fails with exit status 1 and writes nothing, and you run it again. It writes each file atomically.
:::caution Prompt content is sent to the configured provider LLM-backed create/change operations send the generated authoring system prompt and schemas, plus a user prompt containing your request and target path. Creating or changing a command in an existing invowkfile also sends that file's current content; changing a module sends its current module files. If the model returns invalid output, the repair retry also sends the validation error and the previous model response. Use a local provider when your command definitions or module files contain private project details. :::
Validation
Invowk accepts only one generated command object for command authoring, and the generated name must match the requested <name>. Module authoring accepts only generated invowkmod.cue and invowkfile.cue content, and invowkmod.cue must keep the requested module ID. Invowk uses structured JSON output with compatible OpenAI API backends, retries once with validation feedback when a model returns invalid output, and rejects malformed JSON, invalid CUE, full command cmds arrays in command_cue, and arbitrary extra generated module files.
Remove operations are deterministic: agent cmd remove <name> edits the target invowkfile without resolving an LLM provider, and agent mod remove <module-id-or-path> validates the exact local module and requires --force unless you pass --dry-run.
Exit Codes
invowk agent follows the general exit-code contract. An error detected from the command line alone, before any file is read or any LLM is called, exits 2: an invalid command name or module ID, mutually exclusive flags, --verify paired with --ivk-no-cwd/INVOWK_NO_CWD or a non-default --file, a missing description, an invalid --llm-provider, --llm-url, --llm-model or --llm-concurrency value, or an unknown guide topic, schema target, prompt format, or operation. Every other failure exits 1, including a command or module that already exists or does not exist, agent mod remove without --force, invalid LLM output, and errors that need the config file or an LLM.