Skip to main content
skill CX Codex

encore-go-secret — Claude Code skill: Encore Go secrets

A skill that shows the agent how to declare API keys and passwords in Encore Go with a package-level secrets struct.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add encoredev/skills --skill encore-go-secret -a claude-code
npx skills add encoredev/skills --skill go-secret -a claude-code
Open on GitHub

What encore-go-secret does

The skill covers loading private credentials into an Encore Go service without committing them. The agent declares them as fields of a package-level secrets struct, and Encore reads the field names and resolves each one at runtime. Secret keys are globally unique across the application, so SendGridAPIKey resolves to the same value no matter which package declares it.

Values are set with encore secret set and an environment type: prod, dev, local or pr. For local work you can skip that command and put a .secrets.local.cue file at the repo root instead, gitignored. The skill ships examples for an HTTP request that carries a token in a header and for verifying a Stripe webhook signature.

A struct field has to match the secret name you set with encore secret set exactly. Mismatch the two and the value never arrives — that is the first thing to check when something fails. For webhook signing secrets the skill points to encore-go-webhook.

What it helps with

  • load a third-party API key into a Go service without committing it
  • give a secret different values for prod, dev and local
  • attach a token to an HTTP request header
  • verify a Stripe webhook signature from a secret
  • set local secret values through .secrets.local.cue

Example prompts for the agent

  • Declare a SendGridAPIKey secret in the email package with a secrets struct and show how to read it
  • How do I set different SendGridAPIKey values for prod and local with encore secret set?
  • Set up local secret overrides in .secrets.local.cue and remind me to gitignore the file

How to install encore-go-secret

1Skills CLI (Vercel)

npx skills add encoredev/skills --skill encore-go-secret -a claude-code
npx skills add encoredev/skills --skill go-secret -a claude-code

2Manually: put the files in place

~/.claude/skills/go-secret/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/go-secret/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about encore-go-secret

How do I install encore-go-secret in Claude?

Run npx skills add encoredev/skills --skill encore-go-secret -a claude-code. You can also run npx skills add encoredev/skills --skill go-secret -a claude-code; the skill file lands at ~/.claude/skills/go-secret/SKILL.md.

What does encore-go-secret do?

It tells the agent how to declare secrets in Encore Go as a package-level secrets struct, set values per environment, and use local overrides.

How is a local override different from encore secret set?

encore secret set stores a value in Encore for a given environment type. A .secrets.local.cue file at the repo root supplies values for local development only, and it should be gitignored.

Source text

SKILL.md · Apache-2.0
---
name: encore-go-secret
description: Manage API keys, credentials, and other secrets in Encore Go using a package-level `secrets` struct.
when_to_use: >-
  User wants to load a private credential into a Go service without committing it to the repo — third-party API keys (Stripe, OpenAI, Twilio, SendGrid), database passwords, signing keys, OAuth client secrets, JWT signing keys, webhook signing secrets. Covers the `var secrets struct{...}` declaration, accessing secrets as struct fields, setting values via `encore secret set`, and `.secrets.local.cue` overrides. Trigger phrases: "API key", "third-party token", "credentials", "without committing", "private key", "signing secret", "secret manager", "encore secret set".
---

# Encore Go Secrets

## Instructions

Secrets are encrypted, environment-scoped values managed by Encore. Declare them as a package-level `secrets` struct — Encore reads the field names and resolves each to the right value at runtime.

```go
package email

var secrets struct {
    SendGridAPIKey string
    SMTPPassword   string
}

func sendEmail() error {
    apiKey := secrets.SendGridAPIKey
    // Use the secret...
    return nil
}
```

Secret keys are globally unique across the application — `SendGridAPIKey` resolves to the same value regardless of which package declares it.

## Setting values

```bash
# Set per environment type
encore secret set --type prod SendGridAPIKey
encore secret set --type dev  SendGridAPIKey
encore secret set --type local SendGridAPIKey
```

Environment types: `production` (alias `prod`), `development` (alias `dev`), `preview` (alias `pr`), `local`.

## Local overrides

For local development without going through `encore secret set`, create a `.secrets.local.cue` file at the repo root (gitignore it):

```cue
SendGridAPIKey: "SG.local-test-key"
GitHubAPIToken: "ghp_local_..."
```

## Common usage patterns

```go
package github

import (
    "context"
    "net/http"
)

var secrets struct {
    GitHubAPIToken string
}

func callGitHub(ctx context.Context) error {
    req, _ := http.NewRequestWithContext(ctx, "GET", "https://api.github.com/user", nil)
    req.Header.Set("Authorization", "token "+secrets.GitHubAPIToken)
    resp, err := http.DefaultClient.Do(req)
    if err != nil {
        return err
    }
    defer resp.Body.Close()
    return nil
}
```

```go
package webhooks

var secrets struct {
    StripeWebhookSecret string
}
// Verify Stripe signature using secrets.StripeWebhookSecret in a raw endpoint.
```

## Guidelines

- Declare secrets as a package-level `secrets` struct, not as individual `secret(...)` calls.
- Field names must exactly match the secret name set via `encore secret set`.
- Set distinct values per environment via `encore secret set --type <env>`.
- Never commit secret values; use `.secrets.local.cue` for local overrides and gitignore it.
- For webhook signature secrets specifically, see also the `encore-go-webhook` skill.

© encoredev · Apache-2.0 · encoredev/skills

Similar skills

Everything for Backend and APIs →

From the same set10

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor