CLI reference¶
Everything on this page applies to the apcore-cli command in all three SDKs. Usage
flags generated from a module's schema are documented per module — see
apcore-cli apcli describe <module_id>.
Global options¶
| Option | Default | Description |
|---|---|---|
--extensions-dir |
./extensions |
Path to the apcore extensions directory |
--log-level |
WARNING |
Logging level: DEBUG, INFO, WARNING, ERROR |
--all-options |
off | Show built-in options in --help (they are hidden by default) |
--version |
Print the version and exit | |
--help |
Print help and exit |
Built-in commands (apcli)¶
Built-ins live exclusively under the reserved apcli group: <cli> apcli <sub>.
Root-level shims such as apcore-cli list were removed in v0.8.0. Business modules stay
unprefixed (apcore-cli math add). man is the one deliberate exception and remains at
root.
| Command | Description |
|---|---|
apcli list |
List modules, with tag, annotation, and search filters |
apcli describe <module_id> |
Show full module metadata and schemas |
apcli validate <module_id> |
Run preflight checks without executing |
apcli exec <module_id> |
Route execution by ID (also reachable as a direct subcommand) |
apcli init module <id> |
Scaffold a module (decorator, convention, or binding style) |
apcli health [<module_id>] |
Show module health (requires system.* modules) |
apcli usage [<module_id>] |
Show usage statistics (requires system.* modules) |
apcli enable <module_id> |
Enable a disabled module at runtime |
apcli disable <module_id> |
Disable a module at runtime |
apcli reload <module_id> |
Hot-reload a module from disk |
apcli config get <key> |
Read a runtime configuration value |
apcli config set <key> <value> |
Update a runtime configuration value (requires approval) |
apcli describe-pipeline |
Show execution pipeline steps for a strategy |
apcli completion <shell> |
Generate a completion script (bash, zsh, fish) |
man <command> |
Generate a roff man page (root level) |
The group name and visibility are configurable for embedded hosts; see Built-in Command Group.
Module execution options¶
These options are available on every module command.
| Option | Description |
|---|---|
--input - |
Read JSON input from STDIN. CLI flags override duplicate keys. |
--yes / -y |
Bypass approval prompts |
--large-input |
Allow STDIN input above the default size limit |
--max-input-bytes <n> |
Override the input size limit explicitly |
--format <fmt> |
json, table, csv, yaml, jsonl, markdown, skill (skill for list/describe) |
--fields <paths> |
Comma-separated dot-paths to select from the result |
--dry-run |
Run preflight checks without executing |
--trace |
Print the execution pipeline trace with per-step timing |
--stream |
Stream output as JSONL, one object per line |
--strict-stream |
Fail instead of falling back when streaming is unavailable |
--strategy <name> |
Pipeline: standard, internal, testing, performance, minimal |
--approval-timeout <s> |
Override the approval prompt timeout (default 60) |
--approval-token <t> |
Resume a pending approval with the given token |
--sandbox |
Reserved. Currently hidden and does not isolate execution yet |
--acl <path> |
Override the ACL file location |
--all-options |
Show hidden built-in options in help |
--dry-run, --trace, --strategy, --stream, and --sandbox are mutually
incompatible in the combinations the dispatcher rejects at parse time.
--sandbox is not a security boundary yet
The flag is accepted for forward compatibility but the implementation is not complete. Do not rely on it to contain untrusted modules; isolate the whole process in your runner instead.
Exit codes¶
| Code | Meaning |
|---|---|
0 |
Success |
1 |
Module execution error or timeout |
2 |
Invalid CLI input |
44 |
Module not found, disabled, failed to load, or dependency problem |
45 |
Schema validation error |
46 |
Approval denied or timed out |
47 |
Configuration error |
48 |
Circular $ref in a schema |
65 |
Config bind error |
66 |
Config mount error |
70 |
Duplicate error formatter registered |
75 |
Policy evaluation failed (retryable) |
77 |
ACL or policy denied |
78 |
Reserved or duplicate config namespace |
130 |
Cancelled (Ctrl+C) |
Codes are stable across Python, TypeScript, and Rust; scripts can branch on them.
Configuration¶
Four tiers, highest wins:
- CLI flag —
--extensions-dir ./custom - Environment variable —
APCORE_EXTENSIONS_ROOT=./custom - Config file —
apcore.yaml - Default —
./extensions
Environment variables¶
| Variable | Description | Default |
|---|---|---|
APCORE_EXTENSIONS_ROOT |
Extensions directory | ./extensions |
APCORE_CLI_AUTO_APPROVE |
1 bypasses all approval prompts |
(unset) |
APCORE_CLI_LOGGING_LEVEL |
CLI log level; wins over APCORE_LOGGING_LEVEL |
WARNING |
APCORE_LOGGING_LEVEL |
Global apcore log level | WARNING |
APCORE_AUTH_API_KEY |
API key for remote registry authentication | (unset) |
APCORE_CLI_HELP_TEXT_MAX_LENGTH |
Help text truncation length | 1000 |
APCORE_CLI_APPROVAL_TIMEOUT |
Approval prompt timeout in seconds | 60 |
APCORE_CLI_STDIN_BUFFER_LIMIT |
Maximum buffered STDIN bytes | (implementation default) |
APCORE_CLI_STRATEGY |
Default pipeline strategy | standard |
APCORE_CLI_GROUP_DEPTH |
Nested subcommand grouping depth | 1 |
APCORE_CLI_EXPOSE_MODE |
Exposure mode: all, include, exclude |
all |
APCORE_CLI_APCLI |
Visibility of the apcli group (all, none, include, exclude) |
standalone: all, embedded: none |
APCORE_ACL_ROOT |
ACL file directory (apcore-owned key) | ./acl |
APCORE_ACL_AUDIT_ENABLED |
Write ACL audit entries | true |
APCORE_ACL_AUDIT_INCLUDE_DENIED |
Include deny decisions in the audit log | true |
apcore.yaml¶
extensions:
root: ./extensions
sandbox:
enabled: false # reserved; execution is not isolated yet
cli:
help_text_max_length: 1000
approval_timeout: 60
strategy: standard
group_depth: 1
expose:
mode: all # "all" | "include" | "exclude"
include: [] # glob patterns, used when mode is "include"
exclude: [] # glob patterns, used when mode is "exclude"
apcore-cli:
apcli:
mode: all # visibility of the built-in group
Configuration is namespaced so each component owns its keys: apcore-cli for the CLI,
apcore-a2a.openapi and mcp.openapi for the OpenAPI backends, and the core acl
namespace for governance.
Worked examples¶
Preflight without executing¶
apcore-cli math add --a 5 --b hello --dry-run
# ✓ module_id OK
# ✓ module_lookup OK
# ✓ call_chain OK
# ✓ acl OK
# ✗ schema {"field": "b", "expected": "integer"}
#
# Result: FAIL (1 error(s), 0 warning(s))
See which pipeline steps ran¶
apcore-cli math add --a 5 --b 10 --trace
# {"sum": 15}
#
# Pipeline Trace (strategy: standard, 11 steps, 23.4ms)
# ✓ context_creation 0.1ms
# ✓ call_chain_guard 0.0ms
# ✓ module_lookup 1.2ms
# …
Inspect and control the runtime¶
apcore-cli apcli health # module health (needs system.* modules)
apcore-cli apcli usage --period 7d # usage statistics
apcore-cli apcli disable db.dangerous --reason "release freeze" --yes
apcore-cli apcli describe-pipeline --strategy minimal
Stream a large result¶
apcore-cli data.export --query "SELECT *" --stream
# one JSON object per line, flushed as it is produced
# {"row": 1, "data": {…}}
# {"row": 2, "data": {…}}
How modules become commands¶
| apcore | CLI |
|---|---|
metadata["display"]["cli"]["alias"] or module_id |
Command name; nested by the leading ID segments (math.add → apcore-cli math add) |
metadata["display"]["cli"]["summary"] |
One-line entry in command listings |
metadata["display"]["cli"]["description"] or description |
--help text |
input_schema.properties |
Flags (--a, --b) with types, defaults, and required markers |
input_schema.required |
Required-flag enforcement |
annotations.requires_approval |
Interactive approval gate |
Architecture¶
Terminal / script / AI coding agent
|
v
apcore-cli
|
+-- ConfigResolver 4-tier precedence, namespaced keys
+-- GroupedModuleGroup nested commands from module IDs
+-- SchemaParser JSON Schema -> Click / Commander / clap options
+-- RefResolver $ref, allOf, anyOf, oneOf
+-- ApprovalGate TTY-aware approval, fails closed off-TTY
+-- OutputFormatter json / table / csv / yaml / jsonl / markdown
+-- AuditLogger JSON Lines execution log
|
v
apcore Registry + Executor (unchanged)
Source layout¶
python/src/apcore_surfaces/cli/
├── cli.py dispatcher, GroupedModuleGroup
├── approval.py HITL approval + CliApprovalHandler
├── output.py TTY-adaptive formatting
├── discovery.py list / describe / validate
├── system_cmd.py health / usage / enable / disable / reload / config
├── config.py 4-tier ConfigResolver
├── schema_parser.py JSON Schema -> Click options
├── shell.py completions and man pages
└── security/ audit, auth, encryption, sandbox
typescript/src/cli/
├── main.ts entry point, createCli()
├── cli.ts LazyModuleGroup, GroupedModuleGroup
├── approval.ts HITL approval + CliApprovalHandler
├── output.ts TTY-adaptive formatting
├── discovery.ts list / describe / validate
├── system-cmd.ts health / usage / enable / disable / reload / config
├── config.ts 4-tier ConfigResolver
├── schema-parser.ts JSON Schema -> Commander options
├── shell.ts completions and man pages
└── security/ audit, auth, encryption, sandbox
rust/src/cli/
├── main.rs entry point, dispatch routing
├── cli.rs dispatcher, module execution
├── lib.rs public API, exit codes
├── approval.rs HITL approval + CliApprovalHandler
├── output.rs TTY-adaptive formatting
├── discovery.rs list / describe
├── validate.rs validate
├── system_cmd.rs health / usage / enable / disable / reload / config
├── config.rs 4-tier ConfigResolver
├── schema_parser.rs JSON Schema -> clap args
├── shell.rs completions and man pages
└── security/ audit, auth, encryption, sandbox
See also¶
- CLI quickstart — run and inspect real modules.
- Config Resolver — full precedence and key reference.
- Output Formatter — format guarantees per SDK.
- Approval Gate — prompt, bypass, and timeout rules.