Storageのロゴ

Storage

組織
butterbase-ai
storage

Use when uploading or downloading files, generating presigned URLs, configuring storage ACLs, or persisting file references (avatars, attachments, images) in a Butterbase app

概要

公開者butterbase-ai
リポジトリbutterbase-skills
スキル名storage
スター
535
フォーク
42
同梱ファイル
指示のみ
ライセンスMIT
リンク
  • Markdown形式の指示

    モデルが必要に応じて読み込むSKILL.mdファイルです。関連するリクエストがあったときだけトークンを消費します。

  • どのLLMでも利用可能

    AIスキルはプロバイダー固有のコードではなく、通常のMarkdownなので、GPT、Claude、Gemini、Grok、ローカルモデルで利用できます。

  • 指示だけで完結

    モデルに必要なものはすべて指示に含まれているため、別途同期するファイルはありません。

  • オープンソース

    butterbase-aiがGitHubで公開しています。インストールする前にソースを確認してください。

インストール

AIスキル「Storage」をTypingMindにインストールすれば、どのLLMでも利用できます。SKILL.mdを読み取れる別のAIエージェントに追加することもできます。

1

TypingMindにインストール

TypingMindはGitHubフォルダから直接スキルをインストールします。SKILL.mdを読み取り、リソースファイルをまとめてローカルに保存します。

  1. アプリを開き、「プラグイン」→「スキル」に移動します。
  2. 「GitHubからインストール」を選択します。
  3. 以下のスキルフォルダのURLを貼り付けて確定します。
    https://github.com/butterbase-ai/butterbase-skills/tree/main/skills/storage
  4. スキルを利用したいチャットごとに、そのスキルを有効にしてください。
「プラグイン」→「スキル」→「スキルを追加」→「GitHubのURLから」を選択し、フォルダのURLを貼り付けて「続行」を押します。
2

別のAIエージェントにインストール

Agent Skills形式を読み取れるAIエージェントなら、このスキルを利用できます。フォルダをそのAIエージェントのスキルディレクトリにコピーしてください。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/butterbase-ai/butterbase-skills.git /tmp/butterbase-skills
mkdir -p .claude/skills
cp -r /tmp/butterbase-skills/skills/storage .claude/skills/storage
コピー後、新しいスキルを読み込むためにClaude Codeを再起動してください。

TypingMindで使用

TypingMindのチャットでStorageを有効にするだけで、あとはモデルが対応します。名前と説明がシステムプロンプトに含まれ、関連するリクエストがあると、モデルが指示の全文を自動で読み込みます。手動で呼び出す必要はなく、実際に使用されるまでトークンを消費しません。

関連するリクエストがあるとすぐに、モデルが自動的にStorageを読み込みます。

どのAIモデルでも利用可能

AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、Storageは作成時に想定されたモデルに縛られません。TypingMindに一度インストールすれば、ご自身のAPIキーを使って、GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama、またはご自身で実行するローカルモデルで利用できます。

  • 必要なときだけ読み込み

    システムプロンプトには名前と説明だけが含まれます。関連するリクエストが初めてあったときに指示を取得するため、スキルを使わない間は指示の読み込みにトークンを消費しません。

  • チャットの途中でモデルを切り替え

    スキルはコードではなく指示なので、モデルを切り替えてもそのまま使えます。次のモデルも同じSKILL.mdを読み込みます。

スキルの指示

モデルが読み込むSKILL.mdの内容です。スキルはモデルが従う指示なので、インストールする前に確認してください。

Butterbase Storage

Butterbase stores files in S3 (or LocalStack in dev) and exposes them via presigned URLs. Every file gets a stable object_id (UUID) that you persist in your tables; URLs are generated on demand and expire.

All storage operations go through one tool: manage_storage with an action parameter.

