skills/a6-shared/SKILL.md
Core skill for working with the a6 CLI — the Apache APISIX command-line tool. Provides project conventions, command patterns, architecture overview, and development workflow. Load this skill when working on a6 source code, adding new commands, writing tests, or modifying any a6 component.
npx skillsauth add moonming/a6 a6-sharedInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
a6 is a Go CLI wrapping the Apache APISIX Admin API. It provides imperative CRUD for all 14 APISIX resources, declarative config sync, context management for multiple APISIX instances, and debug tooling.
a6github.com/api7/a6a6 <resource> <action> [flags])a6/
├── cmd/a6/main.go # Entry point
├── pkg/cmd/ # Command implementations
│ ├── root/root.go # Root command, registers all subcommands
│ ├── factory.go # DI: IOStreams, HttpClient, Config
│ ├── route/ # a6 route list|get|create|update|delete
│ ├── upstream/ # a6 upstream list|get|create|update|delete|health
│ ├── service/ # a6 service ...
│ ├── consumer/ # a6 consumer ...
│ ├── ssl/ # a6 ssl ...
│ ├── plugin/ # a6 plugin list|get
│ ├── config/ # a6 config sync|diff|dump|validate
│ └── context/ # a6 context create|use|list|delete|current
├── pkg/api/ # Admin API HTTP client + types
│ ├── client.go # Thin net/http wrapper with auth
│ └── types_*.go # Go structs per resource (Route, Upstream, etc.)
├── pkg/iostreams/ # I/O abstraction (TTY detection)
├── pkg/cmdutil/ # Shared utilities (errors, exporter, flags)
├── pkg/tableprinter/ # Table rendering
├── pkg/httpmock/ # HTTP mock for unit tests
├── internal/config/ # Context/config file management
├── test/fixtures/ # JSON fixtures for unit tests
├── test/e2e/ # E2E tests (build tag: e2e)
├── skills/ # AI agent skill files
└── docs/ # Project documentation
Every command receives a *cmd.Factory containing IOStreams, HttpClient(),
and Config(). No global state. This enables full test isolation.
type Factory struct {
IOStreams *iostreams.IOStreams
HttpClient func() (*http.Client, error)
Config func() (config.Config, error)
}
Every command follows the same structure:
type Options struct {
IO *iostreams.IOStreams
Client func() (*http.Client, error)
Config func() (config.Config, error)
// command-specific fields
}
func NewCmdXxx(f *cmd.Factory) *cobra.Command { ... }
func xxxRun(opts *Options) error { ... }
--output json|yaml|table overrides detectionhttpmock stubs + test IOStreams. Zero real network calls.//go:build e2e, real APISIX in Docker, binary invocation.test/fixtures/*.json for realistic mock responses.docs/admin-api-spec.mdpkg/api/types_<resource>.go with both json: and yaml: tagspkg/cmd/<resource>/<resource>.gopkg/cmd/<resource>/<action>/<action>.go (follow docs/golden-example.md)*_test.go in same package (TTY, non-TTY, filter, error cases)test/fixtures/<resource>_<action>.jsonpkg/cmd/root/root.godocs/user-guide/<resource>.mdmake build # Build to ./bin/a6
make test # Unit tests (excludes e2e)
make test-e2e # E2E tests (requires running APISIX)
make lint # golangci-lint
make fmt # gofmt
make check # fmt + vet + lint + test
make docker-up # Start local APISIX stack
make docker-down # Stop local APISIX stack
gofmt + goimports formattingany or interface{} — use concrete types or genericsjson: and yaml: tags| Resource | Key Field | API Path |
|----------|-----------|----------|
| Route | id | /apisix/admin/routes |
| Service | id | /apisix/admin/services |
| Upstream | id | /apisix/admin/upstreams |
| Consumer | username | /apisix/admin/consumers |
| SSL | id | /apisix/admin/ssl |
| Global Rule | id | /apisix/admin/global_rules |
| Plugin Config | id | /apisix/admin/plugin_configs |
| Consumer Group | id | /apisix/admin/consumer_groups |
| Stream Route | id | /apisix/admin/stream_routes |
| Proto | id | /apisix/admin/protos |
| Secret | id | /apisix/admin/secrets/{manager}/{id} |
| Plugin Metadata | plugin_name | /apisix/admin/plugin_metadata/{name} |
| Plugin (read-only) | name | /apisix/admin/plugins |
| Credential | id | /apisix/admin/consumers/{username}/credentials |
The declarative config system (a6 config sync/diff/dump/validate) manages
resources via YAML files:
version: "1"
routes:
- id: my-route
uri: /api/*
upstream_id: my-upstream
upstreams:
- id: my-upstream
type: roundrobin
nodes:
"httpbin:8080": 1
Sync processes resources in dependency order: upstreams/services first, routes/stream_routes last. Deletes happen in reverse order. Transient "still referenced" errors during delete are retried with exponential backoff.
tools
Recipe skill for implementing multi-tenant API gateway patterns using the a6 CLI. Covers tenant isolation via Consumer Groups, host/path/header-based routing, per-tenant rate limiting, context forwarding with proxy-rewrite, and declarative config sync workflows for multi-tenant management.
tools
Recipe skill for configuring mutual TLS (mTLS) using the a6 CLI. Covers SSL certificate management, upstream mTLS to backend services, client certificate verification, and end-to-end mTLS setup from client through APISIX to upstream.
tools
Recipe skill for configuring upstream health checks using the a6 CLI. Covers active health checks (HTTP probing), passive health checks (response analysis), combining both, configuring healthy/unhealthy thresholds, and monitoring upstream node status.
tools
Recipe skill for implementing GraphQL proxying patterns using the a6 CLI. Covers operation-based routing with built-in GraphQL variables, per-operation rate limiting, REST-to-GraphQL conversion with the degraphql plugin, and security patterns for GraphQL APIs.