A feature is not a folder. It is models, routes, pages, screens, a sidebar entry and translation keys. How Hype Stack copies whole features into a repo you own without breaking it on the second install.
Ask a component library what a "feature" is and you get a folder of React files. Ask a product team and you get a different answer. Teams, in our stack, is two Prisma models, a Hono route group, backend and frontend feature modules, two TanStack Router pages, its Expo screens, a sidebar entry, and translation keys in three message catalogs. That is one feature. It runs top to bottom through the repo, which is what people mean by vertical slice architecture.
shadcn proved that people want to own their code instead of importing it. Copy the button in, it is yours, edit it. But a button is horizontal: it lives in one folder and touches nothing. A feature is vertical, and copying a vertical slice into a repo the user owns is a much harder problem, because a feature is more than its files. It is also everything those files expect the rest of the app to do: register this route, mount this provider, know about this table, translate this label.
Our answer, after building the Hype Stack pack system, fits in one sentence. Copying whole features into a repo you do not control only works if every side effect is declared and every modification is a codemod.
Anatomy of a pack
A pack is a folder, and the parts that matter are three:
files/is the shipped source. It mirrors the target project layout:files/backend/src/features/teams,files/frontend/src/routes/(private)/teams,files/mobile/src/features/teams. The CLI copies these into the user's repo, shadcn-style. No npm package, no version lock, the user owns every line afterward.manifest.jsondeclares everything else: where each file lands, how it lands, and every hook the feature needs into code the pack does not ship.setup/is development-only scaffolding, never copied to anyone. Pack files importsdkfrom@/api/sdk, but during pack development there is no app for that to resolve against, so each pack carries its own typed SDK stub insetup/frontend/sdk.tsand an extended KyselyDBtype sopostgres.qb.selectFrom("team")typechecks in isolation. It exists so the shipped code compiles before it ever meets a project.
The files/ directory is the least interesting of the three. It is just application code. The manifest is where the
idea lives.
The manifest is the feature's shadow
Here is a trimmed slice of the Teams manifest:
{
"name": "pack-teams",
"dependencies": ["starter-saas"],
"files": [
{
"source": "files/backend/prisma/schema/team.prisma",
"target": "{{backend.prisma}}/schema/team.prisma",
"strategy": "create"
},
{
"source": "files/frontend/messages/en.json",
"target": "{{frontend.root}}/messages/en.json",
"strategy": "merge-json",
"slot": "frontend"
},
{
"source": "files/mobile/src/routes/(private)/teams",
"target": "{{mobile.routes}}/(private)/teams",
"strategy": "create",
"slot": "mobile"
}
],
"routes": [{ "import": "teamRoutes", "from": "./teams", "prefix": "/teams" }],
"frontendRoutes": [{ "path": "/teams", "search": "Record<string, never>" }],
"nav": [
{
"group": "tertiary",
"label": "Teams",
"messageKey": "teams_nav_label",
"icon": "Users",
"to": "/teams"
}
]
}Every side effect the feature has on the world outside its own folders is a field here. Backend routes to register.
Frontend routes to add to the typed URL union. A sidebar entry, with a messageKey so it renders through the
translation catalog instead of a hardcoded string. Notifications, a busier pack, also declares sockets (a WebSocket
namespace with its payload types), navbarActions (the bell dropdown in the navbar), dashboardRows (a widget on the
admin dashboard), and dependencies_npm (react-email, added to the backend's package.json).
The manifest schema describes about thirty of these declaration surfaces today: env vars with their setup requirements, backend context variables, permission subjects with role grants, organization onboarding steps, settings-page tabs, root-level providers, admin cards, scheduled jobs and queues. Reading a manifest tells you everything a feature will do to a project before a single file moves. Everything below depends on that.
Codemods over documentation
The usual template answer to "this feature needs a route registered" is a README step: add this import to
routes/index.ts. That is a modification outsourced to the user, and some of them will do it wrong, skip it, or do it
twice. So we do not ask. The installer reads the routes field and a codemod writes the import, the .route() call,
and the SDK type tuple into routes/index.ts itself. The other surfaces work the same way: one patch function each for
nav constants, env files, sockets, providers, settings tabs, jobs, queues and the rest, about thirty in all.
Two design rules keep this sane. First, every codemod is idempotent. Each one checks whether its import or entry already
exists before touching anything, so running an install twice changes nothing. Second, a codemod targets an extension
point, not arbitrary code. A SaaS starter ships setup-organization/steps/index.ts containing an empty steps array
precisely so a later pack can declare onboardingSteps and have the codemod append to it. Pack B extends pack A through
a socket pack A deliberately left open.
There is also a hard rule about what a pack may never do: ship its own copy of a file the base template owns. Every copy
strategy fails on a file like appConfig, where the user has typed their own app name. override silently reverts
their edit. create nags them on every install. skip-if-exists is the sneaky one: the copy never lands, so nothing
ever validates it, and it drifts for months without an error. The only correct move on a file you do not own is a
targeted patch that adds what is missing and leaves existing values alone.
Merging a schema you do not own
The database is the sharpest version of that problem. The user's Prisma schema is theirs. They rename fields, add models, change indexes. Any pack that parses and rewrites that file will eventually eat someone's edit.
So we do not merge at all. Prisma supports multi-file schemas, and each pack ships its models as new files: Teams drops
team.prisma and team-invitation.prisma into prisma/schema/ with the create strategy. The pack's tables arrive
without any existing schema file being read, parsed, or rewritten. Reinstalling is safe, and every edit the user made to
their own models survives because we never open those files. The migration stays in the user's hands: the CLI generates
the client and tells you to run prisma migrate dev, and an unreachable database or a drifted migration state gets an
explanation, not a forced reset.
The message catalogs need the opposite treatment, because there a shared file is unavoidable: every pack contributes
keys to one messages/en.json. Text splicing would produce invalid JSON, so merge-json parses both sides and merges
structurally. Keys already in the file keep their position and new keys append in order, so a reinstall produces a diff
of exactly nothing.
Combinations that cannot break
Arbitrary combinations only stay installable if some combinations are impossible. The compose picker encodes this
itself: starter and layout are single-choice, features are multiselect. You cannot install two auth starters, because
two things claiming the same routes and the same session model is not a combination, it is a conflict. You can install
any set of feature packs, because each one declares what it needs and the CLI resolves the dependency graph before
copying anything. Teams depends on starter-saas, a family rather than one pack, so the dependency resolves to
whichever SaaS starter you picked, Better Auth or WorkOS, and never drags the other one in beside it.
stack.json is the memory
None of this survives a second run without state. stack.json, created at project setup, records the app layout (so
targets like {{backend.features}} resolve to real paths, even ones the user moved), the installed packs, and an
append-only installs log with the commit or version and the time of everything that ever landed. A later install of
the same pack adds a new entry, and the newest one wins, so an upgrade shadows the original record without erasing it.
That file is what makes compose re-runnable. Run it again and already-installed packs are filtered from the plan,
idempotent codemods find their guards and do nothing, merge-json produces no diff, and only new packs do work.
create conflicts with files you wrote yourself get an explicit prompt rather than a silent overwrite. Recompose is
boring, and boring took more engineering than the first install.
This is also why the shape suits a coding agent. Each feature sits in its own folders with its contract in one file, so the agent can load the whole feature and little else. AI Agent Boilerplate goes into why that matters for context, and How to Build a SaaS shows which packs make up a SaaS and the order to add them in.
Where this loses
This approach costs more than copying a component, on both sides.
For us, every feature is written twice over: the code, and the declaration of the code. Forget to declare a nav entry
and it ships invisible. The setup/ stub layer exists only because shipped code has to typecheck against an app that is
not there, and keeping stubs honest against the real template is ongoing gardening, enforced by tests rather than by the
compiler alone.
For users, an installed pack is a starting point, not an endpoint. postInstall still tells you to run migrations and
review permission subjects. And the anchors can go missing: codemods patch well-known files, and if you deleted
routes/index.ts or rewrote the nav constants beyond recognition, the guard finds nothing to match and the patch cannot
land where it expected. The failure is visible rather than corrupting, but reconnecting the wire is on you. merge-json
has a sharp edge too: the pack wins on key conflicts, so if you reworded a pack-owned message key and then reinstall
that pack, your wording loses. Switching starter variants leaves the old variant's code in place for you to delete, by
design, because deleting user-owned files automatically is worse.
The trade is explicit. A generator that runs once can be sloppy, because nobody runs it twice. A system that copies
vertical features into a repo the user owns, and expects to come back later with more, has no room for undeclared side
effects. The manifest declares them. The codemods perform them. stack.json remembers them.
The same format is open to anyone: a pack you write yourself installs through the same manifest and codemods, and the
MCP server's pack_authoring_guide tool walks an agent through writing one.