ActionPurpose
upload_urlGenerate a 15-minute presigned PUT URL and reserve an object_id
download_urlGenerate a 1-hour presigned GET URL for a stored object
listList objects (scoped by caller's role)
deletePermanently remove an object from S3 + database
update_configToggle app-level publicReadEnabled and other storage settings

1. The mental model: object_id vs s3_key

FieldWhat it isWhen you use it
object_idUUID, stable, app-level handlePersist in your tables (e.g. users.avatar_id, posts.image_id)
s3_keyInternal bucket path like app_abc/user_uuid/file.jpgInternal only — never treat this as a URL

Critical: s3_key is not a URL. You cannot use it as <img src> or <a href>. Always store the object_id and resolve a fresh download URL at render time.


2. The upload lifecycle

A single upload is two HTTP calls and one DB insert in your app:

┌─────────────────────────┐
│ 1. manage_storage(      │  → returns { upload_url, object_id, expires_at }
│      action: upload_url)│
├─────────────────────────┤
│ 2. PUT file -> S3       │  → must include exact Content-Type header
├─────────────────────────┤
│ 3. INSERT INTO ...      │  → save object_id alongside the user/post/etc.
└─────────────────────────┘

If you skip step 3, the file lives in S3 but no row references it — an orphaned object counting against your quota. Always persist the object_id.

Step 1 — request an upload URL

js
manage_storage({
  app_id: "app_abc123",
  action: "upload_url",
  filename: "avatar.jpg",
  content_type: "image/jpeg",
  size_bytes: 245123,
  public: false                  // optional; default false
})

Returns:

json
{
  "upload_url": "https://s3.amazonaws.com/...",
  "object_id": "9c14b2e0-...",
  "expires_at": "2026-05-08T22:15:00Z"
}

The object_id is created immediately in the database; the file just hasn't been uploaded yet.

Step 2 — PUT the bytes

The Content-Type on the PUT must match exactly the content_type you sent in step 1. If it doesn't, S3 rejects the upload or stores the wrong MIME — breaking browser previews.

bash
curl -X PUT "{upload_url}" \
  -H "Content-Type: image/jpeg" \
  --data-binary @avatar.jpg

From the browser:

js
await fetch(uploadUrl, {
  method: "PUT",
  headers: { "Content-Type": file.type },
  body: file
});

Step 3 — persist the object_id

sql
UPDATE users SET avatar_id = $1 WHERE id = $2

Or via the auto-API / SDK — whatever your app uses for writes. Without this step, the file is unreachable.


3. Generating download URLs

Each call returns a fresh URL valid for 1 hour. Don't bake URLs into static HTML or long-lived caches — re-generate per render or per session.

js
manage_storage({
  app_id: "app_abc123",
  action: "download_url",
  object_id: "9c14b2e0-..."
})
// → { download_url: "https://s3.amazonaws.com/..." }

For lists with many files, resolve URLs in parallel:

js
const urls = await Promise.all(
  posts.map(p => getDownloadUrl(p.image_id))
);

If the caller is unauthorized, the response is 404 (not 403) — Butterbase deliberately hides existence to avoid leaking object IDs.


4. Access control

Three tiers, evaluated in order:

CallerWhat they can read
Service key (bb_sk_*)Everything in the app — RLS bypassed
End-user JWTFiles where (user_id === caller_id) OR object.public === true OR app.publicReadEnabled === true
Anonymous (no auth)Only public objects (and only if app access mode allows anon)

Per-object public flag

Set at upload time:

js
manage_storage({ app_id, action: "upload_url", filename, content_type, size_bytes, public: true })

Use this for one-off public files (a marketing image, a shared avatar) without flipping the whole app to public-read.

App-wide public read

js
manage_storage({
  app_id: "app_abc123",
  action: "update_config",
  publicReadEnabled: true
})

When true, any authenticated user in the app can download any file. Uploads and deletes stay user-scoped.

Storage ACL is hardcoded — you cannot layer Postgres RLS policies on top of storage_objects. If you need fine-grained custom rules, gate downloads through a serverless function instead of handing out direct presigned URLs.


5. Listing and deleting

js
manage_storage({ app_id: "app_abc123", action: "list" })

Service key sees everything; end-user JWT sees only their own files. Each item has id, user_id, key, filename, content_type, size_bytes, created_at.

js
manage_storage({ app_id: "app_abc123", action: "delete", object_id: "9c14b2e0-..." })

Permanently removes the S3 object and DB row. Clear foreign-key references first (e.g. UPDATE users SET avatar_id = NULL) — manage_storage doesn't.


6. Quotas & error codes

LimitDefaultOverride
Per-file size10 MBstorage_config
Total app storagePlan-dependentUpgrade plan
Allowed content typesAll by defaultstorage_config.allowedContentTypes whitelist
ErrorWhen
QUOTA_FILE_SIZE_EXCEEDED (400)size_bytes > per-file limit
QUOTA_STORAGE_EXCEEDED (429)App total exhausted
VALIDATION_INVALID_TYPE (400)content_type not in whitelist
RESOURCE_NOT_FOUND (404)Object missing or caller unauthorized (deliberately ambiguous)
S3_ERROR (503)Transient S3 failure — retry

7. Common patterns

User avatar

  1. Upload form posts file → manage_storage (upload_url, public: false).
  2. Browser PUTs to upload_url.
  3. App calls UPDATE users SET avatar_id = $object_id.
  4. On profile render: manage_storage (download_url, object_id: user.avatar_id).

Public marketing image

Same flow, but public: true at upload time. Then the same download URL is reachable by anonymous visitors (no JWT needed) — useful for landing pages and OG images.

File attachment with auth

For attachments where access depends on app-level rules richer than "owner or public" (e.g. "members of this workspace can read"), don't expose the presigned URL directly. Wrap downloads in a serverless function:

ts
export async function handler(req, ctx) {
  const { rows } = await ctx.db.query(
    "SELECT object_id FROM attachments WHERE id = $1 AND workspace_id IN (SELECT workspace_id FROM members WHERE user_id = $2)",
    [attachmentId, ctx.user.id]
  );
  if (!rows.length) return new Response("forbidden", { status: 403 });
  const url = await getDownloadUrlServerSide(rows[0].object_id);
  return Response.redirect(url, 302);
}

The function runs as butterbase_user and uses your tables' RLS to authorize, then mints a presigned URL with the service key.


8. Anti-patterns

Don'tDo
Store the s3_key in your tablesStore the object_id UUID
Embed presigned URLs in HTML or DB rowsRe-fetch per render — they expire in 1 hour
Send the wrong Content-Type on PUTMatch exactly what you sent to upload_url
Call upload_url and forget step 3Always persist object_id after a successful PUT
Use public: true everywhere "just in case"Default to private; opt files into public explicitly
Delete a file without clearing FKsUpdate referencing rows first, then action: "delete"

If a docs/butterbase/00-state.md exists in the working directory, prefer invoking via /butterbase-skills:journey-storage so the journey orchestrator stays in sync.

よくある質問

AIスキル「Storage」では何ができますか?

Use when uploading or downloading files, generating presigned URLs, configuring storage ACLs, or persisting file references (avatars, attachments, images) in a Butterbase app

TypingMindでStorageを使うメリットは何ですか?

一度インストールすれば、どのモデルでも使えるからです。Storageはプロバイダー固有のコードではなく、通常のMarkdownで記述されているため、同じスキルをGPT-5、Claude、Gemini、Grok、ローカルモデルで利用できます。チャットの途中でモデルを切り替えても、そのまま使い続けられます。TypingMindは自分のAPIキーで動作するため、シート単位のサブスクリプションではなく、プロバイダーに直接料金を支払います。スキルとチャットは自分のストレージに保持されます。

TypingMindにStorageをインストールするにはどうすればよいですか?

TypingMindで「プラグイン」→「スキル」→「GitHubからインストール」を開き、https://github.com/butterbase-ai/butterbase-skills/tree/main/skills/storageを貼り付けてください。TypingMindがSKILL.mdを読み込み、チャットごとに有効にできるスキルとしてインストールします。

Storageを使えるAIモデルはどれですか?

TypingMindに接続したどのモデルでも利用できます。AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、GPT、Claude、Gemini、Grok、ローカルモデルのいずれも、リクエストの内容がこのスキルの用途に合ったときに、このスキルを読み込めます。

Storageで使えるAIモデルの数に制限はありますか?

数に制限はありません。スキルに対応したモデルであれば、GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llamaなど、どのモデルでもStorageを利用できます。すべてTypingMind上で、自分のAPIキーを使って利用できます。

AIスキル「Storage」は無料ですか?

はい。butterbase-aiがMITライセンスのもとでGitHubに公開しています。ご利用のAIプロバイダーに支払うのは、使用したトークンの料金だけです。

AIスキルとは何ですか?

AIスキルは、特定のタスクの実行方法をAIモデルに教える、再利用可能な指示のセットです。オープンなAgent Skills形式に従い、名前と説明を含むSKILL.mdファイルに加え、モデルが必要とするスクリプト、テンプレート、参照ファイルで構成されます。モデルはリクエストがスキルに合致したときだけ指示を読み込むため、インストール済みのスキルも、使うまでは費用がかかりません。

AIスキルは、プラグインやMCPサーバーとどう違いますか?

プラグインやMCPサーバーは、モデルが呼び出せる新しいツールを提供します。ツールとは、どこかで実行され、結果を返すコードです。一方、AIスキルは、タスクへの取り組み方、従うべき手順、望ましい出力の例といった知識や進め方をモデルに伝えます。スキルは通常のMarkdownで記述されているため、サーバー、APIキー、実行環境は不要で、どのモデルでも利用できます。

すべて見る

今すぐ自分専用のAIワークスペースを作成

ニュースレターに登録すると、新機能や今後のプレゼント企画のお知らせが届きます👇