RuleStack

Configs

Stacks

Compare

Diff

RuleStack

Configs

Stacks

Compare

Diff

Read API

RuleStack

Configs

Stacks

Compare

Diff

Read API

Configs/Cursor rules/sportiz91/vibe-template

Cursor rule

.cursor/rules/storage.mdc

Follow these rules when working on file storage.

Cursor rules

Quality

65/100

Scores the file, not the repository.

Length

658 words

15 headings · 3 code blocks

Repository

9

— · pushed 394 days ago

Last changed

3 days ago

First indexed 3 days ago.
sportiz91/vibe-template/.cursor/rules/storage.mdcRawGitHub
1---
2description: Follow these rules when working on file storage.
3globs:
4---
5# Storage Rules
6 
7Follow these rules when working with Supabase Storage.
8 
9It uses Supabase Storage for file uploads, downloads, and management.
10 
11## General Rules
12 
13- Always use environment variables for bucket names to maintain consistency across environments
14- Never hardcode bucket names in the application code
15- Always handle file size limits and allowed file types at the application level
16- Use the `upsert` method instead of `upload` when you want to replace existing files
17- Always implement proper error handling for storage operations
18- Use content-type headers when uploading files to ensure proper file handling
19 
20## Organization
21 
22### Buckets
23 
24- Name buckets in kebab-case: `user-uploads`, `profile-images`
25- Create separate buckets for different types of files (e.g., `profile-images`, `documents`, `attachments`)
26- Document bucket purposes in a central location
27- Set appropriate bucket policies (public/private) based on access requirements
28- Implement RLS (Row Level Security) policies for buckets that need user-specific access
29- Make sure to let me know instructions for setting up RLS policies on Supabase since you can't do this yourself, including the SQL scripts I need to run in the editor
30 
31### File Structure
32 
33- Organize files in folders based on their purpose and ownership
34- Use predictable, collision-resistant naming patterns
35- Structure: `{bucket}/{userId}/{purpose}/{filename}`
36- Example: `profile-images/123e4567-e89b/avatar/profile.jpg`
37- Include timestamps in filenames when version history is important
38- Example: `documents/123e4567-e89b/contracts/2024-02-13-contract.pdf`
39 
40## Actions
41 
42- When importing storage actions, use `@/actions/storage`
43- Name files like `example-storage-actions.ts`
44- Include Storage at the end of function names `Ex: uploadFile -> uploadFileStorage`
45- Follow the same ActionState pattern as DB actions
46 
47Example of a storage action:
48 
49```ts
50"use server"
51 
52import { createClientComponentClient } from "@supabase/auth-helpers-nextjs"
53import { ActionState } from "@/types"
54 
55export async function uploadFileStorage(
56 bucket: string,
57 path: string,
58 file: File
59): Promise<ActionState<{ path: string }>> {
60 try {
61 const supabase = createClientComponentClient()
62
63 const { data, error } = await supabase
64 .storage
65 .from(bucket)
66 .upload(path, file, {
67 upsert: false,
68 contentType: file.type
69 })
70 
71 if (error) throw error
72 
73 return {
74 isSuccess: true,
75 message: "File uploaded successfully",
76 data: { path: data.path }
77 }
78 } catch (error) {
79 console.error("Error uploading file:", error)
80 return { isSuccess: false, message: "Failed to upload file" }
81 }
82}
83```
84 
85## File Handling
86 
87### Upload Rules
88 
89- Always validate file size before upload
90- Implement file type validation using both extension and MIME type
91- Generate unique filenames to prevent collisions
92- Set appropriate content-type headers
93- Handle existing files appropriately (error or upsert)
94 
95Example validation:
96 
97```ts
98const MAX_FILE_SIZE = 10 * 1024 * 1024 // 10MB
99const ALLOWED_TYPES = ["image/jpeg", "image/png", "image/webp"]
100 
101function validateFile(file: File): boolean {
102 if (file.size > MAX_FILE_SIZE) {
103 throw new Error("File size exceeds limit")
104 }
105
106 if (!ALLOWED_TYPES.includes(file.type)) {
107 throw new Error("File type not allowed")
108 }
109
110 return true
111}
112```
113 
114### Download Rules
115 
116- Always handle missing files gracefully
117- Implement proper error handling for failed downloads
118- Use signed URLs for private files
119 
120### Delete Rules
121 
122- Implement soft deletes when appropriate
123- Clean up related database records when deleting files
124- Handle bulk deletions carefully
125- Verify ownership before deletion
126- Always delete all versions/transforms of a file
127 
128## Security
129 
130### Bucket Policies
131 
132- Make buckets private by default
133- Only make buckets public when absolutely necessary
134- Use RLS policies to restrict access to authorized users
135- Example RLS policy:
136 
137```sql
138CREATE POLICY "Users can only access their own files"
139ON storage.objects
140FOR ALL
141USING (auth.uid()::text = (storage.foldername(name))[1]);
142```
143 
144### Access Control
145 
146- Generate short-lived signed URLs for private files
147- Implement proper CORS policies
148- Use separate buckets for public and private files
149- Never expose internal file paths
150- Validate user permissions before any operation
151 
152## Error Handling
153 
154- Implement specific error types for common storage issues
155- Always provide meaningful error messages
156- Implement retry logic for transient failures
157- Log storage errors separately for monitoring
158 
159## Optimization
160 
161- Implement progressive upload for large files
162- Clean up temporary files and failed uploads
163- Use batch operations when handling multiple files

