Getting Started¶
This guide walks you through installing apcore-cli, running your first module, and building your own — all in under 5 minutes.
Prerequisites¶
- Python 3.11+
- An apcore project with an extensions directory, or the example modules from the Python SDK
Install¶
Verify the installation:
Quick start with example modules¶
The Python SDK ships with 8 example modules you can use immediately:
git clone https://github.com/aipartnerup/apcore-cli-python.git
cd apcore-cli-python
pip install -e ".[dev]"
export APCORE_EXTENSIONS_ROOT=examples/extensions
Run a module:
Discover modules¶
List all modules¶
In an interactive terminal you get a formatted table; when piped, output switches to JSON automatically.
Filter by tag¶
Inspect a module¶
This shows the module's description, input/output schemas, tags, and annotations (including requires_approval).
Execute modules¶
Basic execution¶
Flags are generated automatically from the module's input_schema:
STDIN piping¶
Use --input - to read JSON from STDIN. CLI flags override duplicate keys:
echo '{"a": 100, "b": 200}' | apcore-cli math.add --input -
# {"sum": 300}
# --a overrides the STDIN value
echo '{"a": 1, "b": 2}' | apcore-cli math.add --input - --a 999
# {"sum": 1001}
Chain with other tools¶
Approval gate¶
Modules annotated with requires_approval: true will prompt for confirmation before execution. To bypass in scripts:
Output format¶
Force a specific format regardless of TTY detection:
Write your first module¶
Create a Python file in your extensions directory:
# extensions/greet/hello.py
from pydantic import BaseModel
class Input(BaseModel):
name: str
greeting: str = "Hello"
class Output(BaseModel):
message: str
class GreetHello:
input_schema = Input
output_schema = Output
description = "Greet someone by name"
def execute(self, inputs, context=None):
return {"message": f"{inputs['greeting']}, {inputs['name']}!"}
Run it:
The module ID (greet.hello) is derived from the directory structure — no registration needed.
Schema-driven flags
--name is required (no default in Input), --greeting is optional with default "Hello". Boolean fields become --flag / --no-flag pairs. Enum fields become choice options with validation.
Configuration¶
apcore-cli resolves configuration in 4 tiers (highest wins):
| Priority | Source | Example |
|---|---|---|
| 1 (highest) | CLI flag | --extensions-dir ./custom |
| 2 | Environment variable | APCORE_EXTENSIONS_ROOT=./custom |
| 3 | Config file | apcore.yaml |
| 4 (lowest) | Default | ./extensions |
Minimal config file¶
Key environment variables¶
| Variable | Description | Default |
|---|---|---|
APCORE_EXTENSIONS_ROOT |
Path to extensions directory | ./extensions |
APCORE_CLI_AUTO_APPROVE |
Set 1 to bypass approval prompts |
(unset) |
APCORE_LOGGING_LEVEL |
Log level (DEBUG, INFO, WARN, ERROR) |
INFO |
For the full configuration reference, see the Config Resolver spec.
Shell completions¶
Generate and install completion scripts for your shell:
Common exit codes¶
| Code | Meaning |
|---|---|
0 |
Success |
1 |
Module execution error |
2 |
Invalid CLI input |
44 |
Module not found / disabled / load error |
45 |
Schema validation error |
46 |
Approval denied or timed out |
47 |
Configuration error |
For the full exit code reference, see the Tech Design Section 8.1.
Next steps¶
- Configuration -- Full configuration reference
- Tech Design -- Architecture and design decisions
- Feature Specs -- Detailed specs for each component