Claude SDK for Go 2

Last reviewed Oct 25, 2026

Export as PDF

Prompt Details

Prompt Composition

2prompts
  1. Go 1.27130 lines · 5.5K tokens
  2. 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.Client for each tenant, workspace, provider, and privilege tier. Keep its options under server control and bind WorkspaceID, UserProfileID, resource IDs, and routing headers to the authenticated principal before every operation.
  • Select one intended credential source. DefaultClientOptions checks ANTHROPIC_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, or ANTHROPIC_CUSTOM_HEADERS are outside the application's trusted configuration. Explicitly remove X-Api-Key with option.WithHeaderDel when a bearer or environment token replaces an API key; adding Authorization does 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 raw Client.Get/Post/Execute paths to approved HTTPS origins.