diff --git a/CLAUDE.md b/CLAUDE.md index fee48ba3c..d463eda75 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -710,41 +710,12 @@ with context. under the matching category header. The dropdown is grouped the same way as the sidebar. -#### SDK method naming (MANDATORY) +#### SDK method naming -Method names MUST be clean verbs — NEVER repeat the service name. The service -struct already provides the namespace. Stuttering like -`SysctlService.SysctlGet()` is wrong — use `SysctlService.Get()`. - -Standard verbs: - -| Verb | HTTP | Description | -| -------- | ---- | -------------------------------- | -| `List` | GET | List collection | -| `Get` | GET | Get single resource / read state | -| `Create` | POST | Create new resource | -| `Update` | PUT | Update existing resource | -| `Delete` | DEL | Remove resource | - -Rare exceptions for action operations (no persistent resource): - -- `Ping.Do()` — one-shot action -- `Command.Exec()`, `Command.Shell()` — execute commands - -Examples: - -```go -// GOOD — clean verbs, no stuttering -client.Sysctl.Get(ctx, host, key) -client.Cron.Create(ctx, host, opts) -client.Hostname.Update(ctx, host, name) -client.NTP.Delete(ctx, host) -client.Timezone.Get(ctx, host) - -// BAD — stuttering, repeats service name -client.Sysctl.SysctlGet(ctx, host, key) -client.NTP.NtpCreate(ctx, host, opts) -``` +Method naming, type exposure, result-field tags, and error handling are +specified in the `sdk-standards` capability in +[osapi-io/specs](https://github.com/osapi-io/specs). When a convention here and +the specification disagree, the specification wins. #### SDK example conventions diff --git a/docs/docs/sidebar/sdk/guidelines.md b/docs/docs/sidebar/sdk/guidelines.md index 143487ecf..31ffb0b36 100644 --- a/docs/docs/sidebar/sdk/guidelines.md +++ b/docs/docs/sidebar/sdk/guidelines.md @@ -4,8 +4,19 @@ sidebar_position: 1 # SDK Development Guidelines -Rules for developing the OSAPI Go SDK (`pkg/sdk/`). These apply to the client -library and any new SDK packages. +How to develop the OSAPI Go SDK (`pkg/sdk/`), with worked examples. Applies to +the client library and any new SDK packages. + +:::note + +The rules this page illustrates — method naming, keeping generated types out of +public signatures, JSON tags on result fields, and error handling — are +specified in the `sdk-standards` capability in +[osapi-io/specs](https://github.com/osapi-io/specs). They bind +`osapi-orchestrator` as well, which is built on this SDK. Where this page and +the specification disagree, the specification wins. + +::: ## Package Structure