Skip to main content
skill CX Codex

encore-go-bucket — Claude Code skill for Encore Go buckets

A skill that shows the agent how to declare buckets and handle files in Encore Go: uploads, downloads, signed URLs.

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

What encore-go-bucket does

This skill covers object storage inside Encore Go services. A bucket is declared as a package-level variable with objects.NewBucket from encore.dev/storage/objects. Encore provisions the storage underneath: S3 on AWS, GCS on GCP, in-memory locally.

Inside are ready patterns for the operations you need: streaming Upload, Download, Exists, Attrs, List, Remove. Public buckets get PublicURL; private ones get SignedUploadURL and SignedDownloadURL with a TTL so browsers talk to storage directly instead of through your service. A separate section covers BucketRef with permission sets like Downloader, Uploader, Lister, Attrser, Remover.

The skill advises declaring buckets at package level and keeping them private by default, opting into Public: true only for assets meant to be fetched without auth. When you hand bucket access to library code, use BucketRef — the permission contract then lives in the type system. Worth a look at your own buckets: a public one holding user files is an open door.

What it helps with

  • store a user avatar in an Encore service
  • hand out a temporary link to a stored file
  • list bucket objects with their sizes
  • delete a document by key
  • pass bucket access to a helper with limited permissions

Example prompts for the agent

  • Add a private bucket for avatar uploads to my Encore Go service
  • Write an endpoint that returns a signed upload URL valid for 2 hours
  • Show me how to give a helper download-only access with BucketRef

How to install encore-go-bucket

1Skills CLI (Vercel)

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

2Manually: put the files in place

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

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

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

Questions about encore-go-bucket

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

Run npx skills add encoredev/skills --skill encore-go-bucket -a claude-code. The skill lands in ~/.claude/skills/go-bucket/SKILL.md.

What does encore-go-bucket do?

It teaches the agent to declare buckets in Encore Go and write code for uploading, downloading, listing and deleting files, including signed URLs and bucket references with permission sets.

When does the skill trigger?

On requests about object storage, buckets, S3, GCS, blobs, image or user file uploads — whenever an Encore Go service needs to hold unstructured data.

Source text

SKILL.md · Apache-2.0
---
name: encore-go-bucket
description: Store unstructured files in Encore Go using `objects.NewBucket` from `encore.dev/storage/objects` — uploads, images, documents, blobs.
when_to_use: >-
  User wants to upload, download, list, or delete files from an Encore Go service — profile pictures, avatars, document uploads, image storage, media assets, generated reports, blob data. Covers public vs private buckets, signed upload/download URLs, bucket references with permission types (Uploader, Downloader, Lister, Attrser, Remover), and operations like `Upload`, `Download`, `List`, `SignedUploadURL`. Trigger phrases: "object storage", "bucket", "S3", "GCS", "blob", "user uploads", "profile picture", "image upload", "store a file", "file storage".
---

# Encore Go Object Storage

## Instructions

A `Bucket` is a logical store for files. Encore provisions the underlying object storage (S3 on AWS, GCS on GCP, in-memory locally). Declare buckets as package-level variables.

```go
package uploads

import "encore.dev/storage/objects"

// Private bucket (default)
var Uploads = objects.NewBucket("user-uploads", objects.BucketConfig{})

// Public bucket — files accessible via public URL
var PublicAssets = objects.NewBucket("public-assets", objects.BucketConfig{
    Public: true,
})
```

## Operations

```go
import (
    "fmt"
    "io"
)

// Upload (streaming pattern)
writer := Uploads.Upload(ctx, "path/to/file.jpg")
_, err := io.Copy(writer, dataReader)
if err != nil {
    writer.Abort()
    return err
}
err = writer.Close()

// Download
reader := Uploads.Download(ctx, "path/to/file.jpg")
if err := reader.Err(); err != nil {
    return err
}
defer reader.Close()
data, _ := io.ReadAll(reader)

// Existence check
exists, err := Uploads.Exists(ctx, "path/to/file.jpg")

// Attributes (size, content type, ETag)
attrs, err := Uploads.Attrs(ctx, "path/to/file.jpg")

// List
for err, entry := range Uploads.List(ctx, &objects.Query{}) {
    if err != nil {
        return err
    }
    fmt.Println(entry.Key, entry.Size)
}

// Delete
err := Uploads.Remove(ctx, "path/to/file.jpg")

// Public URL (only for public buckets)
url := PublicAssets.PublicURL("image.jpg")
```

## Signed URLs

Generate temporary URLs so clients can upload/download directly without going through your service:

```go
import "time"

// Signed upload URL (expires in 2 hours)
url, err := Uploads.SignedUploadURL(ctx, "user-uploads/avatar.jpg",
    objects.WithTTL(time.Duration(7200)*time.Second))

// Signed download URL
url, err := Uploads.SignedDownloadURL(ctx, "documents/report.pdf",
    objects.WithTTL(time.Duration(7200)*time.Second))
```

## Bucket References

Pass bucket access to library code with a specific permission set:

```go
// Create a reference with download permission only
ref := objects.BucketRef[objects.Downloader](Uploads)

// Combine permissions via an interface
type myPerms interface {
    objects.Downloader
    objects.Uploader
}
ref := objects.BucketRef[myPerms](Uploads)

// Permission types: Downloader, Uploader, Lister, Attrser, Remover,
// SignedDownloader, SignedUploader, ReadWriter
```

## Guidelines

- Declare buckets as package-level variables.
- Default to private buckets; opt into `Public: true` only for assets meant for unauthenticated download.
- Use signed URLs for browser uploads/downloads instead of streaming through your service.
- Use bucket references when passing access to helpers — they encode the permission contract in the type system.

© 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