Skip to content
Slicekit

Backend guides

Removing a feature

Cleanly delete a vertical slice across the API, frontend, permissions and tests.

View .md
On this page

The inverse of adding a vertical slice. Slices remove cleanly because nothing else depends on them: a feature lives in its own folder and is discovered by convention, not wired into a central registry. The work is mostly deletion plus a few spots where a slice reached into shared surfaces (schema, integration-event contracts, personal-data handlers, permissions).

Work the checklist top to bottom. The compiler and the test suite are your safety net: orphaned references surface as build errors, schema drift surfaces in feature and API tests.

1. Delete the Core slice and its endpoint

A slice is three files in three projects: the command and handler in Slicekit.Core, the HTTP adapter in Slicekit.Api, and the tests. Remove all three.

rm -r api/src/Slicekit.Core/Features/<Area>/<UseCase>/
rm api/src/Slicekit.Api/Endpoints/v1/<Group>/<UseCase>Endpoint.cs
rm api/tests/Slicekit.Feature.Tests/Features/<Area>/<UseCase>Tests.cs

Also remove any API integration test under api/tests/Slicekit.Api.Tests/ that covered the endpoint.

2. Check the integration-event contract

If the slice published an IIntegrationEvent (look under api/src/Slicekit.Core/IntegrationEvents/), decide based on consumers:

  • Other services consume it: keep the contract, retire only the publisher, and note that the event is no longer emitted.
  • Nobody consumes it: delete the contract too.

Grep before you delete:

rg "<EventName>" --type cs

See CQRS and events for how raised and published events flow through the outbox.

3. Drop owned schema

If the slice owned tables or columns that nothing else uses, drop them with a new EF migration:

dotnet ef migrations add Drop<Thing> \
  --project api/src/Slicekit.Core \
  --startup-project api/src/Slicekit.Api \
  --context AppDbContext

See adding a migration for outbox-aware sequencing if the dropped tables sat alongside Wolverine’s transactional outbox.

4. Strip personal-data branches

If the slice persisted user-personal data, remove its branch from the export and delete handlers:

  • api/src/Slicekit.Core/Features/Users/ExportMyData/Handler.cs
  • api/src/Slicekit.Core/Features/Users/DeleteUser/Handler.cs

Update their tests in the same change so the export and delete paths stay green.

5. Tidy API versioning

If the deleted endpoint was the last one in a published API version, tidy api/src/Slicekit.Api/Configuration/Versioning.cs and api/src/Slicekit.Api/Endpoints/RegisterEndpoints.cs. This is the inverse of standing a new version up.

6. Remove orphaned permissions

If the slice required a permission via Allow.<Name>, check whether anything else still references it in api/src/Slicekit.Core/Permissions/Allow.cs:

rg "Allow.<Name>" --type cs

If the permission is now orphaned, remove the constant and add a migration that deletes the permission row. See adding a permission for the inverse.

7. Remove the frontend slice

If the API slice had a UI counterpart:

  • Delete frontend/src/features/<slice>/.
  • Drop any routes under frontend/src/routes/ that mounted the slice, and remove nav entries that linked to them.
  • Remove the slice’s i18n keys from frontend/src/shared/i18n/locales/en.json and nl.json, plus any errorCodeMap.ts entries the slice added. Keeping the two locale files matched keeps the locale-completeness check green.
cd frontend && pnpm typecheck && pnpm lint

Typecheck and lint surface orphaned imports the file deletes left behind.

Verify

  • dotnet build api/slicekit.slnx passes. Compile errors expose orphaned references the grep missed.
  • dotnet test api/tests/Slicekit.Unit.Tests api/tests/Slicekit.Architecture.Tests --nologo passes (the fast loop).
  • dotnet test api/slicekit.slnx --nologo passes. The full suite catches schema drift in feature and API tests.
  • git grep <UseCase> returns nothing.

Checklist

  • Core slice folder deleted (Features/<Area>/<UseCase>/).
  • Slicekit.Api endpoint deleted, plus its feature and API integration tests.
  • Integration-event contract kept or deleted based on consumers.
  • Migration added for any tables or columns the slice owned.
  • Personal-data branches removed from ExportMyData and DeleteUser, tests updated.
  • API versioning tidied if this was the last endpoint in a version.
  • Orphaned Allow.<Name> permission removed, with a migration deleting the row.
  • Frontend feature folder, routes, nav entries and i18n keys removed.
  • Build, fast suite and full suite green, git grep clean.