home/roleplay/horizontal-slice-instructions

Horizontal Slice.instructions

GPTClaudeGemini··1,269 copies·updated 2026-07-14
horizontal-slice-instructions.prompt
# Horizontal Slice Instructions

## Overview

A **horizontal slice** is infrastructure-level implementation that provides foundational capabilities across the application without delivering a complete user-facing feature. Unlike vertical slices (which cut through all layers to deliver working functionality), horizontal slices build shared services, libraries, or integrations that enable future vertical slices.

### Key Characteristics

- ✅ **Infrastructure-focused** - Builds shared services, SDKs, or utilities
- ✅ **Layer-specific** - Operates at one architectural layer (e.g., model layer, lib layer)
- ✅ **Reusable** - Designed for multiple features to consume
- ✅ **Foundation-building** - Enables future vertical slices
- ✅ **Not user-facing** - No complete UI-to-database feature flow
- ✅ **Requires vertical slice to complete** - Must be connected to user features later

**Important:** Horizontal slices are complementary to vertical slices, not a replacement. They establish shared infrastructure that vertical slices then consume.

## When to Use Horizontal Slices

### ✅ Appropriate Use Cases

**Third-Party Service Integration:**

- Email service SDK (Resend, SendGrid)
- Payment gateway (Stripe, Polar)
- Analytics platform (PostHog, Mixpanel)
- Cloud storage (S3, Cloudinary)
- External APIs

**Shared Utilities:**

- Authentication middleware
- Caching layer
- Error tracking service
- Logging infrastructure
- Rate limiting

**Common Libraries:**

- Form validation utilities
- Date/time helpers
- String formatting
- File processing
- Image optimization

**Why horizontal first:**

- Multiple features will use the service
- Integration complexity requires focused implementation
- SDK/API patterns need to be established
- Testing infrastructure separately is valuable

### ❌ Inappropriate Use Cases

**Feature-Specific Logic:**

- User profile management → Should be vertical slice
- Post creation → Should be vertical slice
- Comment system → Should be vertical slice
- Search functionality → Should be vertical slice

**Single-Use Components:**

- One-off UI components
- Feature-specific API endpoints
- Custom business logic for single feature

**Why vertical instead:**

- Only one feature needs it
- Can't be reused
- User value is immediate
- Integration risk needs early validation

## Horizontal Slice vs Vertical Slice

### Horizontal Slice (Infrastructure)

when to use it

Community prompt sourced from the open-source GitHub repo sethdavis512/prompt-bucket (no explicit license). A "Horizontal Slice.instructions" style prompt — adapt the placeholders and specifics to your task. Imported as-is and not independently retested here, so check the output before relying on it.

tags

roleplaycommunitygeneral

source

sethdavis512/prompt-bucket · no explicit license