CLI Reference#
Complete reference for all APX commands and options.
Command Categories#
APX commands are organized into logical categories:
apx init- Initialize projectsapx fetch- Download toolchainapx gen- Generate code with canonical importsapx sync- Update go.work overlaysapx unlink- Remove overlays for published APIs
apx search- Discover APIsapx add- Add dependenciesapx update- Update versions
apx publish- Publish to canonicalapx tag- Create tagsapx version- Version management
apx lint- Schema validationapx breaking- Breaking changesapx policy- Policy enforcement
apx list- List APIs/versionsapx show- Show API detailsapx config- Configuration
--verbose- Detailed output--config- Custom config file
Quick Reference#
Most Common Commands#
# Initialize new project (interactive)
apx init
# Add dependency
apx add proto/payments/ledger/v1@v1.2.3
# Validate schemas
apx lint && apx breaking
# Generate code with canonical import paths
apx gen go # generates stubs with canonical imports
apx sync # updates go.work overlays
# Switch from overlay to published module
apx unlink proto/payments/ledger/v1
go get github.com/myorg/apis-go/proto/payments/ledger@v1.2.3
# Publish from app repo
apx publish --module-path=internal/apis/proto/domain/api/v1 \
--canonical-repo=github.com/org/apis
Application code using canonical imports:
// service.go - your application
package service
import (
// Pattern: github.com/<org>/apis-go/proto/<domain>/<api>/v1
ledgerv1 "github.com/myorg/apis-go/proto/payments/ledger/v1"
usersv1 "github.com/myorg/apis-go/proto/users/profile/v1"
productsv2 "github.com/myorg/apis-go/proto/inventory/products/v2"
)
type Service struct {
ledgerClient ledgerv1.LedgerServiceClient
usersClient usersv1.ProfileServiceClient
productsClient productsv2.ProductServiceClient
}
Path Mapping Reference#
APX API Path → Go Import Path
APX API Path |
Go Module Path |
Go Import Path |
|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
Local Overlay Paths
APX API Path |
Local Generated Path |
Overlay in go.work |
|---|---|---|
|
|
|
|
|
|
Discovery & Search#
# Search for APIs
apx search payments ledger
# List all APIs
apx list apis
# Show API details
apx show proto/payments/ledger/v1
# List available versions
apx list versions proto/payments/ledger
Version Management#
# Get version suggestion
apx version suggest
# Set version manually
apx version set v1.2.3
# Verify version matches changes
apx version verify
Exit Codes#
APX uses consistent exit codes:
0: Success
1: General error (validation failed, command error)
2: Configuration error (invalid config, missing files)
3: Network error (cannot fetch dependencies, API unreachable)
4: Permission error (cannot write files, access denied)
5: Breaking change detected (when used with
--fail-on-breaking)
Environment Variables#
APX_CONFIG#
Override default configuration file location:
export APX_CONFIG=/path/to/custom/apx.yaml
apx lint # uses custom config
APX_CACHE_DIR#
Set custom cache directory for downloaded tools:
export APX_CACHE_DIR=/tmp/apx-cache
apx fetch # downloads to custom location
APX_USE_CONTAINER#
Force container execution:
export APX_USE_CONTAINER=true
apx gen go # runs generators in container
APX_VERBOSE#
Enable verbose output by default:
export APX_VERBOSE=true
apx lint # shows detailed output
Configuration File#
APX uses apx.yaml for configuration:
# Project configuration
project:
org: myorg
name: myproject
# API definitions
apis:
- kind: proto
path: internal/apis/proto/domain/service/v1
canonical: proto/domain/service/v1
# Code generation settings
codegen:
out: internal/gen
languages: [go, python, java]
options:
go:
canonical_imports: true # generates with canonical import paths
workspace_overlay: true # manages go.work overlays
python:
package_name: myproject_apis
# Validation settings
validation:
breaking:
ignore_patterns:
- "*.internal.*" # ignore internal packages
policy:
banned_annotations:
- "gorm.*"
- "database.*"
# Publishing settings
publishing:
canonical_repo: github.com/myorg/apis
strategy: subtree
# Tool versions (usually in apx.lock)
toolchain:
buf: v1.28.1
protoc: v24.4
protoc-gen-go: v1.31.0
Shell Completion#
Enable shell completion for better CLI experience:
Bash#
# Add to ~/.bashrc
source <(apx completion bash)
# Or install system-wide
apx completion bash | sudo tee /etc/bash_completion.d/apx
Zsh#
# Add to ~/.zshrc
source <(apx completion zsh)
# Or for oh-my-zsh
apx completion zsh > "${fpath[1]}/_apx"
Fish#
apx completion fish | source
# Or install permanently
apx completion fish > ~/.config/fish/completions/apx.fish
Next Steps#
Learn core commands for project setup
Master dependency commands for API management
Understand publishing commands for releases
Use validation commands for quality assurance
Explore utility commands for daily workflows