Sections

  • Storage Rules
  • General Rules
  • Organization
  • Buckets
  • File Structure
  • Actions
  • File Handling
  • Upload Rules
  • Download Rules
  • Delete Rules
  • Security
  • Bucket Policies
  • Access Control
  • Error Handling
  • Optimization

What it covers

architecturesecuritydo-not

Stack — with the evidence

typescript

(1.00)

node

(1.00)

nextjs

(1.00)

drizzle

(1.00)

tailwind

(1.00)

eslint

(1.00)

react

(0.70)

postgres

(0.70)

javascript

(0.60)

Glob targeting

  • [object Object]

Format

Cursor rules

The most expressive format here. Many small .mdc files, each with frontmatter declaring when it should load, so a rule about migrations only enters context when a migration is open. Costs the most to maintain and only one editor reads it.

What the corpus says about it

Repository

Owner
sportiz91
Language
—
License
—
Archived
no

All configs in this repo

Also in sportiz91/vibe-template

Diff this repo’s formats

One repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?

The other instruction files in this repository
RepositoryFormatStackCoversScoreChanged
sportiz91/vibe-template.cursor/rules/auth.mdc · 9Cursor rulestypescriptnode+7securitydo-not32/1003 days ago
sportiz91/vibe-template.cursor/rules/backend.mdc · 9Cursor rulestypescriptnode+7do-not61/1003 days ago
sportiz91/vibe-template.cursor/rules/coding-standards.mdc · 9Cursor rulestypescriptnode+7styletypesui36/1003 days ago
sportiz91/vibe-template.cursor/rules/frontend.mdc · 9Cursor rulestypescriptnode+7do-not61/1003 days ago
sportiz91/vibe-template.cursor/rules/general.mdc · 9Cursor rulestypescriptnode+7stylearchsecuritydo-not+169/1003 days ago
sportiz91/vibe-template.cursorrules · 9.cursorrulestypescriptnode+7stylearchsecuritydo-not+149/1003 days ago
sportiz91/vibe-templateCLAUDE.md · 9CLAUDE.mdtypescriptnode+7setuptestlint-formatstyle+788/1003 days ago
Diff against .cursor/rules/auth.mdc Diff against .cursor/rules/backend.mdc Diff against .cursor/rules/coding-standards.mdc Diff against .cursor/rules/frontend.mdc Diff against .cursor/rules/general.mdc Diff against .cursorrules Diff against CLAUDE.md

Similar configs

Same format, overlapping stack, ranked by quality.

Same format, overlapping stack, ranked by quality
RepositoryFormatStackCoversScoreChanged
hiromaily/go-crypto-wallet.cursor/rules/typescript.mdc · 126Cursor rulesgobun+5setupbuildtestlint-format+6100/1003 days ago
TechSquidTV/Hermes.cursor/rules/10-hermes-api.mdc · 45Cursor rulestypescriptpytest+15testlint-formatstylearch+5100/1003 days ago
markstev/mark-starter.cursor/rules/frontend.mdc · 0Cursor rulestypescriptturborepo+14setuptestlint-formatstyle+699/1003 days ago
Allymahmoud/case-intake-platform.cursor/rules/frontend.mdc · 0Cursor rulestypescriptturborepo+13setuptestlint-formatstyle+799/1003 days ago
dodgecfr/combatfilms-webapp.cursor/rules/frontend.mdc · 0Cursor rulestypescriptturborepo+15setuptestlint-formatstyle+799/1003 days ago
deifos/clipmira-subtitles.cursor/rules/frontend.mdc · 1Cursor rulestypescriptnextjs+5setuptestlint-formatstyle+799/1003 days ago
langflow-ai/langflow.cursor/rules/docs_development.mdc · 153kCursor rulespythonnode+16setupbuildtestlint-format+797/1003 days ago
TechSquidTV/Hermes.cursor/rules/20-hermes-api-tests.mdc · 45Cursor rulestypescriptpytest+15teststyletesting-strategysecurity+397/1003 days ago
RuleStack

Built by

Kynth Studio

Directory

Configs
Stacks
Compare formats
Diff two configs
Best AGENTS.md examples

Formats

AGENTS.md
CLAUDE.md
Cursor rules
Copilot instructions

Reference

Read API
Corpus health
Privacy Policy
Terms

RuleStack

RuleStack

Built by

Kynth Studio

Directory

Configs
Stacks
Compare formats
Diff two configs
Best AGENTS.md examples

Formats

AGENTS.md
CLAUDE.md
Cursor rules
Copilot instructions

Reference

Read API
Corpus health
Privacy Policy
Terms

RuleStack

RuleStack

Built by

Kynth Studio

Directory

Configs
Stacks
Compare formats
Diff two configs
Best AGENTS.md examples

Formats

AGENTS.md
CLAUDE.md
Cursor rules
Copilot instructions

Reference

Read API
Corpus health
Privacy Policy
Terms

RuleStack