This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Cone is a CLI tool for the ConductorOne platform, written in Go. It manages access to entitlements (request, approve, deny, revoke access) via the ConductorOne API.
make build # Build binary → dist/<OS>_<ARCH>/cone
make lint # Run golangci-lint (strict config in .golangci.yml, ~30 linters)
go test ./... # Run all tests
go test -v -run TestName ./pkg/client/ # Run a single test
make update-deps # Update all Go dependencies and re-vendorUses vendored dependencies (vendor/). After modifying go.mod, run go mod tidy -v && go mod vendor.
main.go— Cobra root command setup, signal handling, registers all subcommandscmd.go—cmdContext()creates authenticatedC1Client+ viper config for each command. Auth priority: access token env var → OIDC token exchange → client credentials- Each command file (e.g.,
task.go,search_entitlements.go) returns a*cobra.Commandand callscmdContext()to get the client
client/— Wrapsconductorone-sdk-go. TheC1Clientinterface defines all API operations. Auth uses JWT bearer assertion (Ed25519 signed) viatoken_source.go, with RFC 8693 token exchange intoken_exchange.go. Client ID format:name@host/suffix(host is parsed to determine API endpoint).output/— Pluggable output formatting.Managerinterface with table/JSON implementations. Data types implementTablePrint(Header() []string,Rows() [][]string) for table output, and optionallyWideTablePrint(WideHeader(),WideRows()) for wide mode. JSON output serializes the struct directly.uhttp/— HTTP client factory with OAuth2 token source, debug logging, custom transport.logging/— Singleton zap logger initialized once at startup.
- Create file in
cmd/cone/ - Return a
*cobra.Commandthat callscmdContext(cmd)to get(ctx, client, viper, error) - Use
output.NewManager(ctx, v)to format output - Register in
main.goviacliCmd.AddCommand()
- Add the method signature to the
C1Clientinterface inpkg/client/client.go - Implement on
*clientin the appropriate file underpkg/client/ - Use
c.sdk.<Service>.<Method>(ctx, operationsRequest)to call the SDK - Check
NewHTTPError(resp.RawResponse)for HTTP-level errors
Key non-obvious rules from .golangci.yml:
- Line length limit: 200 characters
- No naked returns (any function length)
- No named returns
- Comments must end in a period (except TODOs)
- Variable naming: use
ID,URL,HTTP,API(notId,Url, etc.) - No
init()functions - All errors must be checked (exceptions:
fmt.Printf/Println,fmt.Fprintf/Fprintln) goimportsfor import formatting