Overview
Appwrite is an open-source backend-as-a-service platform providing auth, database, storage, functions, and messaging for web, mobile, and Flutter applications. It's self-hostable and has a cloud offering.
Capabilities
- Authentication (email, phone, OAuth2, anonymous, magic links)
- Database with documents, collections, and relationships
- File storage with antivirus scanning
- Serverless functions (Node, Python, PHP, Ruby, Swift, Dart, Go, .NET, Java, Kotlin, Bun, Deno)
- Realtime subscriptions via WebSocket
- Messaging (push, email, SMS)
- Teams and permissions
- Locale and avatars services
When to Use
Trigger phrases:
"appwrite patterns"
"Appwrite backend-as-a-service — auth, database, storage, functions, realtime for"
Full-featured BaaS without building from scratch
Flutter/mobile-first applications
Need self-hosted backend control
Multi-platform (web, iOS, Android, Flutter) applications
When NOT to Use
- Task is about deployment, not development (use deploy skills)
- Task is about code review, not writing (use review skills)
- You need to understand existing code first (use research skills)
- Task is about testing only (use test skills)
- Requirements are unclear (clarify first)
- Task is trivially simple (single line fix)
Pseudo Code
The appwrite-patterns workflow follows a standard pipeline pattern.
Core flow:
# appwrite-patterns primary flow
input = prepare(raw_data)
result = process(input, config={appwrite, auth, backend, database, desktop})
validate(result)
deliver(result)
Error handling:
on error:
log(error_details)
retry_with_backoff(max=3)
if still_failing: alert_and_escalate()
Setup (Web SDK)
import { Client, Account, Databases, Storage, Functions } from 'appwrite';
const client = new Client()
.setEndpoint('https://cloud.appwrite.io/v1')
.setProject('your-project-id');
const account = new Account(client);
const databases = new Databases(client);
const storage = new Storage(client);
const functions = new Functions(client);
Authentication
// Email/password
await account.create(ID.unique(), 'alice@example.com', 'password', 'Alice');
const session = await account.createEmailPasswordSession('alice@example.com', 'password');
// OAuth2
await account.createOAuth2Session('google', 'https://app.com/success', 'https://app.com/fail');
// Magic link
await account.createMagicURLSession(ID.unique(), 'alice@example.com', 'https://app.com/verify');
// Get current user
const user = await account.get();
Database CRUD
import { ID, Query } from 'appwrite';
// Create
await databases.createDocument('mydb', 'posts', ID.unique(), {
title: 'Hello World',
content: 'My first post',
author: userId,
});
// Read with queries
const posts = await databases.listDocuments('mydb', 'posts', [
Query.equal('status', 'published'),
Query.orderDesc('$createdAt'),
Query.limit(20),
]);
// Update
await databases.updateDocument('mydb', 'posts', documentId, {
title: 'Updated Title',
});
// Delete
await databases.deleteDocument('mydb', 'posts', documentId);
Storage
// Upload file
const file = await storage.createFile('bucket-id', ID.unique(), fileInput);
// Get file URL
const url = storage.getFileView('bucket-id', fileId);
// Delete file
await storage.deleteFile('bucket-id', fileId);
Realtime
// Subscribe to collection changes
client.subscribe('databases.mydb.collections.posts.documents', (response) => {
console.log(response.events); // ['databases.*.collections.*.documents.*.create']
console.log(response.payload);
});
// Subscribe to user's own channel
client.subscribe('account', (response) => { /* auth events */ });
Functions
// Execute function
const result = await functions.createExecution('function-id', JSON.stringify({ key: 'value' }));
console.log(result.stdout, result.stderr);
Common Patterns
- Permissions: Use
Permission.read(Role.user(userId)) for fine-grained access control
- Relationships: Use relationship attributes for document linking
- Migrations: Use Appwrite CLI (
appwrite push/pull) for collection schemas
- Docker: Self-host with
docker compose up -d
How to Use
- Understand the requirement and existing codebase patterns
- Design the solution with error handling and testability in mind
- Implement incrementally with tests for each change
- Verify against expected outcomes (manual and automated)
- Document usage, edge cases, and integration points
- Review with team before merging to shared branches
Red Flags
- Skipping tests to ship faster: Untested code breaks in production when you least expect it
- No error handling in production code: Unhandled errors crash services and lose user data
- Hardcoded configuration values: Hardcoded values prevent environment switching and leak secrets
- Ignoring security implications: Missing input validation, auth bypasses, and injection vulnerabilities
- Over-engineering simple solutions: Premature abstraction adds complexity without proportional benefit
Verification
Process
- Analyze the task requirements
- Apply domain expertise
- Verify output quality
Anti-Rationalization Table
| Rationalization |
Reality |
| "Tests slow me down" |
Bugs slow you down 10x more. Tests are speed, not overhead. |
| "I will refactor later" |
Technical debt compounds. Refactor as you go. |
| "It works on my machine" |
If it is not in CI, it does not work. Ship proof, not claims. |
1---2name: appwrite-patterns3description: Use when appwrite backend-as-a-service — auth, database, storage, functions, realtime for web/mobile/desktop. Use when working with appwrite patterns.4license: Apache-2.05---6789## Overview1011Appwrite is an open-source backend-as-a-service platform providing auth, database, storage, functions, and messaging for web, mobile, and Flutter applications. It's self-hostable and has a cloud offering.1213## Capabilities1415- Authentication (email, phone, OAuth2, anonymous, magic links)16- Database with documents, collections, and relationships17- File storage with antivirus scanning18- Serverless functions (Node, Python, PHP, Ruby, Swift, Dart, Go, .NET, Java, Kotlin, Bun, Deno)19- Realtime subscriptions via WebSocket20- Messaging (push, email, SMS)21- Teams and permissions22- Locale and avatars services2324## When to Use25**Trigger phrases:**26- "appwrite patterns"27- "Appwrite backend-as-a-service — auth, database, storage, functions, realtime for"282930- Full-featured BaaS without building from scratch31- Flutter/mobile-first applications32- Need self-hosted backend control33- Multi-platform (web, iOS, Android, Flutter) applications3435## When NOT to Use3637- Task is about deployment, not development (use deploy skills)38- Task is about code review, not writing (use review skills)39- You need to understand existing code first (use research skills)40- Task is about testing only (use test skills)41- Requirements are unclear (clarify first)42- Task is trivially simple (single line fix)434445## Pseudo Code4647The appwrite-patterns workflow follows a standard pipeline pattern.4849Core flow:50```51# appwrite-patterns primary flow52input = prepare(raw_data)53result = process(input, config={appwrite, auth, backend, database, desktop})54validate(result)55deliver(result)56```5758Error handling:59```60on error:61 log(error_details)62 retry_with_backoff(max=3)63 if still_failing: alert_and_escalate()64```656667### Setup (Web SDK)68```typescript69import { Client, Account, Databases, Storage, Functions } from 'appwrite';7071const client = new Client()72 .setEndpoint('https://cloud.appwrite.io/v1')73 .setProject('your-project-id');7475const account = new Account(client);76const databases = new Databases(client);77const storage = new Storage(client);78const functions = new Functions(client);79```8081### Authentication82```typescript83// Email/password84await account.create(ID.unique(), 'alice@example.com', 'password', 'Alice');85const session = await account.createEmailPasswordSession('alice@example.com', 'password');8687// OAuth288await account.createOAuth2Session('google', 'https://app.com/success', 'https://app.com/fail');8990// Magic link91await account.createMagicURLSession(ID.unique(), 'alice@example.com', 'https://app.com/verify');9293// Get current user94const user = await account.get();95```9697### Database CRUD98```typescript99import { ID, Query } from 'appwrite';100101// Create102await databases.createDocument('mydb', 'posts', ID.unique(), {103 title: 'Hello World',104 content: 'My first post',105 author: userId,106});107108// Read with queries109const posts = await databases.listDocuments('mydb', 'posts', [110 Query.equal('status', 'published'),111 Query.orderDesc('$createdAt'),112 Query.limit(20),113]);114115// Update116await databases.updateDocument('mydb', 'posts', documentId, {117 title: 'Updated Title',118});119120// Delete121await databases.deleteDocument('mydb', 'posts', documentId);122```123124### Storage125```typescript126// Upload file127const file = await storage.createFile('bucket-id', ID.unique(), fileInput);128129// Get file URL130const url = storage.getFileView('bucket-id', fileId);131132// Delete file133await storage.deleteFile('bucket-id', fileId);134```135136### Realtime137```typescript138// Subscribe to collection changes139client.subscribe('databases.mydb.collections.posts.documents', (response) => {140 console.log(response.events); // ['databases.*.collections.*.documents.*.create']141 console.log(response.payload);142});143144// Subscribe to user's own channel145client.subscribe('account', (response) => { /* auth events */ });146```147148### Functions149```typescript150// Execute function151const result = await functions.createExecution('function-id', JSON.stringify({ key: 'value' }));152console.log(result.stdout, result.stderr);153```154155## Common Patterns156157- **Permissions**: Use `Permission.read(Role.user(userId))` for fine-grained access control158- **Relationships**: Use relationship attributes for document linking159- **Migrations**: Use Appwrite CLI (`appwrite push/pull`) for collection schemas160- **Docker**: Self-host with `docker compose up -d`161162## How to Use1631641. Understand the requirement and existing codebase patterns1652. Design the solution with error handling and testability in mind1663. Implement incrementally with tests for each change1674. Verify against expected outcomes (manual and automated)1685. Document usage, edge cases, and integration points1696. Review with team before merging to shared branches170171## Red Flags172173- **Skipping tests to ship faster**: Untested code breaks in production when you least expect it174- **No error handling in production code**: Unhandled errors crash services and lose user data175- **Hardcoded configuration values**: Hardcoded values prevent environment switching and leak secrets176- **Ignoring security implications**: Missing input validation, auth bypasses, and injection vulnerabilities177- **Over-engineering simple solutions**: Premature abstraction adds complexity without proportional benefit178179## Verification180181- [ ] Skill output matches expected behavior182183## Process1841851. Analyze the task requirements1862. Apply domain expertise1873. Verify output quality188189## Anti-Rationalization Table190191| Rationalization | Reality |192|---|---|193| "Tests slow me down" | Bugs slow you down 10x more. Tests are speed, not overhead. |194| "I will refactor later" | Technical debt compounds. Refactor as you go. |195| "It works on my machine" | If it is not in CI, it does not work. Ship proof, not claims. |