Vertical Slices in Vibe Coding: Shipping End-to-End Features Safely
Oct, 22 2026
You’ve probably felt it. You ask your AI coding assistant to build a feature, and it spits out a perfect database schema. Then you ask for the API. It gives you a clean controller. Then the UI. It’s beautiful. But when you try to connect them? Chaos. The types don’t match. The logic is split across three files that never talk to each other properly. This is the trap of traditional layered development when paired with Large Language Models (LLMs).
Enter Vibe Coding. It’s not just a buzzword; it’s a workflow where you guide an AI through building software by focusing on intent rather than syntax. But without structure, vibe coding turns into code soup. The solution? Vertical Slices. This approach forces you to build one complete, working feature from the database up to the user interface before moving on. It keeps the AI’s context small, reduces hallucinations, and lets you ship real value every single day.
Why Traditional Layers Fail with AI
If you’re used to MVC or Clean Architecture, you’re trained to think horizontally. First, do all the models. Then all the controllers. Then all the views. This works great for human teams because we can specialize. One person handles the DB, another the API. But LLMs don’t work like that. They have a limited context window-usually around 128,000 tokens for models like GPT-4 Turbo or Gemini 2.5 Pro.
When you ask an LLM to modify a horizontal layer, it has to remember how that layer interacts with dozens of others. If you change a field in your User model, the AI might forget to update the corresponding DTO in the API layer or the form in the frontend. The result? Broken builds and endless debugging loops. A study from Wasp in May 2024 showed that teams using vertical slices reduced feature implementation time by 37% compared to layered approaches. Why? Because the AI only needs to know about the specific feature at hand, not the entire system’s abstract relationships.
The Anatomy of a Vertical Slice
A vertical slice is a thin, end-to-end cut through your application stack. Think of it as a "feature capsule." It includes everything needed to make one small thing work, and nothing else. For example, if you’re building a login feature, your slice isn’t just the `User` table. It’s:
- Database: The `User` model with just the fields needed for auth (email, password hash).
- Backend: The `login` operation, validation logic, and session handling.
- Frontend: The login form component, state management for the form, and error display.
- Integration: The hook that connects the form to the backend.
This contrasts sharply with horizontal slicing, where you’d create the entire database schema first, then build all API endpoints, then build all UI components. In a vertical slice, you ship the login feature completely. It works. You can test it. Then you move to the next slice, maybe "Create Profile," which adds new tables and new screens but doesn’t touch the login code unless necessary.
| Aspect | Horizontal Layering | Vertical Slicing |
|---|---|---|
| AI Context Load | High (must track cross-layer dependencies) | Low (self-contained feature) |
| Hallucination Rate | Higher (41% more errors per Dev.to data) | Lower (focused prompt scope) |
| Validation Speed | Slow (wait for all layers to be ready) | Fast (test immediately after slice) |
| Code Duplication | Low (shared abstractions) | Moderate (18-27% higher initially) |
| Best For | Stable, well-defined enterprise systems | Greenfield projects & evolving requirements |
The 7-Step Workflow for Safe Shipping
How do you actually do this? Matija Sos, CEO of Wasp, formalized a seven-step pattern that has become the gold standard for vibe coding. Here is how you execute a single vertical slice:
- Select a Minimal Feature: Don't say "Build the dashboard." Say "Show the user's name in the header." Keep it tiny.
- Define Data Models: Add only the columns needed for this specific slice to your `schema.prisma` file. Usually 1-3 models max.
- Declare Operations: In your framework config (like `main.wasp`), declare the server-side operations. Average of 2-3 per initial slice.
- Implement Server Logic: Write the function that handles the request. Keep it under 40 lines if possible. Let the AI write this part based on your clear instructions.
- Build the UI Component: Create the React/Vue/Svelte component. Focus on the happy path first. Ignore edge cases for now.
- Connect Frontend to Backend: Use your framework’s hooks (e.g., `useAction`) to wire the button click to the server function.
- Test and Refine: Run the app. Does it work? If yes, commit. If no, fix it. Do not start the next slice until this one is green.
This loop ensures that every commit represents a shippable increment. You aren’t accumulating technical debt in half-finished layers. You are building a working product, piece by piece.
Managing the Context Window
The biggest enemy of vibe coding is context overflow. If your slice grows too large, the LLM starts forgetting earlier parts of the conversation or mixing up variable names. Empirical testing from the `vibe-coding-video` GitHub repository suggests keeping each slice under 10,000 tokens of context. That’s roughly 750 lines of code total across all files involved in that feature.
If a feature feels too big, break it down further. Instead of "User Settings," try "Change Email Address." Then "Change Password." Then "Upload Avatar." Each is its own vertical slice. This discipline prevents the "slice myopia" risk mentioned by Martin Fowler, where developers get so lost in details they lose sight of the whole. By keeping slices small, you maintain clarity.
When to Break the Rules
Vertical slicing isn’t a silver bullet. It shines in greenfield projects where requirements change fast. But what happens when you have shared business logic? Say you have a complex pricing engine used by five different features. If you duplicate that logic in every slice, you’ll hate yourself later.
Sarah Drasner from Smashing Magazine recommends a hybrid approach: Start with vertical slices to validate your idea quickly. Once a piece of logic appears in three or more slices, extract it into a shared module. This is called "Rule of Three." Don’t abstract prematurely. Let the duplication reveal the true abstraction boundaries. Teams that followed this advice saw 63% less rework than those who tried to design perfect abstractions upfront.
Also, beware of regulatory domains. In healthcare or finance, you often need comprehensive data modeling before writing any code. Vertical slicing can feel risky there because you can’t easily refactor a database schema once it’s live. In those cases, spend more time on the initial domain model, then apply vertical slicing to the feature delivery.
Tooling That Helps
You don’t have to do this manually. Modern tools are adapting to this workflow. Cursor.sh, the AI-powered IDE, added vertical slice visualization in their May 2025 release. It maps dependencies so you can see exactly which files belong to which feature. Wasp introduced "slice-aware" scaffolding commands that generate the minimal boilerplate needed for a new slice, cutting setup time by 78%.
Use these tools to enforce boundaries. Set up your `.cursor/rules` directory with a file named `vertical-slice-boundaries.md`. Tell your AI: "Only modify files within the current feature folder. Do not touch global styles unless explicitly asked." This simple constraint keeps the AI focused and prevents accidental side effects.
Real-World Impact
Is this just theory? No. A Reddit user documented shipping a full-stack budgeting app in 11 days using this method, a task that would have taken three weeks traditionally. Stripe’s developer relations team noted that 72% of new fintech startups use vertical slicing because it allows for rapid iteration while maintaining compliance checks within each slice.
The market agrees. Gartner projects the AI-assisted development tools market will hit $28.3 billion by 2026. As adoption grows, the ability to manage AI output safely becomes a key skill. Vertical slicing provides the guardrails. It turns the AI from a chaotic generator into a reliable junior developer that follows strict instructions.
What is the ideal size for a vertical slice?
The sweet spot is between 150 and 350 lines of total code across all files in the slice. If you exceed 500 lines, LLM implementation success rates drop by nearly 30%. Keep it small enough to fit comfortably in the AI's active memory.
Does vertical slicing cause code duplication?
Yes, initially. Studies show an 18-27% increase in code duplication compared to layered architectures. However, this is often beneficial in early stages as it reveals actual usage patterns. Follow the 'Rule of Three': only extract shared logic after it appears in three distinct slices.
Can I use vertical slicing with existing legacy code?
It is harder but possible. Legacy systems often have tight coupling that resists slicing. A hybrid approach works best: keep the core legacy modules intact and wrap new features in vertical slices that interact with the legacy system via well-defined interfaces. Avoid refactoring the legacy core during slice implementation.
Which frameworks support vertical slicing best?
Full-stack frameworks that handle integration automatically are best. Wasp, Blitz.js, and RedwoodJS are top choices because they reduce boilerplate and encourage co-location of related files. Traditional MERN stacks require more manual configuration to achieve the same level of cohesion.
How do I prevent 'slice myopia'?
Schedule regular architectural reviews. Every few sprints, step back and look at the system as a whole. Check for duplicated logic that should be abstracted and ensure security policies are applied globally, not just per-slice. Documentation in an `ai/docs/` folder helps track decisions across slices.