MCP HubMCP Hub
SKILL·4ED528

django-storages-s3

jeffallan
更新日 22 days ago
5 閲覧
11,251
1,075
11,251
GitHubで表示
テストtesting

について

このClaudeスキルは、開発者がdjango-storagesパッケージを使用してDjangoの静的ファイルとメディアファイルをAWS S3に保存する設定を行うのを支援します。STORAGES辞書の設定、カスタムバックエンドの作成、署名付きURLの生成、CloudFrontとの統合に関する専門的なガイダンスを提供します。Django設定でS3をバックエンドとするファイルストレージの実装、IAMポリシーの管理、テスト用のS3モック作成を行う際にご利用ください。

クイックインストール

Claude Code

推奨
メイン
npx skills add jeffallan/claude-skills -a claude-code
プラグインコマンド代替
/plugin add https://github.com/jeffallan/claude-skills
Git クローン代替
git clone https://github.com/jeffallan/claude-skills.git ~/.claude/skills/django-storages-s3

このコマンドをClaude Codeにコピー&ペーストしてスキルをインストールします

ドキュメント

Django Storages S3

Senior Django specialist for production-grade file storage on AWS S3 via django-storages and boto3 — public and private media, static files, presigned URLs, and CloudFront.

When to Use This Skill

  • Serving static and/or media files from AWS S3 instead of the local filesystem
  • Configuring the Django 4.2+ STORAGES dict or legacy DEFAULT_FILE_STORAGE
  • Separating public (CDN-served) and private (presigned) file backends
  • Generating presigned download or direct browser-to-S3 upload URLs
  • Fronting S3 with CloudFront and writing a least-privilege IAM policy
  • Migrating local FileField/ImageField storage to S3 without code changes
  • Testing storage code without hitting S3

Core Workflow

  1. Install & registerpip install django-storages[s3] boto3; add "storages" to INSTALLED_APPS
  2. Configure credentials — Load from env vars or rely on an attached IAM role; never hardcode
  3. Wire the STORAGES dict — Set default (media) and staticfiles backends with separate location prefixes
  4. Add named backends — Split public vs. private buckets/ACLs as additional STORAGES entries when needed
  5. Verify & test — Run collectstatic, confirm uploads land in S3, and mock S3 in tests with InMemoryStorage or moto

Reference Guide

Load detailed guidance based on context:

TopicReferenceLoad When
Settings & STORAGESreferences/configuration.mdCore settings, 4.2+ vs legacy, CloudFront
Custom backendsreferences/custom-backends.mdPublic vs. private buckets, per-field storage
Presigned URLsreferences/presigned-urls.mdDownload links, direct browser uploads
Testing & IAMreferences/testing-storages.mdMocking S3, IAM policy, common pitfalls

Minimal Working Example

The snippet below demonstrates the core MUST DO constraints: env-loaded credentials, STORAGES dict, separate media/static locations, and default_acl=None on the media backend.

# settings.py
import os

AWS_STORAGE_BUCKET_NAME = os.environ["AWS_STORAGE_BUCKET_NAME"]
AWS_S3_REGION_NAME = os.environ.get("AWS_S3_REGION_NAME", "us-east-1")
AWS_S3_CUSTOM_DOMAIN = f"{AWS_STORAGE_BUCKET_NAME}.s3.{AWS_S3_REGION_NAME}.amazonaws.com"
# On EC2/ECS/Lambda, omit keys entirely — boto3 uses the attached IAM role.

STORAGES = {
    "default": {  # media uploads
        "BACKEND": "storages.backends.s3boto3.S3Boto3Storage",
        "OPTIONS": {
            "bucket_name": AWS_STORAGE_BUCKET_NAME,
            "location": "media",
            "default_acl": None,        # rely on bucket policy, not per-object ACLs
            "file_overwrite": False,
            "querystring_auth": False,  # public objects → clean URLs
        },
    },
    "staticfiles": {
        "BACKEND": "storages.backends.s3boto3.S3StaticStorage",
        "OPTIONS": {
            "bucket_name": AWS_STORAGE_BUCKET_NAME,
            "location": "static",
        },
    },
}

MEDIA_URL = f"https://{AWS_S3_CUSTOM_DOMAIN}/media/"
STATIC_URL = f"https://{AWS_S3_CUSTOM_DOMAIN}/static/"
# models.py — uploads go straight to S3 on save()
from django.db import models

class Document(models.Model):
    file = models.FileField(upload_to="docs/")  # uses STORAGES["default"]

Auditing an Existing Configuration

