templates/skills/services/gcs/SKILL.md
Use Google Cloud Storage for object storage, file uploads, static assets, and backup storage in GCP.
npx skillsauth add hivellm/rulebook Google Cloud StorageInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
CRITICAL: Use Google Cloud Storage for object storage, file uploads, static assets, and backup storage in GCP.
// Using @google-cloud/storage
import { Storage } from '@google-cloud/storage'
const storage = new Storage({
projectId: process.env.GCP_PROJECT_ID,
keyFilename: process.env.GCP_KEY_FILE, // Path to service account key
// Or use credentials object
credentials: {
client_email: process.env.GCP_CLIENT_EMAIL,
private_key: process.env.GCP_PRIVATE_KEY?.replace(/\\n/g, '\n'),
},
})
const bucket = storage.bucket(process.env.GCS_BUCKET_NAME || 'my-bucket')
// Upload file
const file = bucket.file('path/to/file.jpg')
await file.save(fileBuffer, {
metadata: {
contentType: 'image/jpeg',
metadata: {
userId: '123',
originalName: 'photo.jpg',
},
},
})
// Download file
const [fileContent] = await file.download()
// Delete file
await file.delete()
// List files
const [files] = await bucket.getFiles({
prefix: 'uploads/',
maxResults: 100,
})
// Generate signed URL
const [url] = await file.getSignedUrl({
action: 'read',
expires: Date.now() + 3600 * 1000, // 1 hour
})
// Generate signed URL for upload
const [uploadUrl] = await file.getSignedUrl({
action: 'write',
expires: Date.now() + 3600 * 1000,
contentType: 'image/jpeg',
})
// Copy file
const sourceFile = bucket.file('source/file.jpg')
const destFile = bucket.file('dest/file.jpg')
await sourceFile.copy(destFile)
// Set metadata
await file.setMetadata({
metadata: {
category: 'profile',
uploadedBy: 'user-123',
},
})
// Get metadata
const [metadata] = await file.getMetadata()
console.log(metadata.contentType, metadata.size, metadata.metadata)
async function uploadFile(file: Buffer, filename: string, userId: string) {
const filePath = `users/${userId}/${Date.now()}-${filename}`
const file = bucket.file(filePath)
await file.save(file, {
metadata: {
contentType: getContentType(filename),
metadata: {
userId,
originalName: filename,
uploadedAt: new Date().toISOString(),
},
},
})
await file.makePublic() // Or use signed URLs
return {
filePath,
publicUrl: file.publicUrl(),
}
}
async function generateTemporaryUrl(filePath: string, expiresInMinutes: number = 60) {
const file = bucket.file(filePath)
const [url] = await file.getSignedUrl({
action: 'read',
expires: Date.now() + expiresInMinutes * 60 * 1000,
})
return url
}
✅ DO:
❌ DON'T:
GCP_PROJECT_ID=my-project
GCP_KEY_FILE=/path/to/service-account-key.json
[email protected]
GCP_PRIVATE_KEY="-----BEGIN PRIVATE KEY-----\n..."
GCS_BUCKET_NAME=my-bucket
{
"type": "service_account",
"project_id": "my-project",
"private_key_id": "...",
"private_key": "-----BEGIN PRIVATE KEY-----\n...",
"client_email": "[email protected]",
"client_id": "...",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token"
}
<!-- GCS:END -->research
Create structured analyses with numbered findings, execution plans, and task materialization
research
Author a rulebook task spec interactively — research, draft, ask the user clarifying questions, confirm, then create the tasks in rulebook ready for /rulebook-driver. Use when the user wants to plan/spec a feature before implementing.
development
Behavioral guidelines to reduce common LLM coding mistakes — overcomplication, sloppy refactors, hidden assumptions, weak goals. Use when writing, reviewing, or refactoring code. Auto-applies; invoke explicitly via /karpathy-guidelines or 'follow karpathy discipline'.
data-ai
Autonomous AI agent loop for iterative task implementation (@hivehub/rulebook ralph)