Topic 3 of 5 · 4 min read
Slicing a feature into vertical slices
Goal: Split a feature request into ordered slices that each produce a working, testable change.
Slice a feature vertically: each slice is a thin end-to-end path through the system that builds, passes tests and could merge on its own. Avoid horizontal slices such as "all the database changes" or "all the UI", because none of them works until the last one lands.
Check yourself · 1 of 3
In feature planning, what does a vertical slice mean?
Why it matters
An agent needs a result it can run. A horizontal slice, such as a new database table with nothing using it, cannot be exercised end to end, so the agent can only check that it compiles. Mistakes then show up later, after more code depends on them. A vertical slice gives the agent, and you, real behaviour to test at every step. It also keeps each diff small enough to read.
How to slice
- Find the thinnest useful behaviour. Ask: what is the smallest thing a user could do that touches every layer? Often that is the happy path with one case.
- Order by risk and dependency. Put the slice that proves the riskiest assumption first, such as the external API call or the migration.
- Give each slice its own check. A test, a command or a request that fails before and passes after.
- Keep the app working between slices. Hide unfinished behaviour behind a flag or an unused route, not behind a broken build.
- Hand over one slice per session. Start the next session fresh, with a short note of what is now true.
Before and after
Feature: "Users can export their orders as CSV."
Horizontal plan:
- Task 1: build the CSV library wrapper.
- Task 2: add the endpoint.
- Task 3: add the button.
- Task 4: write tests.
Nothing is testable until task 3, and tests come last.
Vertical plan:
1. GET /orders/export returns a CSV with id and total for the
signed-in user. Test: request returns 200 and two header columns.
2. Add date, status and currency columns, with escaping for commas
and quotes. Test: a row with a comma stays in one cell.
3. Add the Export button that downloads the file.
Test: clicking calls the endpoint.
4. Add a date range filter. Test: orders outside it are excluded.
Each step runs, each has a test, and step 1 can ship alone.
What goes wrong
- Layer slicing. Work that cannot run until every layer exists.
- Slices that are not independent. If slice 3 needs unmerged code from slice 2 and slice 2 stalls in review, you have a pile-up.
- Tests last. An agent that writes tests only at the end tends to write tests that describe what it built, not what you wanted.
- Slices too thin. A slice that changes a single constant adds overhead without reducing risk.
Examples
Slicing a password reset
- A user enters an email; the app logs a reset link (no email yet). Test: the log contains a link for a known user.
- Send the link through the mail provider. Test: the provider mock receives one message.
- The link opens a form that sets a new password. Test: the old password stops working.
- Links expire after a set time. Test: an expired link is refused.
Slice 1 proves token handling before anything touches the mail service.
A layered plan that stalls
The team asks agents for "the new orders table", "the orders API" and "the orders page" as three parallel tasks. The API agent assumes a column name that the table agent chose differently. All three diffs build alone and fail together. One vertical slice, owned by one session, would have exposed the mismatch on day one.
Key points
- A vertical slice cuts through every layer and delivers one small behaviour that can be run and tested.
- Horizontal slices such as "all the backend first" cannot be exercised until the last slice lands.
- Order slices so the riskiest assumption is proved first.
- Each slice needs its own check that fails before the work and passes after it.
- Keep the build green between slices, using flags or unused routes for unfinished behaviour.
Common mistakes
- Cutting work by layer (database, API, UI) so nothing runs end to end until the last task.
- Giving parallel agents slices that depend on each other's unmerged output.
- Leaving all tests for a final slice instead of writing each slice's check with it.
- Making the first slice the easiest one rather than the one that proves the riskiest assumption.
Check yourself · 2 of 3
You plan an "export orders as CSV" feature. Which first slice is best?
Check yourself · 3 of 3
Why should the riskiest assumption go in an early slice?
Practice items, not counted towards your mastery.
Start here
- Small CLs (Google Engineering Practices) (opens in a new tab)ArticleFree
Why small, self-contained changes get better reviews, and how to split large ones.
- Best practices for Claude Code (Claude Code docs) (opens in a new tab)DocsFree
A vendor's advice on verification, planning first and managing a filling context.
- Best practices for using GitHub Copilot to work on tasks (opens in a new tab)DocsFree
What makes a task a good fit for a coding agent: clear scope and acceptance criteria.