Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 5 additions & 34 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
15 changes: 13 additions & 2 deletions docs/docs/sidebar/sdk/guidelines.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading