Claude SDK for Go 2
Last reviewed Oct 25, 2026
Prompt Details
Prompt Composition
2prompts
- Go 1.27130 lines · 5.5K tokens
- Claude SDK for Go 256 lines · 2.8K tokens
Total186 lines · 8.3K tokens
CWE Coverage
- 15
- 20
- 22
- 59
- 78
- 79
- 89
- 94
- 117
- 190
- 201
- 208
- 209
- 214
- 250
- 252
- 257
- 287
- 294
- 295
- 307
- 323
- 327
- 338
- 347
- 352
- 362
- 367
- 378
- 426
- 444
- 488
- 494
- 522
- 532
- 639
- 732
- 759
- 770
- 772
- 807
- 829
- 862
- 863
- 915
- 916
- 918
- 942
- 1004
- 1275
- 1395
- 1427
- 1428
Prompt Preview
Apply the Go 1.27 baseline first. These rules cover applications using github.com/anthropics/anthropic-sdk-go/v2, including Messages, local and remote tools, managed agents, administration, and cloud adapters.
Client identity and request scope
- Construct a separate
anthropic.Clientfor each tenant, workspace, provider, and privilege tier. Keep its options under server control and bindWorkspaceID,UserProfileID, resource IDs, and routing headers to the authenticated principal before every operation. - Select one intended credential source.
DefaultClientOptionschecksANTHROPIC_API_KEY,ANTHROPIC_AUTH_TOKEN, an explicit profile, environment federation, then an active or default profile; a profile can also supply routing and workspace settings. Reject an unexpected identity or endpoint before sending user data. - Use
option.WithoutEnvironmentDefaults()when process environment, profile files, orANTHROPIC_CUSTOM_HEADERSare outside the application's trusted configuration. Explicitly removeX-Api-Keywithoption.WithHeaderDelwhen a bearer or environment token replaces an API key; addingAuthorizationdoes not erase the other header. - Keep federation rule, organization, expected service account, identity-token source, and workspace in trusted configuration. A new workspace or origin needs its own credential exchange; keep profile and identity-token files outside model-readable directories.
- Restrict
option.WithBaseURL, request-level base URL overrides, provider endpoints, and rawClient.Get/Post/Executepaths to approved HTTPS origins.