When reviewing a project that already uses S3 (not greenfield), walk this checklist — each item is a constraint below rephrased as "find X, confirm Y":

  1. Credentialsgrep -rn "AWS_SECRET_ACCESS_KEY\|aws_secret" settings/ → confirm values come from os.environ/django-environ or an IAM role, never literals committed to the repo.
  2. ACLsgrep -rn "default_acl\|AWS_DEFAULT_ACL" . → on buckets created after April 2023, every value must be None. Any "public-read"/"private" will raise AccessControlListNotSupported; public access belongs in a bucket policy.
  3. Storage backend — confirm Django 4.2+ uses the STORAGES dict, not DEFAULT_FILE_STORAGE/STATICFILES_STORAGE (removed in Django 5.1, so silently ignored on 5.1/5.2/6.0); confirm the static class is S3StaticStorage, not a fabricated name.
  4. Locations — confirm default (media) and staticfiles have distinct location prefixes or buckets so collectstatic never collides with uploads.
  5. Region — confirm region_name (or the global AWS_S3_REGION_NAME) matches the bucket's real region and that AWS_S3_CUSTOM_DOMAIN includes the region segment for non-us-east-1 buckets.
  6. Presigning — for private backends, confirm querystring_auth=True and custom_domain=None; confirm presigned .url() results aren't cached past AWS_QUERYSTRING_EXPIRE.
  7. Overwrite cleanup — where file_overwrite=False, confirm replaced files are explicitly deleted (otherwise superseded objects leak).
  8. IAM — confirm the policy grants only Get/Put/Delete/ListBucket on the bucket ARN, not broader S3 access.

Constraints

MUST DO

  • Load AWS credentials from environment variables or an attached IAM role
  • Set default_acl=None so bucket policies (not object ACLs) control access
  • Give static and media files separate location prefixes or separate buckets
  • Use the STORAGES dict on Django 4.2+ (same config through 5.2 LTS and 6.0); DEFAULT_FILE_STORAGE/STATICFILES_STORAGE were removed in 5.1, so reserve them for < 4.2 only
  • Set custom_domain=None on any backend that issues presigned URLs
  • Mock S3 (InMemoryStorage or moto) in tests instead of hitting real buckets

MUST NOT DO

  • Hardcode AWS_SECRET_ACCESS_KEY in settings.py or commit it
  • Mix querystring_auth=True with a custom_domain (presigning breaks)
  • Mix static and media files under the same prefix
  • Grant the IAM user broader than Get/Put/Delete/ListBucket on the bucket ARN
  • Rely on per-object ACLs on buckets created after April 2023 (ACLs disabled by default)

Knowledge Reference

django-storages, S3Boto3Storage, S3StaticStorage, boto3, STORAGES dict, presigned URLs, generate_presigned_post, CloudFront, IAM policy, InMemoryStorage, moto

Related Skills

  • django-expert — core Django models, DRF, and ORM that produce the files this skill persists to S3
  • fullstack-guardian — secure end-to-end upload flows and access control around stored files
  • devops-engineer — provisioning the S3 buckets, IAM roles, and CloudFront distributions this skill targets

Documentation

GitHub リポジトリ

jeffallan/claude-skills
パス: skills/django-storages-s3
0
ai-agentsclaudeclaude-codeclaude-marketplaceclaude-skills
FAQ

よくある質問

django-storages-s3 Skillとは何ですか?

django-storages-s3 はjeffallan が作成した Claude Skillです。Skillは、Claudeが必要に応じて読み込む指示とリソースをまとめ、追加の指示なしで django-storages-s3 に関連するタスクを実行できるようにします。

django-storages-s3 をインストールするには?

このページのインストールコマンドを使用してください。django-storages-s3 をプラグインとして Claude Code に追加するか、リポジトリを skills ディレクトリにクローンし、Claudeを再起動してSkillを読み込みます。

django-storages-s3 はどのカテゴリに属しますか?

django-storages-s3 は テスト カテゴリに属します。

django-storages-s3 は無料で利用できますか?

はい。django-storages-s3 は AIMCP に掲載されており、無料でインストールできます。

関連スキル

evaluating-llms-harness
テスト

このClaudeスキルは、lm-evaluation-harnessを実行し、MMLUやGSM8Kなど60以上の標準化学術タスクでLLMをベンチマークします。開発者がモデルの品質を比較し、トレーニングの進捗を追跡し、学術的な結果を報告するために設計されています。このツールはHuggingFaceやvLLMモデルを含む様々なバックエンドをサポートしています。

スキルを見る
cloudflare-cron-triggers
テスト

このスキルは、cron式を使用してWorkersをスケジュールするためのCloudflare Cron Triggersの実装に関する包括的な知識を提供します。定期的なタスクの設定、メンテナンスジョブ、自動化されたワークフローの構築を網羅し、無効なcron式やタイムゾーン問題といった一般的な課題への対処法も含みます。開発者はこれを使用して、スケジュールされたハンドラーの設定、cronトリガーのテスト、WorkflowsやGreen Computeとの連携を構成できます。

スキルを見る
webapp-testing
テスト

このClaude Skillは、Playwrightベースのツールキットを提供し、Pythonスクリプトを通じてローカルWebアプリケーションのテストを可能にします。フロントエンドの検証、UIデバッグ、スクリーンショット撮影、ログ表示を実現し、サーバーライフサイクルを管理します。ブラウザ自動化タスクにご利用いただけますが、コンテキストの汚染を避けるため、スクリプトのソースコードを読むのではなく直接実行してください。

スキルを見る
finishing-a-development-branch
テスト

このスキルは、開発者がテストの合格を確認し、構造化された統合オプションを提示することで、完成した作業を仕上げることを支援します。実装が完了した後のマージ、PR作成、ブランチの整理といったワークフローを案内します。コードが準備できてテスト済みの際に使用し、開発プロセスを体系的に完了させましょう。

スキルを見る