Skip to main content

application-patterns

Common application development patterns and implementations

Source facts

Repository
miles990/claude-software-skills
Last source activity
January 8, 2026 at 02:34
Detected SKILL.md language
English
Stars
26
Forks
6

Install options

The review-first prompt is selected by default. You can switch to a direct command or download a local copy.

Review the source files

Read SKILL.md and any companion files shown by SkillsMP before deciding whether to install.

Showing SKILL.md

SKILL.md
Source instructions ยท Read-only preview
name
application-patterns
description
Common application development patterns and implementations
domain
domain-applications
version
1.0.0
tags
["crud","authentication","admin","dashboard","forms","file-upload","search"]
triggers
{"keywords":{"primary":["crud","authentication","admin panel","dashboard","file upload","search"],"secondary":["login","signup","form","data table","bulk operations","workflow","i18n"]},"context_boost":["app","application","feature","implementation","pattern"],"context_penalty":["infrastructure","deployment","devops"],"priority":"high"}
# Application Development Patterns ## Overview Common patterns for building real-world applications. These patterns solve recurring problems in application development. --- ## CRUD Applications ### Data Flow Pattern ``` โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ Form โ”‚ โ”€โ”€โ†’ โ”‚Validate โ”‚ โ”€โ”€โ†’ โ”‚ Service โ”‚ โ”€โ”€โ†’ โ”‚ DB โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ†‘ โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ Response โ†โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ ``` ### Form Handling Best Practices ```typescript // 1. Validation schema (shared frontend/backend) const userSchema = z.object({ email: z.string().email(), name: z.string().min(2).max(100), role: z.enum(['admin', 'user', 'guest']) }); // 2. Server action with error handling async function createUser(formData: FormData) { const result = userSchema.safeParse(Object.fromEntries(formData)); if (!result.success) { return { error: result.error.flatten() }; } try { const user = await db.user.create({ data: result.data }); return { success: true, data: user }; } catch (e) { if (e.code === 'P2002') { return { error: { email: 'Email already exists' } }; } throw e; } } ``` --- ## User Authentication ### Authentication Flow ``` โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ Authentication Flows โ”‚ โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค โ”‚ โ”‚ โ”‚ Email/Password: โ”‚ โ”‚ Login โ†’ Validate โ†’ Create Session โ†’ Set Cookie โ†’ Redirect โ”‚ โ”‚ โ”‚ โ”‚ OAuth (Social Login): โ”‚ โ”‚ Redirect โ†’ Provider Auth โ†’ Callback โ†’ Upsert User โ†’ Done โ”‚ โ”‚ โ”‚ โ”‚ Magic Link: โ”‚ โ”‚ Email โ†’ Generate Token โ†’ Send Link โ†’ Verify โ†’ Login โ”‚ โ”‚ โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ ``` ### Session Management | Strategy | Pros | Cons | |----------|------|------| | JWT | Stateless, scalable | Can't revoke easily | | Server Session | Revocable, secure | Requires session store | | Hybrid | Best of both | More complex | ### Security Checklist - [ ] Password hashing (bcrypt/argon2) - [ ] Rate limiting on login - [ ] CSRF protection - [ ] Secure cookie settings (httpOnly, secure, sameSite) - [ ] Account lockout after failed attempts - [ ] Password reset token expiration --- ## Admin Dashboards ### Data Table Pattern ```typescript // Reusable data table with sorting, filtering, pagination interface DataTableProps<T> { data: T[]; columns: ColumnDef<T>[]; pagination: { page: number; pageSize: number; total: number }; sorting: { field: string; direction: 'asc' | 'desc' }[]; filters: Record<string, unknown>; onStateChange: (state: TableState) => void; } // Server-side handling async function getUsers(params: TableState) { const { page, pageSize, sorting, filters } = params; const query = { where: buildWhereClause(filters), orderBy: buildOrderBy(sorting), skip: (page - 1) * pageSize, take: pageSize, }; const [users, total] = await Promise.all([ db.user.findMany(query), db.user.count({ where: query.where }) ]); return { data: users, total }; } ``` ### Bulk Operations ```typescript // Safe bulk delete with confirmation async function bulkDelete(ids: string[]) { // 1. Validate permissions for each item const items = await db.item.findMany({ where: { id: { in: ids } }, select: { id: true, ownerId: true } }); const authorized = items.filter(item => canDelete(currentUser, item) ); // 2. Soft delete or hard delete await db.item.updateMany({ where: { id: { in: authorized.map(i => i.id) } }, data: { deletedAt: new Date() } }); return { deleted: authorized.length, skipped: ids.length - authorized.length }; } ``` --- ## File Management ### Upload Strategies | Method | Use Case | Max Size | |--------|----------|----------| | Direct to server | Small files | ~10MB | | Presigned URL | Large files | Unlimited | | Chunked upload | Very large files | Unlimited | | Resumable | Unreliable network | Unlimited | ### Presigned URL Flow ``` Client Server S3 โ”‚ โ”‚ โ”‚ โ”‚โ”€โ”€ Request upload URL โ”€โ”€โ†’โ”‚ โ”‚ โ”‚ โ”‚โ”€โ”€ Generate presigned โ”€โ†’โ”‚ โ”‚โ†โ”€โ”€ Return presigned URLโ”€โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ Upload file directly โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ†’โ”‚ โ”‚ โ”‚ โ”‚ โ”‚โ”€โ”€ Confirm upload โ”€โ”€โ”€โ”€โ”€โ”€โ†’โ”‚ โ”‚ โ”‚ โ”‚โ”€โ”€ Verify file exists โ”€โ†’โ”‚ โ”‚โ†โ”€โ”€ Success โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”‚ โ”‚ ``` ### Image Processing Pipeline ```typescript async function processUpload(file: File) { // 1. Validate file type and size if (!ALLOWED_TYPES.includes(file.type)) { throw new Error('Invalid file type'); } // 2. Generate variants const variants = await Promise.all([ sharp(file.buffer).resize(100, 100).toBuffer(), // thumbnail sharp(file.buffer).resize(800, 600).toBuffer(), // medium sharp(file.buffer).resize(1920, 1080).toBuffer(), // large ]); // 3. Upload to CDN const urls = await uploadToS3(variants); // 4. Store metadata return db.image.create({ data: { original: urls.original, thumbnail: urls.thumbnail, medium: urls.medium, large: urls.large, mimeType: file.type, size: file.size, } }); } ``` --- ## Search Implementation ### Search Architecture ``` โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ Database โ”‚ โ”€โ”€โ†’ โ”‚ Sync โ”‚ โ”€โ”€โ†’ โ”‚ Search โ”‚ โ”‚ (Primary) โ”‚ โ”‚ Worker โ”‚ โ”‚ Engine โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ†‘ โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ โ”‚ Client โ”‚ โ”€โ”€โ†’ โ”‚ Search API โ”‚ โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ ``` ### Search Features Checklist - [ ] Full-text search - [ ] Faceted filtering - [ ] Autocomplete/suggestions - [ ] Typo tolerance (fuzzy matching) - [ ] Highlighting - [ ] Synonyms - [ ] Relevance tuning --- ## Workflow Engines ### State Machine Pattern ```typescript const orderStateMachine = { initial: 'pending', states: { pending: { on: { PAY: 'paid', CANCEL: 'cancelled' } }, paid: { on: { SHIP: 'shipped', REFUND: 'refunded' } }, shipped: { on: { DELIVER: 'delivered', RETURN: 'returned' } }, delivered: { type: 'final' }, cancelled: { type: 'final' }, refunded: { type: 'final' }, returned: { on: { REFUND: 'refunded' } } } }; ``` ### Approval Workflow ```typescript interface ApprovalStep { id: string; approvers: string[]; // User IDs or roles requiredApprovals: number; // How many need to approve timeout?: Duration; // Auto-escalate after escalateTo?: string; // Next approver on timeout } async function processApproval(stepId: string, userId: string, decision: 'approve' | 'reject') { const step = await db.approvalStep.findUnique({ where: { id: stepId } }); // Record decision await db.approval.create({ data: { stepId, userId, decision, timestamp: new Date() } }); // Check if complete const approvals = await db.approval.count({ where: { stepId, decision: 'approve' } }); if (approvals >= step.requiredApprovals) { await advanceToNextStep(step); } } ``` --- ## Multi-language (i18n) ### Translation Structure ``` locales/ โ”œโ”€โ”€ en/ โ”‚ โ”œโ”€โ”€ common.json # Shared strings โ”‚ โ”œโ”€โ”€ auth.json # Auth module โ”‚ โ””โ”€โ”€ dashboard.json # Dashboard module โ”œโ”€โ”€ zh-TW/ โ”‚ โ”œโ”€โ”€ common.json โ”‚ โ”œโ”€โ”€ auth.json โ”‚ โ””โ”€โ”€ dashboard.json โ””โ”€โ”€ ja/ โ””โ”€โ”€ ... ``` ### Best Practices 1. **Key Naming**: Use namespaced keys ```json { "auth.login.title": "Sign In", "auth.login.email": "Email Address", "auth.login.submit": "Sign In" } ``` 2. **Pluralization**: Handle plural forms ```json { "items": "{count, plural, =0 {No items} =1 {1 item} other {# items}}" } ``` 3. **Variables**: Use interpolation ```json { "welcome": "Welcome, {name}!" } ``` 4. **Date/Number Formatting**: Use Intl APIs ```typescript new Intl.DateTimeFormat(locale).format(date) new Intl.NumberFormat(locale, { style: 'currency', currency }).format(amount) ``` --- ## Related Skills - [[architecture-patterns]] - Overall system design - [[frontend]] - UI implementation - [[backend]] - Server implementation - [[database]] - Data persistence - [[security-practices]] - Security considerations
View on GitHub