This file provides guidance to AI Agents when working with code in this repository.
# Build all binaries
make build # or ./scripts/build.sh
# Run linters
make lint # or ./scripts/lint.sh
make fmt # auto-fix lint issues (runs golangci-lint --fix)
# Run tests
make test # or ./scripts/run-tests.sh
./scripts/run-tests.sh -run <regex> # run specific tests
./scripts/run-tests.sh -g # update golden files
./scripts/run-tests.sh -c # record new cassettes (requires valid API credentials)
./scripts/run-tests.sh -D # enable debug mode
# Update SDK dependency
make bump-sdk # updates scaleway-sdk-go to latest masterThis is a Go CLI (scw) for managing Scaleway cloud infrastructure. The codebase follows a modular architecture centered around a core command execution engine.
cmd/scw/ # Main entry point
commands/ # Command registration (GetCommands() merges all namespaces)
core/ # Core CLI engine: bootstrap, command execution, printing, validation
internal/namespaces/ # Auto-generated + manual API command implementations (60+ namespaces)
internal/ # Shared utilities: editor, interactive, config, cache, etc.
docs/ # Documentation (auto-generated command docs + developer guides)
The core package provides the CLI framework:
bootstrap.go- Initializes config, client, and command execution pipelinecommand.go- Command definition and execution logicprinter.go- Output formatting (JSON, human-readable, templated)validate.go- Argument validationtesting.go- Test framework with golden files and cassette recording (VCR pattern)
Commands are organized by namespace (e.g., instance, k8s, lb) and registered in commands/commands.go:
func GetCommands() *core.Commands {
commands := core.NewCommandsMerge(
instance.GetCommands(),
k8s.GetCommands(),
// ...
)
}Each namespace in internal/namespaces/<name>/ provides its own GetCommands() function.
Most API namespaces in internal/namespaces/ are auto-generated from Scaleway's code generation pipelines. These files start with:
// This file was automatically generated. DO NOT EDIT.See docs/CONTINUOUS_CODE_DEPLOYMENT.md for details.
Manual namespaces (e.g., config, init, autocomplete, feedback) live alongside generated ones.
Configuration is managed by scaleway-sdk-go/scw package:
- Config file:
$XDG_CONFIG_HOME/scw/config.yamlor~/.config/scw/config.yaml - Environment variables override config file (e.g.,
SCW_ACCESS_KEY,SCW_SECRET_KEY,SCW_DEFAULT_ORGANIZATION_ID) - See
core/default.goandinternal/namespaces/config/for implementation
Tests use a VCR-style recording system:
- Cassettes: Record API interactions (YAML files in
testdata/) - Golden files: Expected CLI output (
.goldenfiles) - Tests run against recorded cassettes to avoid hitting live APIs
# Record new cassette (creates real resources - billed)
./scripts/run-tests.sh -c
# Update golden output files
./scripts/run-tests.sh -g
# Target specific test
go test ./internal/namespaces/instance/v1 -run Test_CreateServerSee docs/developer.md for complete testing guide.
- Naming: Use dashes
-for commands/args, underscores_for response fields (except UUIDs) - PR titles: Follow conventional commits (e.g.,
fix(instance): fix server create,feat(core): add new feature) - Beta features: Guarded by
SCW_ENABLE_BETA=trueenvironment variable
- Go 1.26.0+
- Main external dependency:
scaleway-sdk-go(Scaleway API SDK) - Linting:
golangci-lint(config in.golangci.yml)