---
name: vertical-slice
description: Enforce end-to-end working increments at each workflow step. Use during planning and decomposition phases. Prevents "horizontal layers" — building all models, then all services, then all tests — which produces nothing shippable until the very end. Every slice must be testable and deployable in isolation.
user-invocable: false
model-invocable: true
side-effects: file-writes
permission-profile: normal
triggers:
  - plan
  - build
  - "*"
---

# Vertical Slice

## Iron Law

```
EVERY SLICE MUST BE INDEPENDENTLY TESTABLE AND DEPLOYABLE.
NO SLICE IS DONE UNTIL ITS CONSUMER PATH WORKS END-TO-END.
```

A slice that produces "partial infrastructure" is not a slice — it is a layer. Layers are not shippable. If the slice cannot be verified in isolation, it is too large or wrongly cut.

## Recognize Your Own Rationalizations

- "I'll wire it up in the next slice." → If it can't be verified now, you can't confirm the first slice worked. Bugs compound invisibly.
- "It's more efficient to build all the DB tables first." → It is more efficient to ship nothing until the very end. Horizontal layers guarantee integration surprises.
- "The consumer isn't built yet." → Then build a stub consumer in this slice. The slice defines its own consumer path.
- "I'll test it all together when it's complete." → "Together" is where integration bugs hide. Test each slice independently.

## When to Run

- Planning or decomposition: before breaking a milestone into tasks.
- Slice review: before starting a new slice, confirm the previous one is truly end-to-end.
- When an autonomous loop has been running for more than two slices without a shippable increment.

## Skill Chain

Planning-phase skill. Inline with the main delivery chain.

```
← prev:  architecture-planning, pm-planning, or any planning phase
→ next:  spec-first-tdd (write the failing test for the first slice)
```

## Slice Definition Protocol

For each slice, define **before writing any code**:

```
Slice ID:     <S01, S02, ...>
Purpose:      <one sentence — why does this slice exist? what value does it add?>
Entry point:  <the user-visible or API-visible surface that exercises this slice>
Done state:   <exact observable behaviour that proves this slice is complete>
Verifier:     <the command or test that confirms done state — must be runnable>
Stub strategy: <if a dependency isn't built yet, what stub/fake makes this testable?>
```

A slice without a `Verifier` is not a valid slice. Stop and define one before proceeding.

## Anti-Patterns to Detect and Reject

| Pattern | Problem | Correct Cut |
|---------|---------|-------------|
| "Add all DB tables" | No consumer, not testable alone | "Add one table + one read + one test" |
| "Build the service layer" | No entry point, no verifier | "Add one endpoint that returns real data from DB" |
| "Implement the model" | Model without integration is not slice | "Add model + minimal handler + test that calls handler" |
| "Set up infrastructure" | Infrastructure without behaviour is scaffolding | Include the first real use in the same slice |
| "Refactor X" | Refactors with no consumer test are invisible | Include the test that proves behaviour unchanged |

## Slice Sizing

**Right-sized slice:** completes in a single autonomous iteration, has one clear verifier, can be described in one sentence.

**Too large:** "Build the authentication system." Cut it: login endpoint → token validation → logout → password reset.

**Too small:** "Add an import statement." Merge it with the first meaningful use.

**Boundary check:** If a slice takes more than one session to complete, it is too large. Cut it.

## Completion Criteria

Each slice is done when:

- [ ] `Verifier` command runs and passes
- [ ] The consumer path works end-to-end (not "the model is ready")
- [ ] No "temporary stubs" left in production paths (test stubs are fine)
- [ ] The done state matches what was defined before coding started

If the verifier passes but the done state wasn't defined upfront, you completed something — you just don't know what. Define done state first next time.
